The base class for all options.  
 More...
Inherited by util::BoolOption, util::DoubleArrayOption, util::DoubleOption, util::FloatArrayOption, util::FloatOption, util::IntArrayOption, util::IntOption, util::RegionArrayOption, util::StringArrayOption, and util::StringOption.
|  | 
| virtual void | setValue (const string &s)=0  throw (UException) | 
|  | This function is the heart of the Optionclass: it parses the value of the option from the suppliedstring.  More...
 | 
|  | 
| virtual string | getTypeName () const | 
|  | Return the type name of the option as a string.  More... 
 | 
|  | 
| virtual bool | needsValue () const | 
|  | 
| const string & | getName () const | 
|  | Return the (long) option name.  More... 
 | 
|  | 
| char | getCmdLineChar () const | 
|  | Return the short option char.  More... 
 | 
|  | 
| const string & | getDefault () const | 
|  | Return the string representation of the default value.  More... 
 | 
|  | 
| const string & | getUsage () const | 
|  | Return the help string.  More... 
 | 
|  | 
| virtual string | toString () const =0 | 
|  | Return the option's value as a string.  More... 
 | 
|  | 
|  | 
|  | Option (const char *name, const char *defaultVal, const char *usage, const char cmd) | 
|  | 
|  | Option (const string &name, const string &defaultVal, const string &usage, const char cmd) | 
|  | 
| virtual | ~Option ()  throw () | 
|  | 
|  | 
| virtual int | getInt () const | 
|  | 
| virtual float | getFloat () const | 
|  | 
| virtual string | getString () const | 
|  | 
| virtual bool | getBool () const | 
|  | 
|  | 
| (Note that these are not member functions.)  | 
| ostream & | operator<< (ostream &os, Option &op) | 
|  | 
The base class for all options. 
All data is stored as strings. Conversion (parsing) to the actual type happens in derived specializations.
Constructing an option requires 4 (+1) parameters: 
- the option's name 
- the default value as a string 
- the help string to print for this option 
- the character representing the option in the command line '-x' if this char is 0, the option will be a long option with it's name used as the option string for the command line '–name' 
- The constructors of the heirs have a further parameter which is a pointer to the option's type. The option will also write its value to that location if the pointer is not NULL. Useful for easily setting global parameters, or filling a struct with parameter values without having to manually loop over and read all program option's values.
      
        
          | util::Option::Option | ( | const char * | name, | 
        
          |  |  | const char * | defaultVal, | 
        
          |  |  | const char * | usage, | 
        
          |  |  | const char | cmd | 
        
          |  | ) |  |  | 
      
 
ctors and dtor The parameters are 
- nameThe long option name, to be used with –option-name (command line), or option-name = (config file).
- defaultValstring representation of default value
- usageoption description and help text
- theshort option character, for use with -c on the command line. Supply- '\0'if no short option name is needed.
 
 
      
        
          | util::Option::Option | ( | const string & | name, | 
        
          |  |  | const string & | defaultVal, | 
        
          |  |  | const string & | usage, | 
        
          |  |  | const char | cmd | 
        
          |  | ) |  |  | 
      
 
 
  
  | 
        
          | virtual util::Option::~Option | ( |  | ) |  |  
          | throw | ( |  |  
          |  | ) |  |  |  | virtual | 
 
 
  
  | 
        
          | virtual void util::Option::setValue | ( | const string & | s | ) |  |  
          | throw | ( | UException |  
          |  | ) |  |  |  | pure virtual | 
 
 
  
  | 
        
          | virtual int util::Option::getInt | ( |  | ) | const |  | inlinevirtual | 
 
Acess the value of the option. Usually subclasses will not implement all of these, in fact, mostly just one of these. 
Reimplemented in util::IntOption.
 
 
  
  | 
        
          | virtual float util::Option::getFloat | ( |  | ) | const |  | inlinevirtual | 
 
 
  
  | 
        
          | virtual string util::Option::getString | ( |  | ) | const |  | inlinevirtual | 
 
 
  
  | 
        
          | virtual bool util::Option::getBool | ( |  | ) | const |  | inlinevirtual | 
 
 
  
  | 
        
          | virtual string util::Option::getTypeName | ( |  | ) | const |  | inlinevirtual | 
 
 
  
  | 
        
          | virtual bool util::Option::needsValue | ( |  | ) | const |  | inlinevirtual | 
 
Return true if the option needs a value, false if it is a toggle-switch needing no value. On the command line, values are given as –long-option value, or -x value. In a config file, long-option = value. '#' can be used to delineate comments. See CommandLineReader and ConfigFileReader. 
Reimplemented in util::BoolOption.
 
 
      
        
          | const string& util::Option::getName | ( |  | ) | const | 
      
 
Return the (long) option name. 
 
 
      
        
          | char util::Option::getCmdLineChar | ( |  | ) | const | 
      
 
Return the short option char. 
 
 
      
        
          | const string& util::Option::getDefault | ( |  | ) | const | 
      
 
Return the string representation of the default value. 
 
 
      
        
          | const string& util::Option::getUsage | ( |  | ) | const | 
      
 
 
  
  | 
        
          | virtual string util::Option::toString | ( |  | ) | const |  | pure virtual | 
 
 
  
  | 
        
          | string util::Option::name_ |  | protected | 
 
long option name (e.g. –long-option or long-option=value) 
 
 
  
  | 
        
          | string util::Option::default_ |  | protected | 
 
string representation of default value 
 
 
  
  | 
        
          | string util::Option::usage_ |  | protected | 
 
 
  
  | 
        
          | char util::Option::cmdlinechar_ |  | protected | 
 
short option char, for command line use