Hold an integer number. More...
Inherits util::Option.
Option
class: it parses the value of the option from the supplied string
. (Note that these are not member functions.)
Hold an integer number.
These are the specializations for various types and arrays of types. Each of these implements overloads the parser function:
void setValue( const string& s );
and the accessor function(s) returning the appropriate type.
The constructors have a further parameter which is a pointer to the option's (native) 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::IntOption::IntOption | ( | const char * | name, | |
const char * | defaultVal, | |||
const char * | usage, | |||
const char | cmd, | |||
int *const | storage = NULL | |||
) |
util::IntOption::IntOption | ( | const string & | name, | |
const string & | defaultVal, | |||
const string & | usage, | |||
const char | cmd, | |||
int *const | storage = NULL | |||
) |
util::IntOption::~IntOption | ( | ) | throw () [inline] |
virtual string util::IntOption::getTypeName | ( | ) | const [inline, virtual] |
Return the type name of the option as a string.
Reimplemented from util::Option.
void util::IntOption::setValue | ( | const string & | s | ) | throw (UException) [virtual] |
This function is the heart of the Option
class: it parses the value of the option from the supplied string
.
Implements util::Option.
virtual int util::IntOption::getInt | ( | ) | const [virtual] |
Acess the value of the option. Usually subclasses will not implement all of these, in fact, mostly just one of these.
Reimplemented from util::Option.
virtual string util::IntOption::toString | ( | ) | const [virtual] |
Return the option's value as a string.
Implements util::Option.
virtual float util::Option::getFloat | ( | ) | const [inline, virtual, inherited] |
Reimplemented in util::FloatOption.
virtual string util::Option::getString | ( | ) | const [inline, virtual, inherited] |
Reimplemented in util::StringOption.
virtual bool util::Option::getBool | ( | ) | const [inline, virtual, inherited] |
Reimplemented in util::BoolOption.
virtual bool util::Option::needsValue | ( | ) | const [inline, virtual, inherited] |
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 [inherited] |
Return the (long) option name.
char util::Option::getCmdLineChar | ( | ) | const [inherited] |
Return the short option char.
const string& util::Option::getDefault | ( | ) | const [inherited] |
Return the string representation of the default value.
const string& util::Option::getUsage | ( | ) | const [inherited] |
Return the help string.
int util::IntOption::value_ [protected] |
int* util::IntOption::storage_ [protected] |
string util::Option::name_ [protected, inherited] |
long option name (e.g. --long-option or long-option=value)
string util::Option::default_ [protected, inherited] |
string representation of default value
string util::Option::usage_ [protected, inherited] |
help string
char util::Option::cmdlinechar_ [protected, inherited] |
short option char, for command line use