Changeset 2406:0ffc78641b34 in lemon-0.x for lemon/arg_parser.cc
- Timestamp:
- 03/13/07 13:33:40 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3237
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/arg_parser.cc
r2402 r2406 29 29 ArgParser::ArgParser(int argc, char **argv) :_argc(argc), _argv(argv), 30 30 _command_name(argv[0]) { 31 refOption("-help","Print a short help message",_showHelp,this);31 funcOption("-help","Print a short help message",_showHelp,this); 32 32 synonym("help","-help"); 33 33 synonym("h","-help"); … … 122 122 ArgParser &ArgParser::refOption(const std::string &name, 123 123 const std::string &help, 124 int & value, bool obl)125 { 126 ParData p; 127 p.int_p=& value;124 int &ref, bool obl) 125 { 126 ParData p; 127 p.int_p=&ref; 128 128 p.self_delete=false; 129 129 p.help=help; … … 136 136 ArgParser &ArgParser::refOption(const std::string &name, 137 137 const std::string &help, 138 double & value, bool obl)139 { 140 ParData p; 141 p.double_p=& value;138 double &ref, bool obl) 139 { 140 ParData p; 141 p.double_p=&ref; 142 142 p.self_delete=false; 143 143 p.help=help; … … 150 150 ArgParser &ArgParser::refOption(const std::string &name, 151 151 const std::string &help, 152 bool & value, bool obl)153 { 154 ParData p; 155 p.bool_p=& value;152 bool &ref, bool obl) 153 { 154 ParData p; 155 p.bool_p=&ref; 156 156 p.self_delete=false; 157 157 p.help=help; … … 160 160 _opts[name]=p; 161 161 162 value= false;162 ref = false; 163 163 164 164 return *this; … … 167 167 ArgParser &ArgParser::refOption(const std::string &name, 168 168 const std::string &help, 169 std::string & value, bool obl)170 { 171 ParData p; 172 p.string_p=& value;169 std::string &ref, bool obl) 170 { 171 ParData p; 172 p.string_p=&ref; 173 173 p.self_delete=false; 174 174 p.help=help; … … 179 179 } 180 180 181 ArgParser &ArgParser:: refOption(const std::string &name,181 ArgParser &ArgParser::funcOption(const std::string &name, 182 182 const std::string &help, 183 183 void (*func)(void *),void *data) … … 198 198 { 199 199 Opts::iterator i = _opts.find(opt); 200 if(i==_opts.end()) exit(3); ///\todo throw exception instead201 else if(i->second.ingroup) exit(3); ///\todo throw exception instead200 if(i==_opts.end()) throw LogicError(); 201 else if(i->second.ingroup) throw LogicError(); 202 202 else { 203 203 GroupData &g=_groups[group]; … … 221 221 Opts::iterator s = _opts.find(syn); 222 222 if(o==_opts.end()||s!=_opts.end()) 223 exit(3); ///\todo throw exception instead223 throw LogicError(); 224 224 else { 225 225 ParData p;
Note: See TracChangeset
for help on using the changeset viewer.