#include <PropertyTree.h>
Properties of a reasoner.
Definition at line 21 of file PropertyTree.h.
◆ PropertyTree() [1/6]
PropertyTree::PropertyTree |
( |
| ) |
|
◆ PropertyTree() [2/6]
PropertyTree::PropertyTree |
( |
std::shared_ptr< const boost::property_tree::ptree > |
ptree | ) |
|
|
explicit |
Load a reasoner configuration from a property tree.
- Parameters
-
Definition at line 22 of file PropertyTree.cpp.
23 : ptree_(std::move(
ptree)),
◆ PropertyTree() [3/6]
PropertyTree::PropertyTree |
( |
const std::string_view |
json_str | ) |
|
|
explicit |
Load a reasoner configuration from a JSON string.
- Parameters
-
Definition at line 28 of file PropertyTree.cpp.
30 std::istringstream ss(json_str.data());
31 boost::property_tree::ptree tree;
32 boost::property_tree::read_json(ss, tree);
34 ptree_ = std::make_shared<boost::property_tree::ptree>(tree);
◆ PropertyTree() [4/6]
knowrob::PropertyTree::PropertyTree |
( |
| ) |
|
◆ PropertyTree() [5/6]
knowrob::PropertyTree::PropertyTree |
( |
std::shared_ptr< const boost::property_tree::ptree > |
ptree | ) |
|
|
explicit |
Load a reasoner configuration from a property tree.
- Parameters
-
◆ PropertyTree() [6/6]
knowrob::PropertyTree::PropertyTree |
( |
const std::string_view |
json_str | ) |
|
|
explicit |
Load a reasoner configuration from a JSON string.
- Parameters
-
◆ begin() [1/2]
auto knowrob::PropertyTree::begin |
( |
| ) |
const |
|
inline |
- Returns
- the begin iterator of the key-value pairs.
Definition at line 73 of file PropertyTree.h.
73 {
return properties_.begin(); }
◆ begin() [2/2]
auto knowrob::PropertyTree::begin |
( |
| ) |
const |
|
inline |
- Returns
- the begin iterator of the key-value pairs.
Definition at line 73 of file PropertyTree.h.
73 {
return properties_.begin(); }
◆ createKeyTerm() [1/2]
TermPtr PropertyTree::createKeyTerm |
( |
std::string_view |
key | ) |
const |
Generate a term from a key string.
- Parameters
-
- Returns
- a term representing the key.
Definition at line 133 of file PropertyTree.cpp.
136 size_t pos_start = 0, pos_end, delim_len = delimiter_.length();
137 std::string_view token;
138 std::vector<std::string_view> res;
140 while ((pos_end = key.find(delimiter_, pos_start)) != std::string::npos) {
141 token = key.substr(pos_start, pos_end - pos_start);
142 pos_start = pos_end + delim_len;
145 last_key = std::make_shared<Function>(
Function(delimiter_, {last_key, next_key}));
149 res.push_back(token);
static std::shared_ptr< knowrob::Atom > Tabled(std::string_view stringForm)
std::shared_ptr< Term > TermPtr
◆ createKeyTerm() [2/2]
TermPtr knowrob::PropertyTree::createKeyTerm |
( |
std::string_view |
key | ) |
const |
Generate a term from a key string.
- Parameters
-
- Returns
- a term representing the key.
◆ dataSources() [1/2]
auto& knowrob::PropertyTree::dataSources |
( |
| ) |
const |
|
inline |
- Returns
- the list of data sources that should be imported into the reasoner backend.
Definition at line 83 of file PropertyTree.h.
83 {
return dataSources_; }
◆ dataSources() [2/2]
auto& knowrob::PropertyTree::dataSources |
( |
| ) |
const |
|
inline |
- Returns
- the list of data sources that should be imported into the reasoner backend.
Definition at line 83 of file PropertyTree.h.
83 {
return dataSources_; }
◆ end() [1/2]
auto knowrob::PropertyTree::end |
( |
| ) |
const |
|
inline |
- Returns
- the end iterator of the key-value pairs.
Definition at line 78 of file PropertyTree.h.
78 {
return properties_.end(); }
◆ end() [2/2]
auto knowrob::PropertyTree::end |
( |
| ) |
const |
|
inline |
- Returns
- the end iterator of the key-value pairs.
Definition at line 78 of file PropertyTree.h.
78 {
return properties_.end(); }
◆ get() [1/2]
TermPtr PropertyTree::get |
( |
std::string_view |
key, |
|
|
const TermPtr & |
defaultValue |
|
) |
| |
Get a value from the property tree. The keys can contain dots to access nested values and square brackets to access array elements. E.g. a call could have this form:
get("key1.key2[0].key3", defaultValue).
The result needs to be a leaf node in the property tree, else (or in case no value is found) an exception is thrown.
- Parameters
-
key | a key. |
defaultValue | a default value. |
- Returns
- the value associated with the key.
Definition at line 57 of file PropertyTree.cpp.
59 return get_value_recursive(*ptree_,
std::string(key));
60 }
catch (
const std::runtime_error &e) {
◆ get() [2/2]
TermPtr knowrob::PropertyTree::get |
( |
std::string_view |
key, |
|
|
const TermPtr & |
defaultValue |
|
) |
| |
Get a value from the property tree. The keys can contain dots to access nested values and square brackets to access array elements. E.g. a call could have this form:
get("key1.key2[0].key3", defaultValue).
The result needs to be a leaf node in the property tree, else (or in case no value is found) an exception is thrown.
- Parameters
-
key | a key. |
defaultValue | a default value. |
- Returns
- the value associated with the key.
◆ init() [1/2]
void PropertyTree::init |
( |
| ) |
|
Initialize the property tree.
Definition at line 38 of file PropertyTree.cpp.
42 auto data_sources = ptree_->get_child_optional(
"imports");
44 data_sources = ptree_->get_child_optional(
"data-sources");
47 for (
const auto &pair: data_sources.value()) {
48 auto &subtree = pair.second;
49 URI dataSourceURI(subtree);
50 auto dataFormat = subtree.get(
"format", formatDefault);
52 dataSources_.push_back(source);
◆ init() [2/2]
void knowrob::PropertyTree::init |
( |
| ) |
|
Initialize the property tree.
◆ operator->() [1/2]
auto knowrob::PropertyTree::operator-> |
( |
| ) |
const |
|
inline |
Access the underlying boost property tree.
- Returns
- the underlying property tree.
Definition at line 46 of file PropertyTree.h.
◆ operator->() [2/2]
auto knowrob::PropertyTree::operator-> |
( |
| ) |
const |
|
inline |
Access the underlying boost property tree.
- Returns
- the underlying property tree.
Definition at line 46 of file PropertyTree.h.
◆ ptree() [1/2]
auto knowrob::PropertyTree::ptree |
( |
| ) |
const |
|
inline |
- Returns
- the property tree used to generate this configuration.
Definition at line 88 of file PropertyTree.h.
◆ ptree() [2/2]
auto knowrob::PropertyTree::ptree |
( |
| ) |
const |
|
inline |
- Returns
- the property tree used to generate this configuration.
Definition at line 88 of file PropertyTree.h.
The documentation for this class was generated from the following files: