Dune Core Modules (2.10.0)
Hierarchical structure of string parameters. More...
#include <dune/common/parametertree.hh>
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 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, bool fail_if_missing=false) 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... | |
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... | |
Detailed Description
Hierarchical structure of string parameters.
Member Function Documentation
◆ get() [1/4]
|
inline |
Get value.
- Template Parameters
-
T Type of the value
- Parameters
-
key Key name
- Exceptions
-
RangeError if key does not exist NotImplemented Type is not supported
- Returns
- value as T
References DUNE_THROW, hasKey(), and Dune::Exception::what().
◆ get() [2/4]
std::string ParameterTree::get | ( | const std::string & | key, |
const char * | defaultValue | ||
) | const |
◆ 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
References hasKey().
Referenced by Dune::SolverFactory< Operator >::get().
◆ get() [4/4]
|
inline |
get value converted to a certain type
Returns value as type T for given key.
- Template Parameters
-
T type of returned value.
- Parameters
-
key key name defaultValue default if key does not exist
- Returns
- value converted to T
References hasKey().
◆ getSubKeys()
const ParameterTree::KeyVector & ParameterTree::getSubKeys | ( | ) | const |
get substructure keys
Returns a vector of all keys associated to (key,substructure) entries in order of appearance
- Returns
- reference to entry vector
◆ getValueKeys()
const ParameterTree::KeyVector & ParameterTree::getValueKeys | ( | ) | const |
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
-
key key name
- Returns
- true if key exists in structure, otherwise false
References Dune::dot(), DUNE_THROW, hasKey(), and sub().
Referenced by get(), hasKey(), operator[](), and Dune::ParameterTreeParser::readINITree().
◆ hasSub()
bool ParameterTree::hasSub | ( | const std::string & | sub | ) | const |
test for substructure
Tests whether given substructure exists.
- Parameters
-
sub substructure name
- Returns
- true if substructure exists in structure, otherwise false
References Dune::dot(), DUNE_THROW, hasSub(), and sub().
Referenced by hasSub().
◆ 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
-
key key name
- Returns
- reference to corresponding value
References Dune::dot(), hasKey(), and sub().
◆ 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
-
key key name
- Returns
- reference to corresponding value
- Exceptions
-
Dune::RangeError if key is not found
References Dune::dot(), DUNE_THROW, hasKey(), and sub().
◆ report()
void ParameterTree::report | ( | std::ostream & | stream = std::cout , |
const std::string & | prefix = "" |
||
) | const |
◆ sub() [1/2]
ParameterTree & ParameterTree::sub | ( | const std::string & | sub | ) |
get substructure by name
- Parameters
-
sub substructure name
- Returns
- reference to substructure
References Dune::dot(), DUNE_THROW, and sub().
Referenced by hasKey(), hasSub(), operator[](), and sub().
◆ 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
References Dune::dot(), DUNE_THROW, and sub().
The documentation for this class was generated from the following files:
- dune/common/parametertree.hh
- dune/common/parametertree.cc