Changes in lemon/arg_parser.h [959:38213abd2911:311:c887e703b566] in lemon
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/arg_parser.h
r959 r311 3 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 * Copyright (C) 2003-20 105 * Copyright (C) 2003-2008 6 6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport 7 7 * (Egervary Research Group on Combinatorial Optimization, EGRES). … … 34 34 35 35 namespace lemon { 36 37 ///Exception used by ArgParser38 39 ///Exception used by ArgParser.40 ///41 class ArgParserException : public Exception {42 public:43 /// Reasons for failure44 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 ///Constructor58 ArgParserException(Reason r) throw() : _reason(r) {}59 ///Virtual destructor60 virtual ~ArgParserException() throw() {}61 ///A short description of the exception62 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 failure78 Reason reason() const {return _reason; }79 };80 81 36 82 37 ///Command line arguments parser … … 162 117 void (*func)(void *),void *data); 163 118 164 bool _exit_on_problems;165 166 void _terminate(ArgParserException::Reason reason) const;167 168 119 public: 169 120 … … 430 381 const std::vector<std::string> &files() const { return _file_args; } 431 382 432 ///Throw instead of exit in case of problems433 void throwOnProblems()434 {435 _exit_on_problems=false;436 }437 383 }; 438 384 }
Note: See TracChangeset
for help on using the changeset viewer.