Hierarchical structure of string parameters.
More...
#include <dune/common/parametertree.hh>
|
typedef std::vector< std::string > | KeyVector |
| storage for key lists
|
|
|
| ParameterTree () |
| Create new empty ParameterTree.
|
|
bool | hasKey (const std::string &key) const |
| test for key
|
|
bool | hasSub (const std::string &sub) const |
| test for substructure
|
|
std::string & | operator[] (const std::string &key) |
| get value reference for key
|
|
const std::string & | operator[] (const std::string &key) const |
| get value reference for key
|
|
void | report (std::ostream &stream=std::cout, const std::string &prefix="") const |
| print distinct substructure to stream
|
|
ParameterTree & | sub (const std::string &sub) |
| get substructure by name
|
|
const ParameterTree & | sub (const std::string &sub, bool fail_if_missing=false) const |
| get const substructure by name
|
|
std::string | get (const std::string &key, const std::string &defaultValue) const |
| get value as string
|
|
std::string | get (const std::string &key, const char *defaultValue) const |
| get value as string
|
|
template<typename T > |
T | get (const std::string &key, const T &defaultValue) const |
| get value converted to a certain type
|
|
template<class T > |
T | get (const std::string &key) const |
| Get value.
|
|
const KeyVector & | getValueKeys () const |
| get value keys
|
|
const KeyVector & | getSubKeys () const |
| get substructure keys
|
|
|
static std::string | ltrim (const std::string &s) |
|
static std::string | rtrim (const std::string &s) |
|
static std::vector< std::string > | split (const std::string &s) |
|
template<class Iterator > |
static void | parseRange (const std::string &str, Iterator it, const Iterator &end) |
|
Hierarchical structure of string parameters.
◆ KeyVector
◆ ParameterTree()
ParameterTree::ParameterTree |
( |
| ) |
|
◆ get() [1/4]
template<class T >
T Dune::ParameterTree::get |
( |
const std::string & |
key | ) |
const |
|
inline |
Get value.
- Template Parameters
-
- Parameters
-
- Exceptions
-
- Returns
- value as T
◆ get() [2/4]
std::string ParameterTree::get |
( |
const std::string & |
key, |
|
|
const char * |
defaultValue |
|
) |
| const |
get value as string
Returns pure string value for given key.
- Todo:
- This is a hack so get("my_key", "xyz") compiles (without this method "xyz" resolves to bool instead of std::string)
- Parameters
-
key | key name |
defaultValue | default if key does not exist |
- Returns
- value as string
◆ get() [3/4]
std::string ParameterTree::get |
( |
const std::string & |
key, |
|
|
const std::string & |
defaultValue |
|
) |
| const |
get value as string
Returns pure string value for given key.
- Parameters
-
key | key name |
defaultValue | default if key does not exist |
- Returns
- value as string
◆ get() [4/4]
template<typename T >
T Dune::ParameterTree::get |
( |
const std::string & |
key, |
|
|
const T & |
defaultValue |
|
) |
| const |
|
inline |
get value converted to a certain type
Returns value as type T for given key.
- Template Parameters
-
- Parameters
-
key | key name |
defaultValue | default if key does not exist |
- Returns
- value converted to T
◆ getSubKeys()
get substructure keys
Returns a vector of all keys associated to (key,substructure) entries in order of appearance
- Returns
- reference to entry vector
◆ getValueKeys()
get value keys
Returns a vector of all keys associated to (key,values) entries in order of appearance
- Returns
- reference to entry vector
◆ hasKey()
bool ParameterTree::hasKey |
( |
const std::string & |
key | ) |
const |
test for key
Tests whether given key exists.
- Parameters
-
- Returns
- true if key exists in structure, otherwise false
◆ hasSub()
bool ParameterTree::hasSub |
( |
const std::string & |
sub | ) |
const |
test for substructure
Tests whether given substructure exists.
- Parameters
-
- Returns
- true if substructure exists in structure, otherwise false
◆ ltrim()
std::string ParameterTree::ltrim |
( |
const std::string & |
s | ) |
|
|
staticprotected |
◆ operator[]() [1/2]
std::string & ParameterTree::operator[] |
( |
const std::string & |
key | ) |
|
get value reference for key
Returns reference to value for given key name. This creates the key, if not existent.
- Parameters
-
- Returns
- reference to corresponding value
◆ operator[]() [2/2]
const std::string & ParameterTree::operator[] |
( |
const std::string & |
key | ) |
const |
get value reference for key
Returns reference to value for given key name. This creates the key, if not existent.
- Parameters
-
- Returns
- reference to corresponding value
- Exceptions
-
◆ parseRange()
template<class Iterator >
static void Dune::ParameterTree::parseRange |
( |
const std::string & |
str, |
|
|
Iterator |
it, |
|
|
const Iterator & |
end |
|
) |
| |
|
inlinestaticprotected |
◆ report()
void ParameterTree::report |
( |
std::ostream & |
stream = std::cout , |
|
|
const std::string & |
prefix = "" |
|
) |
| const |
print distinct substructure to stream
Prints all entries with given prefix.
- Parameters
-
stream | Stream to print to |
prefix | for key and substructure names |
◆ rtrim()
std::string ParameterTree::rtrim |
( |
const std::string & |
s | ) |
|
|
staticprotected |
◆ split()
std::vector< std::string > ParameterTree::split |
( |
const std::string & |
s | ) |
|
|
staticprotected |
◆ sub() [1/2]
get substructure by name
- Parameters
-
- Returns
- reference to substructure
◆ sub() [2/2]
const ParameterTree & ParameterTree::sub |
( |
const std::string & |
sub, |
|
|
bool |
fail_if_missing = false |
|
) |
| const |
get const substructure by name
- Parameters
-
sub | substructure name |
fail_if_missing | if true, throw an error if substructure is missing |
- Returns
- reference to substructure
◆ empty_
◆ prefix_
std::string Dune::ParameterTree::prefix_ |
|
protected |
◆ subKeys_
◆ subs_
◆ valueKeys_
◆ values_
std::map<std::string, std::string> Dune::ParameterTree::values_ |
|
protected |
The documentation for this class was generated from the following files: