Changes in lemon/arg_parser.h [311:c887e703b566:880:38213abd2911] in lemon-1.2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/arg_parser.h
r311 r880 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 085 * Copyright (C) 2003-2010 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 35 35 namespace lemon { 36 36 37 ///Exception used by ArgParser 38 39 ///Exception used by ArgParser. 40 /// 41 class ArgParserException : public Exception { 42 public: 43 /// Reasons for failure 44 45 /// Reasons for failure. 46 /// 47 enum Reason { 48 HELP, ///< <tt>--help</tt> option was given. 49 UNKNOWN_OPT, ///< Unknown option was given. 50 INVALID_OPT ///< Invalid combination of options. 51 }; 52 53 private: 54 Reason _reason; 55 56 public: 57 ///Constructor 58 ArgParserException(Reason r) throw() : _reason(r) {} 59 ///Virtual destructor 60 virtual ~ArgParserException() throw() {} 61 ///A short description of the exception 62 virtual const char* what() const throw() { 63 switch(_reason) 64 { 65 case HELP: 66 return "lemon::ArgParseException: ask for help"; 67 break; 68 case UNKNOWN_OPT: 69 return "lemon::ArgParseException: unknown option"; 70 break; 71 case INVALID_OPT: 72 return "lemon::ArgParseException: invalid combination of options"; 73 break; 74 } 75 return ""; 76 } 77 ///Return the reason for the failure 78 Reason reason() const {return _reason; } 79 }; 80 81 37 82 ///Command line arguments parser 38 83 … … 116 161 const std::string &help, 117 162 void (*func)(void *),void *data); 163 164 bool _exit_on_problems; 165 166 void _terminate(ArgParserException::Reason reason) const; 118 167 119 168 public: … … 381 430 const std::vector<std::string> &files() const { return _file_args; } 382 431 432 ///Throw instead of exit in case of problems 433 void throwOnProblems() 434 { 435 _exit_on_problems=false; 436 } 383 437 }; 384 438 }
Note: See TracChangeset
for help on using the changeset viewer.