Changeset 214:60eecd3fe37a in lemon for lemon/arg_parser.h
- Timestamp:
- 07/13/08 23:05:25 (17 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/arg_parser.h
r209 r214 272 272 ///@} 273 273 274 void show(std::ostream &os,Opts::iterator i); 275 void show(std::ostream &os,Groups::iterator i); 276 void showHelp(Opts::iterator i); 277 void showHelp(std::vector<OtherArg>::iterator i); 278 void shortHelp(); 279 void showHelp(); 280 281 void unknownOpt(std::string arg); 282 283 void requiresValue(std::string arg, OptType t); 284 void checkMandatories(); 274 private: 275 void show(std::ostream &os,Opts::const_iterator i) const; 276 void show(std::ostream &os,Groups::const_iterator i) const; 277 void showHelp(Opts::const_iterator i) const; 278 void showHelp(std::vector<OtherArg>::const_iterator i) const; 279 280 void unknownOpt(std::string arg) const; 281 282 void requiresValue(std::string arg, OptType t) const; 283 void checkMandatories() const; 284 285 void shortHelp() const; 286 void showHelp() const; 287 public: 285 288 286 289 ///Start the parsing process … … 294 297 295 298 ///Give back the command name (the 0th argument) 296 const std::string &commandName() { return _command_name; }299 const std::string &commandName() const { return _command_name; } 297 300 298 301 ///Check if an opion has been given to the command. 299 bool given(std::string op) 300 { 301 Opts:: iterator i = _opts.find(op);302 bool given(std::string op) const 303 { 304 Opts::const_iterator i = _opts.find(op); 302 305 return i!=_opts.end()?i->second.set:false; 303 306 } … … 312 315 class RefType 313 316 { 314 ArgParser &_parser;317 const ArgParser &_parser; 315 318 std::string _name; 316 319 public: 317 320 ///\e 318 RefType( ArgParser &p,const std::string &n) :_parser(p),_name(n) {}321 RefType(const ArgParser &p,const std::string &n) :_parser(p),_name(n) {} 319 322 ///\e 320 323 operator bool() 321 324 { 322 Opts:: iterator i = _parser._opts.find(_name);325 Opts::const_iterator i = _parser._opts.find(_name); 323 326 LEMON_ASSERT(i!=_parser._opts.end(), 324 327 std::string()+"Unkown option: '"+_name+"'"); … … 330 333 operator std::string() 331 334 { 332 Opts:: iterator i = _parser._opts.find(_name);335 Opts::const_iterator i = _parser._opts.find(_name); 333 336 LEMON_ASSERT(i!=_parser._opts.end(), 334 337 std::string()+"Unkown option: '"+_name+"'"); … … 340 343 operator double() 341 344 { 342 Opts:: iterator i = _parser._opts.find(_name);345 Opts::const_iterator i = _parser._opts.find(_name); 343 346 LEMON_ASSERT(i!=_parser._opts.end(), 344 347 std::string()+"Unkown option: '"+_name+"'"); … … 352 355 operator int() 353 356 { 354 Opts:: iterator i = _parser._opts.find(_name);357 Opts::const_iterator i = _parser._opts.find(_name); 355 358 LEMON_ASSERT(i!=_parser._opts.end(), 356 359 std::string()+"Unkown option: '"+_name+"'"); … … 366 369 ///Give back the value of an option. 367 370 ///\sa RefType 368 RefType operator[](const std::string &n) 371 RefType operator[](const std::string &n) const 369 372 { 370 373 return RefType(*this, n); … … 375 378 ///Give back a reference to a vector consisting of the program arguments 376 379 ///not starting with a '-' character. 377 std::vector<std::string> &files(){ return _file_args; }380 const std::vector<std::string> &files() const { return _file_args; } 378 381 379 382 };
Note: See TracChangeset
for help on using the changeset viewer.