7 #ifndef ISC_TRANSLATOR_H 8 #define ISC_TRANSLATOR_H 1 13 #include <sysrepo-cpp/Session.hpp> 66 const std::string& xpath,
67 const std::string& name);
104 std::string
const& xpath,
105 std::string
const& name,
106 sr_type_t
const type);
112 void delItem(
const std::string& xpath);
121 template <
typename functor_t>
122 void forAll(std::string
const& xpath, functor_t f) {
123 libyang::S_Data_Node data_node(
session_->get_data(xpath.c_str()));
128 for (libyang::S_Data_Node& root : data_node->tree_for()) {
129 for (libyang::S_Data_Node
const& n : root->tree_dfs()) {
146 template <
typename T>
153 for (
size_t i(0); i < values->val_cnt(); ++i) {
177 #endif // ISC_TRANSLATOR_H sysrepo::S_Vals getValuesFromItems(std::string const &xpath)
Get the values of all siblings at a certain xpath.
isc::data::ElementPtr getItems(const std::string &xpath)
Get and translate a list of basic values from YANG to JSON.
void checkAndSetLeaf(isc::data::ConstElementPtr const &from, std::string const &xpath, std::string const &name, sr_type_t const type)
Get an element from given ElementPtr node and set it in sysrepo at given xpath.
Between YANG and JSON translator class for basic values.
virtual ~TranslatorBasic()
Destructor.
boost::shared_ptr< Element > ElementPtr
static isc::data::ElementPtr value(sysrepo::S_Val s_val)
Translate basic value from YANG to JSON.
static ElementPtr createList(const Position &pos=ZERO_POSITION())
Creates an empty ListElement type ElementPtr.
void setItem(const std::string &xpath, isc::data::ConstElementPtr elem, sr_type_t type)
Translate and set basic value from JSON to YANG.
std::string model_
The model.
boost::shared_ptr< const Element > ConstElementPtr
TranslatorBasic(sysrepo::S_Session session, const std::string &model)
Constructor.
void delItem(const std::string &xpath)
Delete basic value from YANG.
Defines the logger used by the top-level component of kea-lfc.
void forAll(std::string const &xpath, functor_t f)
Run a function for a node and all its children.
isc::data::ElementPtr getItem(const std::string &xpath)
Get and translate basic value from YANG to JSON.
void checkAndGetLeaf(isc::data::ElementPtr &storage, const std::string &xpath, const std::string &name)
Retrieves an item and stores it in the specified storage.
isc::data::ElementPtr getList(std::string const &xpath, T &t, isc::data::ElementPtr(T::*f)(std::string const &xpath))
Retrieve a list as ElementPtr from sysrepo from a certain xpath.
sysrepo::S_Session session_
The sysrepo session.