configuration class
More...
#include <configuration.hpp>
|
std::ostream & | print (std::ostream &o) const |
| print options More...
|
|
|
popts::variables_map | _vmap |
| stores the program options
|
|
popts::options_description | _visible_opts |
| options visible in the help
|
|
popts::options_description | _hidden_opts |
| options hidden in the help output
|
|
popts::positional_options_description | _oargs |
| positional arguments description
|
|
This class holds the configuration of a program or library that has been extracted from various sources.
template<typename T >
void pni::core::configuration::add_argument |
( |
const config_argument< T > & |
arg | ) |
|
|
inline |
Adds an argument to the configuration.
- Parameters
-
void pni::core::configuration::add_option |
( |
const config_option< bool > & |
opt, |
|
|
bool |
visible = true |
|
) |
| |
Overloaded version of the add_option template member for bool variables.
- Parameters
-
opt | boolean configuration option |
visible | visibility flag |
const popts::positional_options_description& pni::core::configuration::arguments |
( |
| ) |
const |
|
inline |
Return reference to the arguments of the configuration.
- Returns
- return positional options description
template<typename T >
string pni::core::configuration::default_value_string |
( |
const T & |
v | ) |
|
|
inlineprivate |
Converts the default value provided by an option to its string representation.
- Template Parameters
-
T | data type of the default value |
- Parameters
-
- Returns
- string representation of v
template<typename T >
string pni::core::configuration::default_value_string |
( |
const std::vector< T > & |
v | ) |
|
|
inlineprivate |
Overloaded version if the option allows multiple values via a std::pointer. In this case the first element is used as a default value. An exception is thrown wenn the default container is an empty container.
- Exceptions
-
- Template Parameters
-
T | element type of the vector |
- Parameters
-
- Returns
- string representation of the first element
bool pni::core::configuration::has_option |
( |
const string & |
name | ) |
const |
Return true if a particular option has been passed by the user. If the option is present true is returned otherwise false.
- Parameters
-
name | long name of the option |
- Returns
- true if option exists
const popts::options_description& pni::core::configuration::hidden_options |
( |
| ) |
const |
|
inline |
- Returns
- return hidden options description
const popts::variables_map& pni::core::configuration::map |
( |
| ) |
const |
|
inline |
Return a const reference to the configuration variables map stored in the configuration class.
- Returns
- reference to the variables map
std::ostream& pni::core::configuration::print |
( |
std::ostream & |
o | ) |
const |
|
protected |
Append options string representation to an output stream. Only the visible options are appended to the output stream.
- Parameters
-
o | reference to the output stream |
- Returns
- reference to output stream
template<typename T >
T pni::core::configuration::value |
( |
const string & |
name | ) |
const |
|
inline |
Template method returning the value of an option as instance of type T. If the option was created with a default value this value will be returned. If the option was created without default value an exception will be thrown.
- Template Parameters
-
T | return type of the method |
- Exceptions
-
- Parameters
-
name | long name of the option |
- Returns
- value of the option as instance of type T
const popts::options_description& pni::core::configuration::visible_options |
( |
| ) |
const |
|
inline |
- Returns
- return the visible options
The documentation for this class was generated from the following file: