COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/arg_parser.h

    r842 r440  
    3434
    3535namespace lemon {
    36 
    37   ///Exception used by ArgParser
    38   class ArgParserException : public Exception {
    39   public:
    40     enum Reason {
    41       HELP,         /// <tt>--help</tt> option was given
    42       UNKNOWN_OPT,  /// Unknown option was given
    43       INVALID_OPT   /// Invalid combination of options
    44     };
    45    
    46   private:
    47     Reason _reason;
    48    
    49   public:
    50     ///Constructor
    51     ArgParserException(Reason r) throw() : _reason(r) {}
    52     ///Virtual destructor
    53     virtual ~ArgParserException() throw() {}
    54     ///A short description of the exception
    55     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 failure
    71     Reason reason() const {return _reason; }
    72   };
    73 
    7436
    7537  ///Command line arguments parser
     
    142104    std::string _command_name;
    143105
    144    
     106
    145107  private:
    146108    //Bind a function to an option.
     
    154116                    const std::string &help,
    155117                    void (*func)(void *),void *data);
    156 
    157     bool _exit_on_problems;
    158    
    159     void _terminate(ArgParserException::Reason reason) const;
    160118
    161119  public:
     
    423381    const std::vector<std::string> &files() const { return _file_args; }
    424382
    425     ///Throw instead of exit in case of problems
    426     void throwOnProblems()
    427     {
    428       _exit_on_problems=false;
    429     }
    430383  };
    431384}
Note: See TracChangeset for help on using the changeset viewer.