54 mutable map<string,int> __options;
55 vector<string> __arguments;
56 mutable map<string,bool> __options_used;
58 string __command_line;
63 CmdLine(
const int argc,
char** argv);
65 CmdLine(
const vector<string> & args);
68 bool present(
const string & opt)
const;
70 bool present_and_set(
const string & opt)
const;
74 inline const vector<string> & arguments()
const {
return __arguments;}
77 template<
class T> T value(
const string & opt)
const;
78 template<
class T> T value(
const string & opt,
const T & defval)
const;
82 int int_val(
const string & opt)
const;
84 int int_val(
const string & opt,
const int & defval)
const;
87 double double_val(
const string & opt)
const;
89 double double_val(
const string & opt,
const double & defval)
const;
92 string string_val(
const string & opt)
const;
94 string string_val(
const string & opt,
const string & defval)
const;
97 string command_line()
const;
100 bool all_options_used()
const;
107 void _report_conversion_failure(
const string & opt,
108 const string & optstring)
const;
116 template<
class T> T CmdLine::value(
const string & opt)
const {
118 string optstring = string_val(opt);
119 istringstream optstream(optstring);
121 if (optstream.fail()) _report_conversion_failure(opt, optstring);
126 template<>
inline string CmdLine::value<string>(
const string & opt)
const {
127 return string_val(opt);}
131 template<
class T> T CmdLine::value(
const string & opt,
const T & defval)
const {
132 if (this->present_and_set(opt)) {
return value<T>(opt);}
133 else {
return defval;}