Manage a map of options.Each option is defined by a string and is associated to an integer value.
More...
#include <misc/optionmap.hh>
Public Member Functions |
const char * | parse_options (const char *options) |
| Add the parsed options to the map.
|
int | get (const char *option, int def=0) const |
| Get the value of option.
|
int | operator[] (const char *option) const |
| Get the value of option.
|
int | set (const char *option, int val, int def=0) |
| Set the value of option to val.
|
void | set (const option_map &o) |
| Acquire all the settings of o.
|
int & | operator[] (const char *option) |
| Get a reference to the current value of option.
|
Private Attributes |
std::map< std::string, int > | options_ |
Detailed Description
Manage a map of options.
Each option is defined by a string and is associated to an integer value.
Member Function Documentation
int spot::option_map::get |
( |
const char * |
option, |
|
|
int |
def = 0 |
|
) |
| const |
Get the value of option.
- Returns
- The value associated to option if it exists, def otherwise.
- See Also
- operator[]()
int spot::option_map::operator[] |
( |
const char * |
option | ) |
const |
Get the value of option.
- Returns
- The value associated to option if it exists, 0 otherwise.
- See Also
- get()
int& spot::option_map::operator[] |
( |
const char * |
option | ) |
|
Get a reference to the current value of option.
const char* spot::option_map::parse_options |
( |
const char * |
options | ) |
|
Add the parsed options to the map.
\a options are separated by a space, comma, semicolon or tabulation and
can be optionnaly followed by an integer value (preceded by an equal
sign). If not specified, the default value is 1.
The following three lines are equivalent.
@verbatim
/// optA !optB optC=4194304 /// optA=1, optB=0, optC=4096K /// optC = 4M; optA !optB ///
\return A non-null pointer to the option for which an expected integer
value cannot be parsed.
int spot::option_map::set |
( |
const char * |
option, |
|
|
int |
val, |
|
|
int |
def = 0 |
|
) |
| |
Set the value of option to val.
- Returns
- The previous value associated to option if declared, or def otherwise.
void spot::option_map::set |
( |
const option_map & |
o | ) |
|
Acquire all the settings of o.
Friends And Related Function Documentation
std::ostream& operator<< |
( |
std::ostream & |
os, |
|
|
const option_map & |
m |
|
) |
| |
|
friend |
Member Data Documentation
std::map<std::string, int> spot::option_map::options_ |
|
private |
The documentation for this class was generated from the following file: