66 string strip (
string s)
79 if (j == string::npos)
82 while (j > 0 && isspace (s[j-1]))
86 while (i < j && isspace (s[i]))
139 std::map<std::string,std::string>
_map;
221 if (file.size() == 0)
224 ifstream
f (file.c_str());
226 cerr <<
"Can't open " << file <<
"\n";
231 while (getline (
f, l)) {
251 for (
int i=1; i <
argc; i++) {
252 if (argv[i][0] ==
'-' && argv[i][1] ==
'-') {
256 if (strchr (argv[i],
'=') != 0)
259 else if (argv[i][2] ==
'n' && argv[i][3] ==
'o') {
292 if (_map.find(
name) == _map.end()) {
293 cerr <<
"can't find default for " <<
name <<
"\n";
296 std::map<string,string>::const_iterator it = _map.find(
name);
319 if (pos == string::npos) {
320 cerr <<
"bad defaults line " << l <<
"\n";
389 return (_rep->_map.find(
name) != _rep->_map.end());
405 return atoi (_rep->get_val (
name).c_str());
420 return atof (_rep->get_val (
name).c_str());
435 string val = _rep->get_val (
name);
436 if (tolower (val[0]) ==
't' || tolower (val[0]) ==
'y')
438 else if (tolower (val[0]) ==
'f' || tolower (val[0]) ==
'n')
440 return !!get_int (
name);
455 return _rep->get_val (
name);
472 for (std::map<std::string,std::string>::const_iterator it = def.
_rep->
_map.begin() ;
475 s <<
"[" << it->first <<
"] = [" << it->second <<
"]\n";
Defaults_Textrep(string file)
Constructor, construct a Defaults_Textrep instance from an ASCII text-file and command line arguments...
A lightweight implementation of the Defaults interface that uses simple ASCII text files...
virtual bool exists(std::string name) const
The internal representation for a Defaults_Text object.
std::map< std::string, std::string > _map
~Defaults_Text()
Destructor.
string get_val(string name) const
Defaults_Text(std::string def_file)
Constructor, create a Default_Text object from an ASCII text file. Pass an empty string to skip readi...
virtual double get_float(std::string name) const
virtual std::string get_string(std::string name) const
Define a concrete interface for getting parameter settings from an ASCII text file.
virtual int get_int(std::string name) const
void process_args(int argc, char **argv)
std::ostream & operator<<(std::ostream &s, const Constraint_Intermed &ci)
Output stream operator, print the content of this Constraint_Intermed to an output stream...
void read_file(string file)
virtual bool get_bool(std::string name) const