|
dune-common
2.3.1
|
Hierarchical structure of string parameters. More...
#include <dune/common/parametertree.hh>
Classes | |
| struct | Parser< array< T, n > > |
| struct | Parser< bool > |
| struct | Parser< FieldVector< T, n > > |
| struct | Parser< std::basic_string< char, traits, Allocator > > |
| struct | Parser< std::vector< T, A > > |
Public Types | |
| typedef std::vector< std::string > | KeyVector |
| storage for key lists More... | |
Public Member Functions | |
| ParameterTree () | |
| Create new empty ParameterTree. More... | |
| bool | hasKey (const std::string &key) const |
| test for key More... | |
| bool | hasSub (const std::string &sub) const |
| test for substructure More... | |
| std::string & | operator[] (const std::string &key) |
| get value reference for key More... | |
| const std::string & | operator[] (const std::string &key) const |
| get value reference for key More... | |
| void | report (std::ostream &stream=std::cout, const std::string &prefix="") const |
| print distinct substructure to stream More... | |
| ParameterTree & | sub (const std::string &sub) |
| get substructure by name More... | |
| const ParameterTree & | sub (const std::string &sub) const |
| get const substructure by name More... | |
| std::string | get (const std::string &key, const std::string &defaultValue) const |
| get value as string More... | |
| std::string | get (const std::string &key, const char *defaultValue) const |
| get value as string More... | |
| int | get (const std::string &key, int defaultValue) const |
| get value as int More... | |
| double | get (const std::string &key, double defaultValue) const |
| get value as double More... | |
| template<typename T > | |
| T | get (const std::string &key, const T &defaultValue) const |
| get value converted to a certain type More... | |
| template<class T > | |
| T | get (const std::string &key) const |
| Get value. More... | |
| const KeyVector & | getValueKeys () const |
| get value keys More... | |
| const KeyVector & | getSubKeys () const |
| get substructure keys More... | |
Static Protected Member Functions | |
| 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) |
Protected Attributes | |
| KeyVector | valueKeys |
| KeyVector | subKeys |
| std::map< std::string, std::string > | values |
| std::map< std::string, ParameterTree > | subs |
Hierarchical structure of string parameters.
| typedef std::vector<std::string> Dune::ParameterTree::KeyVector |
storage for key lists
| ParameterTree::ParameterTree | ( | ) |
Create new empty ParameterTree.
| std::string ParameterTree::get | ( | const std::string & | key, |
| const std::string & | defaultValue | ||
| ) | const |
get value as string
Returns pure string value for given key.
| key | key name |
| defaultValue | default if key does not exist |
References hasKey().
| std::string ParameterTree::get | ( | const std::string & | key, |
| const char * | defaultValue | ||
| ) | const |
| int ParameterTree::get | ( | const std::string & | key, |
| int | defaultValue | ||
| ) | const |
get value as int
Returns value for given key interpreted as int.
| key | key name |
| defaultValue | default if key does not exist |
| double ParameterTree::get | ( | const std::string & | key, |
| double | defaultValue | ||
| ) | const |
get value as double
Returns value for given key interpreted as double.
| key | key name |
| defaultValue | default if key does not exist |
References hasKey().
|
inline |
get value converted to a certain type
Returns value as type T for given key.
| T | type of returned value. |
| key | key name |
| defaultValue | default if key does not exist |
References hasKey().
|
inline |
Get value.
| T | Type of the value |
| key | Key name |
| RangeError | if key does not exist |
| NotImplemented | Type is not supported |
References DUNE_THROW, and hasKey().
| const ParameterTree::KeyVector & ParameterTree::getSubKeys | ( | ) | const |
get substructure keys
Returns a vector of all keys associated to (key,substructure) entries in order of appearance
References subKeys.
| const ParameterTree::KeyVector & ParameterTree::getValueKeys | ( | ) | const |
get value keys
Returns a vector of all keys associated to (key,values) entries in order of appearance
References valueKeys.
| bool ParameterTree::hasKey | ( | const std::string & | key | ) | const |
test for key
Tests whether given key exists.
| key | key name |
References Dune::dot(), hasKey(), sub(), subs, and values.
Referenced by get(), hasKey(), operator[](), and Dune::ParameterTreeParser::readINITree().
| bool ParameterTree::hasSub | ( | const std::string & | sub | ) | const |
test for substructure
Tests whether given substructure exists.
| sub | substructure name |
References Dune::dot(), hasSub(), sub(), and subs.
Referenced by hasSub(), and operator[]().
|
staticprotected |
| std::string & ParameterTree::operator[] | ( | const std::string & | key | ) |
| 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.
| key | key name |
| Dune::RangeError | if key is not found |
References Dune::dot(), DUNE_THROW, hasKey(), hasSub(), sub(), and values.
|
inlinestaticprotected |
References DUNE_THROW.
Referenced by Dune::ParameterTree::Parser< FieldVector< T, n > >::parse(), and Dune::ParameterTree::Parser< array< T, n > >::parse().
| void ParameterTree::report | ( | std::ostream & | stream = std::cout, |
| const std::string & | prefix = "" |
||
| ) | const |
|
staticprotected |
|
staticprotected |
Referenced by Dune::ParameterTree::Parser< std::vector< T, A > >::parse().
| ParameterTree & ParameterTree::sub | ( | const std::string & | sub | ) |
get substructure by name
| sub | substructure name |
References Dune::dot(), sub(), subKeys, and subs.
Referenced by hasKey(), hasSub(), operator[](), Dune::ParameterTree::Parser< std::vector< T, A > >::parse(), and sub().
| const ParameterTree & ParameterTree::sub | ( | const std::string & | sub | ) | const |
get const substructure by name
| sub | substructure name |
References Dune::dot(), DUNE_THROW, sub(), and subs.
|
protected |
Referenced by getSubKeys(), operator[](), and sub().
|
protected |
Referenced by hasKey(), hasSub(), operator[](), report(), and sub().
|
protected |
Referenced by getValueKeys(), and operator[]().
|
protected |
Referenced by hasKey(), operator[](), and report().
1.8.7