79 if (j == string::npos)
82 while (j > 0 && isspace(s[j - 1]))
86 while (i < j && isspace(s[i]))
89 return string(s, i, j - i);
135 std::map<std::string, std::string>
_map;
216 ifstream
f(file.c_str());
218 cerr <<
"Can't open " << file <<
"\n";
223 while (getline(
f, l)) {
242 for (
int i = 1; i <
argc; i++) {
243 if (argv[i][0] ==
'-' && argv[i][1] ==
'-') {
246 if (strchr(argv[i],
'=') !=
nullptr)
249 else if (argv[i][2] ==
'n' && argv[i][3] ==
'o') {
279 if (_map.find(
name) == _map.end()) {
280 cerr <<
"can't find default for " <<
name <<
"\n";
283 std::map<string, string>::const_iterator it = _map.find(
name);
305 if (pos == string::npos) {
306 cerr <<
"bad defaults line " << l <<
"\n";
366 return (_rep->_map.find(
name) != _rep->_map.end());
380 return atoi(_rep->get_val(
name).c_str());
394 return atof(_rep->get_val(
name).c_str());
408 string val = _rep->get_val(
name);
409 if (tolower(val[0]) ==
't' || tolower(val[0]) ==
'y')
411 else if (tolower(val[0]) ==
'f' || tolower(val[0]) ==
'n')
413 return !!get_int(
name);
427 return _rep->get_val(
name);
442 for (std::map<std::string, std::string>::const_iterator it = def.
_rep->
_map.begin(); it != def.
_rep->
_map.end();
444 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...
int def(FILE *, FILE *, int)
bool exists(std::string name) const override
std::string get_string(std::string name) const override
A lightweight implementation of the Defaults interface that uses simple ASCII text files...
The internal representation for a Defaults_Text object.
int get_int(std::string name) const override
string get_val(string name) const
double get_float(std::string name) const override
Defaults_Text(std::string def_file)
Constructor, create a Default_Text object from an ASCII text file. Pass an empty string to skip readi...
std::map< std::string, std::string > _map
bool get_bool(std::string name) const override
~Defaults_Text() override
Destructor.
Define a concrete interface for getting parameter settings from an ASCII text file.
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)