Commit 9e54d30c authored by PACANOWSKI Romain's avatar PACANOWSKI Romain

Indendation and cosmetic changes

parent db951976
......@@ -36,66 +36,63 @@ class arguments
{
}
arguments(int argc, char** const argv)
{
for(int i=0; i<argc; ++i)
{
std::string temp(argv[i]) ;
std::string key;
std::string data;
if(temp.compare(0, 2, "--") == 0)
{
for(int i=0; i<argc; ++i)
key = temp.substr(2, temp.size()-2) ;
#ifdef DEBUG_ARGS
std::cout << "<<DEBUG>> (" << i << ")" << key << " -> [ ";
#endif
if(++i < argc)
{
std::string temp(argv[i]) ;
std::string key;
std::string data;
if(temp.compare(0, 2, "--") == 0)
std::string next(argv[i]) ;
if(next[0] == '-')
{
//#define DEBUG_ARGS
key = temp.substr(2, temp.size()-2) ;
#ifdef DEBUG_ARGS
std::cout << "<<DEBUG>> (" << i << ")" << key << " -> [ ";
#endif
if(++i < argc)
{
std::string next(argv[i]) ;
if(next[0] == '-')
{
--i;
}
else if(next[0] == '[' && next[next.size()-1] != ']')
{
data.append(next);
++i;
while(i < argc && next[next.size()-1] != ']')
{
next = argv[i] ;
data.append(" ");
#ifdef DEBUG_ARGS
std::cout << " ";
#endif
data.append(next);
#ifdef DEBUG_ARGS
std::cout << "(" << i << ")" << next;
#endif
--i;
}
else if(next[0] == '[' && next[next.size()-1] != ']')
{
data.append(next);
++i;
}
--i;
}
else
{
#ifdef DEBUG_ARGS
std::cout << next;
#endif
data.append(next);
}
++i;
while(i < argc && next[next.size()-1] != ']')
{
next = argv[i] ;
data.append(" ");
#ifdef DEBUG_ARGS
std::cout << " ";
#endif
data.append(next);
#ifdef DEBUG_ARGS
std::cout << "(" << i << ")" << next;
#endif
++i;
}
#ifdef DEBUG_ARGS
std::cout << "]" << std::endl;
#endif
_map.insert(std::pair<std::string, std::string>(key, data)) ;
--i;
}
}
}
~arguments()
else
{
#ifdef DEBUG_ARGS
std::cout << next;
#endif
data.append(next);
}
}//end of if
#ifdef DEBUG_ARGS
std::cout << "]" << std::endl;
#endif
_map.insert(std::pair<std::string, std::string>(key, data)) ;
}//end of if test with "--"
}//end of for-loop
}
~arguments()
{
}
......@@ -110,43 +107,45 @@ class arguments
{
return false ;
}
}
//! \brief is the data at the given key in a vector format?
//! No matter the type of the data, this function will test is the
//! mapped string is of type "[ .... ]".
//! It returns false if there is no associated entry.
bool is_vec(const std::string& key) const
{
if(_map.count(key) > 0)
{
return _map.find(key)->second[0] == '[' ;
}
//! \brief is the data at the given key in a vector format?
//! No matter the type of the data, this function will test is the
//! mapped string is of type "[ .... ]".
//! It returns false if there is no associated entry.
bool is_vec(const std::string& key) const
else
{
if(_map.count(key) > 0)
{
return _map.find(key)->second[0] == '[' ;
}
else
{
return false ;
}
return false ;
}
}
//! \brief access the element stored value
std::string operator[](const std::string& key) const
{
if(_map.count(key) > 0)
{
return _map.find(key)->second ;
}
else
{
if(_map.count(key) > 0)
{
return _map.find(key)->second ;
}
else
{
//std::cerr << "Underfined request to key : \"" << key << "\"" << std::endl ;
return std::string() ;
}
}
//! \brief update the value \a val stored under key \a key
void update(const std::string& key, const std::string& val)
{
_map[key] = val;
}
//! \brief acces to the string value associated with the parameter
return std::string() ;
}
}
//! \brief update the value \a val stored under key \a key
void update(const std::string& key, const std::string& val)
{
_map[key] = val;
}
//! \brief acces to the string value associated with the parameter
//! \a key.
//!
//! The \a default_value argument will be returned if the \a key
......@@ -158,6 +157,7 @@ class arguments
else
return default_value ;
}
//! \brief acces to the float value associated with the parameter
//! \a key.
//!
......@@ -170,6 +170,7 @@ class arguments
else
return default_value ;
}
//! \brief acces to the integer value associated with the parameter
//! \a key.
//!
......@@ -182,7 +183,8 @@ class arguments
else
return default_value ;
}
//! \brief acces to a vector of float of size \a size associated with
//! \brief acces to a vector of float of size \a size associated with
//! the parameter \a key.
//!
//! The \a default_value argument will be returned if the \a key
......@@ -262,39 +264,38 @@ class arguments
return res;
}
std::vector<std::string> get_vec(const std::string& key) const
{
std::vector<std::string> res;
if(_map.count(key) > 0)
{
std::string s = _map.find(key)->second;
std::vector<std::string> get_vec(const std::string& key) const
{
std::vector<std::string> res;
if(_map.count(key) > 0)
{
std::string s = _map.find(key)->second;
if(s[0] == '[') // Is an array of type [a, b, c]
{
size_t pos = 1;
while(pos != std::string::npos)
{
size_t ppos = s.find(',', pos);
if(ppos != std::string::npos)
{
std::string temp = s.substr(pos, ppos-pos);
res.push_back(temp);
pos = ppos+1;
}
else
{
std::string temp = s.substr(pos, std::string::npos);
temp = temp.substr(0, temp.size()-1);
res.push_back(temp);
pos = ppos;
}
}
}
}
return res;
if(s[0] == '[') // Is an array of type [a, b, c]
{
size_t pos = 1;
while(pos != std::string::npos)
{
size_t ppos = s.find(',', pos);
if(ppos != std::string::npos)
{
std::string temp = s.substr(pos, ppos-pos);
res.push_back(temp);
pos = ppos+1;
}
else
{
std::string temp = s.substr(pos, std::string::npos);
temp = temp.substr(0, temp.size()-1);
res.push_back(temp);
pos = ppos;
}
}
}
}
return res;
}
//! \brief get the reconstructed command line arguments (without
//! the executable name
......
......@@ -214,10 +214,10 @@ function* plugins_manager::get_function(const std::string& filename)
function* f = get_function(args);
f->setDimX(nX);
f->setDimY(nY);
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
f->setParametrization(param_in);
}
if(f->input_parametrization() == params::UNKNOWN_INPUT)
{
f->setParametrization(param_in);
}
f->setParametrization(param_out);
// Load the function part from the file object
......@@ -227,7 +227,7 @@ function* plugins_manager::get_function(const std::string& filename)
}
//! Get an instance of the function selected based on the name <em>n</em>.
//! Return NULL if no one exist.
//! Return NULL if none exists.
function* plugins_manager::get_function(const arguments& args)
{
if(!args.is_defined("func"))
......@@ -268,7 +268,7 @@ function* plugins_manager::get_function(const arguments& args)
function* f = get_function(temp_args);
if(dynamic_cast<nonlinear_function*>(f) == NULL)
{
std::cerr << "<<ERROR>> only non-linear function care compatible with a compound" << std::endl;
std::cerr << "<<ERROR>> only non-linear function are compatible with a compound" << std::endl;
}
else
{
......@@ -335,12 +335,12 @@ function* plugins_manager::get_function(const arguments& args)
nonlinear_function* func_fres = dynamic_cast<nonlinear_function*>(get_function(arguments::create_arguments(n)));
if(func_fres != NULL)
{
return new product_function(nl_func, func_fres);
return new product_function(nl_func, func_fres);
}
else
{
std::cerr << "<<ERROR>> the right part of the product is not a nonlinear function. Will use only the left part." << std::endl;
return func;
std::cerr << "<<ERROR>> the right part of the product is not a nonlinear function. Will use only the left part." << std::endl;
return func;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment