Hierarchical collection of key/value pairs.
More...
#include <PropertyTree.hpp>
Hierarchical collection of key/value pairs.
◆ PropertyTree() [1/4]
Opm::PropertyTree::PropertyTree |
( |
| ) |
|
Default constructor.
Should typically be populated in put() before use.
◆ PropertyTree() [2/4]
Opm::PropertyTree::PropertyTree |
( |
const std::string & |
jsonFile | ) |
|
|
explicit |
Constructor.
Loads a property tree from an external source expected to be a text file in JSON.
- Parameters
-
[in] | jsonFile | Name of file containing external property tree, linearised into JSON format. |
◆ PropertyTree() [3/4]
Copy constructor.
- Parameters
-
◆ PropertyTree() [4/4]
Converting constructor.
Forms a property tree object from a Boost ptree.
- Parameters
-
[in] | tree | Source object represented as a Boost ptree. |
◆ get() [1/2]
Retrieve property value given hierarchical property key.
- Template Parameters
-
- Parameters
-
[in] | key | Property key. Expected to be in hierarchical notation for subtrees–i.e., using periods ('.') to separate hierarchy levels. |
- Returns
- Copy of internal property value for
key
.
◆ get() [2/2]
T Opm::PropertyTree::get |
( |
const std::string & |
key, |
|
|
const T & |
defValue |
|
) |
| const |
Retrieve property value given hierarchical property key.
- Template Parameters
-
- Parameters
-
[in] | key | Property key. Expected to be in hierarchical notation for subtrees–i.e., using periods ('.') to separate hierarchy levels. |
[in] | defValue | Default value for when key is not in the property tree. |
- Returns
- Copy of internal property value for
key
, or a copy of defValue
if the key
is not in the property tree.
◆ get_child()
Retrieve copy of sub tree rooted at node.
Throws an exception if no sub tree exists at given root.
- Parameters
-
[in] | Property | key. Expected to be in hierarchical notation for subtrees–i.e., using periods ('.') to separate hierarchy levels. |
- Returns
- Copy of property sub tree rooted at
key
.
◆ get_child_items_as_vector()
template std::optional< std::vector< double > > Opm::PropertyTree::get_child_items_as_vector |
( |
const std::string & |
child | ) |
const |
Retrieve node items as linearised vector.
Assumes that the node's child is an array type of homongeneous elements.
- Template Parameters
-
- Parameters
-
[in] | child | Property key. Expected to be in hierarchical notation for subtrees–i.e., using periods ('.') to separate hierarchy levels. |
- Returns
- Array of property values. Nullopt if no node named by
child
exists.
◆ get_child_optional()
std::optional< PropertyTree > Opm::PropertyTree::get_child_optional |
( |
const std::string & |
key | ) |
const |
Retrieve copy of sub tree rooted at node.
- Parameters
-
[in] | Property | key. Expected to be in hierarchical notation for subtrees–i.e., using periods ('.') to separate hierarchy levels. |
- Returns
- Copy of property sub tree rooted at
key
. Nullopt if no sub tree exists that is rooted at key
.
◆ operator=()
Assignment operator.
- Parameters
-
- Returns
- .
◆ put()
Insert key/value pair into property tree.
- Template Parameters
-
- Parameters
-
[in] | key | Property key. Expected to be in hierarchical notation for subtrees–i.e., using periods ('.') to separate hierarchy levels. |
[in] | data | Property value corresponding to key . |
◆ write_json()
void Opm::PropertyTree::write_json |
( |
std::ostream & |
os, |
|
|
bool |
pretty |
|
) |
| const |
Emit a textual representation of the property tree in JSON form.
- Parameters
-
[in,out] | os | Output stream. Typically a stream opened on a file. |
[in] | pretty | Whether or not to pretty-print the JSON output–i.e., whether or not to insert new lines and spaces for human readability. |
The documentation for this class was generated from the following files: