Changes in lemon/arg_parser.h [842:c2ff0a365245:440:88ed40ad0d4f] in lemon-main
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/arg_parser.h
r842 r440 34 34 35 35 namespace lemon { 36 37 ///Exception used by ArgParser38 class ArgParserException : public Exception {39 public:40 enum Reason {41 HELP, /// <tt>--help</tt> option was given42 UNKNOWN_OPT, /// Unknown option was given43 INVALID_OPT /// Invalid combination of options44 };45 46 private:47 Reason _reason;48 49 public:50 ///Constructor51 ArgParserException(Reason r) throw() : _reason(r) {}52 ///Virtual destructor53 virtual ~ArgParserException() throw() {}54 ///A short description of the exception55 virtual const char* what() const throw() {56 switch(_reason)57 {58 case HELP:59 return "lemon::ArgParseException: ask for help";60 break;61 case UNKNOWN_OPT:62 return "lemon::ArgParseException: unknown option";63 break;64 case INVALID_OPT:65 return "lemon::ArgParseException: invalid combination of options";66 break;67 }68 return "";69 }70 ///Return the reason for the failure71 Reason reason() const {return _reason; }72 };73 74 36 75 37 ///Command line arguments parser … … 142 104 std::string _command_name; 143 105 144 106 145 107 private: 146 108 //Bind a function to an option. … … 154 116 const std::string &help, 155 117 void (*func)(void *),void *data); 156 157 bool _exit_on_problems;158 159 void _terminate(ArgParserException::Reason reason) const;160 118 161 119 public: … … 423 381 const std::vector<std::string> &files() const { return _file_args; } 424 382 425 ///Throw instead of exit in case of problems426 void throwOnProblems()427 {428 _exit_on_problems=false;429 }430 383 }; 431 384 }
Note: See TracChangeset
for help on using the changeset viewer.