spot  2.11.6
Public Member Functions | Friends | List of all members
spot::option_map Class Reference

Manage a map of options. More...

#include <spot/misc/optionmap.hh>

Collaboration diagram for spot::option_map:

Public Member Functions

const char * parse_options (const char *options)
 Add the parsed options to the map. More...
 
int get (const char *option, int def=0) const
 Get the value of option. More...
 
std::string get_str (const char *option, std::string def={}) const
 Get the value of option. More...
 
int operator[] (const char *option) const
 Get the value of option. More...
 
int set (const char *option, int val, int def=0)
 Set the value of option to val. More...
 
void set_if_unset (const char *option, int val)
 Set the value of option to val if it is unset. More...
 
std::string set_str (const char *option, std::string val, std::string def={})
 Set the value of a string option to val. More...
 
void report_unused_options () const
 Raise a runtime_error if some options have not been used. More...
 
void set (const option_map &o)
 Acquire all the settings of o. More...
 
int & operator[] (const char *option)
 Get a reference to the current value of option. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const option_map &m)
 Print the option_map m. More...
 

Detailed Description

Manage a map of options.

Each option is defined by a string and is associated to an integer value.

Member Function Documentation

◆ get()

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[]()

◆ get_str()

std::string spot::option_map::get_str ( const char *  option,
std::string  def = {} 
) const

Get the value of option.

Returns
The value associated to option if it exists, def otherwise.
See also
operator[]()

◆ operator[]() [1/2]

int& spot::option_map::operator[] ( const char *  option)

Get a reference to the current value of option.

◆ operator[]() [2/2]

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()

◆ parse_options()

const char* spot::option_map::parse_options ( const char *  options)

Add the parsed options to the map.

options are separated by a space, comma, semicolon or tabulation and can be optionally followed by an integer value (preceded by an equal sign). If not specified, the default value is 1.

The following three lines are equivalent.

optA !optB optC=4194304
optA=1, optB=0, optC=4096K
optC = 4M; optA !optB
Returns
A non-null pointer to the option for which an expected integer value cannot be parsed.

◆ report_unused_options()

void spot::option_map::report_unused_options ( ) const

Raise a runtime_error if some options have not been used.

◆ set() [1/2]

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.

◆ set() [2/2]

void spot::option_map::set ( const option_map o)

Acquire all the settings of o.

◆ set_if_unset()

void spot::option_map::set_if_unset ( const char *  option,
int  val 
)

Set the value of option to val if it is unset.

◆ set_str()

std::string spot::option_map::set_str ( const char *  option,
std::string  val,
std::string  def = {} 
)

Set the value of a string option to val.

Returns
The previous value associated to option if declared, or def otherwise.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const option_map m 
)
friend

Print the option_map m.


The documentation for this class was generated from the following file:

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.1