dune-common 2.9.1
|
Hierarchical structure of string parameters. More...
#include <dune/common/parametertree.hh>
Classes | |
struct | Parser< bool > |
struct | Parser< FieldVector< T, n > > |
struct | Parser< std::array< T, n > > |
struct | Parser< std::basic_string< char, traits, Allocator > > |
struct | Parser< std::bitset< n > > |
struct | Parser< std::vector< T, A > > |
Public Types | |
typedef std::vector< std::string > | KeyVector |
storage for key lists | |
Public Member Functions | |
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 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 | |
std::string | prefix_ |
KeyVector | valueKeys_ |
KeyVector | subKeys_ |
std::map< std::string, std::string > | values_ |
std::map< std::string, ParameterTree > | subs_ |
Static Protected Attributes | |
static const ParameterTree | empty_ |
Hierarchical structure of string parameters.
typedef std::vector<std::string> Dune::ParameterTree::KeyVector |
storage for key lists
ParameterTree::ParameterTree | ( | ) |
Create new empty ParameterTree.
Get value.
T | Type of the value |
key | Key name |
RangeError | if key does not exist |
NotImplemented | Type is not supported |
get value as string
Returns pure string value for given key.
key | key name |
defaultValue | default if key does not exist |
get value as string
Returns pure string value for given key.
key | key name |
defaultValue | default if key does not exist |
|
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 |
const ParameterTree::KeyVector & ParameterTree::getSubKeys | ( | ) | const |
get substructure keys
Returns a vector of all keys associated to (key,substructure) entries in order of appearance
const ParameterTree::KeyVector & ParameterTree::getValueKeys | ( | ) | const |
get value keys
Returns a vector of all keys associated to (key,values) entries in order of appearance
test for key
Tests whether given key exists.
key | key name |
test for substructure
Tests whether given substructure exists.
sub | substructure name |
|
staticprotected |
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.
key | key name |
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 |
|
inlinestaticprotected |
void ParameterTree::report | ( | std::ostream & | stream = std::cout, |
const std::string & | prefix = "" ) const |
print distinct substructure to stream
Prints all entries with given prefix.
stream | Stream to print to |
prefix | for key and substructure names |
|
staticprotected |
|
staticprotected |
ParameterTree & ParameterTree::sub | ( | const std::string & | sub | ) |
get substructure by name
sub | substructure name |
const ParameterTree & ParameterTree::sub | ( | const std::string & | sub, |
bool | fail_if_missing = false ) const |
get const substructure by name
sub | substructure name |
fail_if_missing | if true, throw an error if substructure is missing |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |