67 string strip (
string s)
80 if (j == string::npos)
83 while (j > 0 && isspace (s[j-1]))
87 while (i < j && isspace (s[i]))
140 std::map<std::string,std::string>
_map;
222 if (file.size() == 0)
225 ifstream
f (file.c_str());
227 cerr <<
"Can't open " << file <<
"\n";
232 while (getline (
f, l)) {
252 for (
int i=1; i <
argc; i++) {
253 if (argv[i][0] ==
'-' && argv[i][1] ==
'-') {
257 if (strchr (argv[i],
'=') != 0)
260 else if (argv[i][2] ==
'n' && argv[i][3] ==
'o') {
293 if (_map.find(
name) == _map.end()) {
294 cerr <<
"can't find default for " <<
name <<
"\n";
297 std::map<string,string>::const_iterator it = _map.find(
name);
320 if (pos == string::npos) {
321 cerr <<
"bad defaults line " << l <<
"\n";
390 return (_rep->_map.find(
name) != _rep->_map.end());
406 return atoi (_rep->get_val (
name).c_str());
421 return atof (_rep->get_val (
name).c_str());
436 string val = _rep->get_val (
name);
437 if (tolower (val[0]) ==
't' || tolower (val[0]) ==
'y')
439 else if (tolower (val[0]) ==
'f' || tolower (val[0]) ==
'n')
441 return !!get_int (
name);
456 return _rep->get_val (
name);
473 for (std::map<std::string,std::string>::const_iterator it = def.
_rep->
_map.begin() ;
476 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