44 return value.
instance ? std::make_shared<Data_Node>(value.
instance, deleter) :
nullptr;
50 return value.
leafref ? std::make_shared<Data_Node>(value.
leafref, deleter) :
nullptr;
61 throw std::invalid_argument(
"Module can not be empty");
66 check_libyang_error(module->module->ctx);
70 deleter = !
parent ? std::make_shared<Deleter>(node, module->deleter) :
parent->deleter;
76 throw std::invalid_argument(
"Module can not be empty");
81 check_libyang_error(module->module->ctx);
85 deleter = !
parent ? std::make_shared<Deleter>(node, module->deleter) :
parent->deleter;
91 throw std::invalid_argument(
"Module can not be empty");
96 check_libyang_error(module->module->ctx);
100 deleter = !
parent ? std::make_shared<Deleter>(node, module->deleter) :
parent->deleter;
106 throw std::invalid_argument(
"Module can not be empty");
111 check_libyang_error(module->module->ctx);
115 deleter = !
parent ? std::make_shared<Deleter>(node, module->deleter) :
parent->deleter;
121 throw std::invalid_argument(
"Module can not be empty");
126 check_libyang_error(module->module->ctx);
130 deleter = !
parent ? std::make_shared<Deleter>(node, module->deleter) :
parent->deleter;
136 throw std::invalid_argument(
"Context can not be empty");
139 throw std::invalid_argument(
"Path can not be empty");
142 new_node =
lyd_new_path(NULL, context->ctx,
path, (
void *) value, value_type, options);
144 check_libyang_error(context->ctx);
148 deleter = std::make_shared<Deleter>(node, context->deleter);
154 throw std::invalid_argument(
"Context can not be empty");
157 throw std::invalid_argument(
"Path can not be empty");
162 check_libyang_error(context->ctx);
166 deleter = context->deleter;
172 throw std::invalid_argument(
"Context can not be empty");
175 throw std::invalid_argument(
"Path can not be empty");
180 check_libyang_error(context->ctx);
184 deleter = context->deleter;
190 char *path =
nullptr;
194 check_libyang_error(node->schema->module->ctx);
198 std::string s_path = path;
203 struct lyd_node *new_node =
nullptr;
205 new_node =
lyd_dup(node, recursive);
210 S_Deleter new_deleter = std::make_shared<Deleter>(new_node, deleter);
211 return std::make_shared<Data_Node>(new_node, new_deleter);
214 struct lyd_node *new_node =
nullptr;
221 S_Deleter new_deleter = std::make_shared<Deleter>(new_node, deleter);
222 return std::make_shared<Data_Node>(new_node, new_deleter);
225 struct lyd_node *new_node =
nullptr;
229 S_Deleter new_deleter = std::make_shared<Deleter>(new_node, context->deleter);
230 return new_node ? std::make_shared<Data_Node>(new_node, new_deleter) :
nullptr;
233 int ret =
lyd_merge(node, source->node, options);
235 check_libyang_error(source->node->schema->module->ctx);
242 check_libyang_error(context->ctx);
305 return std::make_shared<Set>(
set, std::make_shared<Deleter>(
set, deleter));
313 return std::make_shared<Set>(
set, std::make_shared<Deleter>(
set, deleter));
316 struct lyd_node *new_node =
nullptr;
320 return new_node ? std::make_shared<Data_Node>(new_node, deleter) :
nullptr;
323 int ret =
lyd_validate(&node, options, (
void *) var_arg->ctx);
330 int ret =
lyd_validate(&node, options, (
void *) var_arg->node);
339 if (ret != EXIT_SUCCESS) {
352 return diff ? std::make_shared<Difflist>(
diff, deleter) :
nullptr;
355 struct lyd_node *new_node =
nullptr;
357 new_node =
lyd_new_path(node, ctx->ctx,
path, (
void *)value, value_type, options);
362 return new_node ? std::make_shared<Data_Node>(new_node, deleter) :
nullptr;
365 struct lyd_node *new_node =
nullptr;
372 return new_node ? std::make_shared<Data_Node>(new_node, deleter) :
nullptr;
375 struct lyd_node *new_node =
nullptr;
382 return new_node ? std::make_shared<Data_Node>(new_node, deleter) :
nullptr;
399 deleter = std::make_shared<Deleter>(node,
nullptr);
412 return attr ? std::make_shared<Attr>(
attr, deleter) :
nullptr;
422 return module ? std::make_shared<Module>(module, deleter) :
nullptr;
425 char *strp =
nullptr;
434 std::string s_strp = strp;
440 std::vector<S_Data_Node> s_vector;
444 s_vector.push_back(std::make_shared<Data_Node>(elem, deleter));
450 std::vector<S_Data_Node> s_vector;
454 s_vector.push_back(std::make_shared<Data_Node>(elem, deleter));
462 Data_Node(derived->node, derived->deleter),
464 deleter(derived->deleter)
466 if (derived->node->schema->nodetype !=
LYS_LEAFLIST && derived->node->schema->nodetype !=
LYS_LEAF) {
467 throw std::invalid_argument(
"Type must be LYS_LEAFLIST or LYS_LEAF");
496 return std::make_shared<Type>((
struct lys_type *) type, deleter);
500 Data_Node(derived->node, derived->deleter),
502 deleter(derived->deleter)
504 if (derived->node->schema->nodetype !=
LYS_ANYDATA && derived->node->schema->nodetype !=
LYS_ANYXML) {
505 throw std::invalid_argument(
"Type must be LYS_ANYDATA or LYS_ANYXML");
528 deleter = std::make_shared<Deleter>(diff, deleter);
532 std::vector<S_Data_Node> s_vector;
539 for(i = 0; i <
sizeof(*diff->
first); i++) {
540 s_vector.push_back(std::make_shared<Data_Node>(*diff->
first, deleter));
546 std::vector<S_Data_Node> s_vector;
553 for(i = 0; i <
sizeof(*diff->
second); i++) {
554 s_vector.push_back(std::make_shared<Data_Node>(*diff->
second, deleter));
561 return new_node ? std::make_shared<Data_Node>(new_node,
nullptr) :
nullptr;
int insert(S_Data_Node new_node)
int insert_before(S_Data_Node new_node)
struct lys_module * module
struct lyd_node * lyd_new_anydata(struct lyd_node *parent, const struct lys_module *module, const char *name, void *value, LYD_ANYDATA_VALUETYPE value_type)
Create a new anydata or anyxml node in a data tree.
int schema_sort(int recursive)
int change_leaf(const char *val_str)
struct lyd_node * lyd_dup_to_ctx(const struct lyd_node *node, int options, struct ly_ctx *ctx)
Create a copy of the specified data tree node in the different context. All the schema references and...
int merge_to_ctx(S_Data_Node source, int options, S_Context context)
int validate(int options, S_Context var_arg)
int lyd_validate(struct lyd_node **node, int options, void *var_arg,...)
Validate node data subtree.
char * lyd_path(const struct lyd_node *node)
Build data path (usable as path, see XPath Addressing) of the data node.
struct lyd_attr * lyd_insert_attr(struct lyd_node *parent, const struct lys_module *mod, const char *name, const char *value)
Insert attribute into the data node.
S_Data_Node create_new_Data_Node(struct lyd_node *node)
struct lys_module * lyd_node_module(const struct lyd_node *node)
Return main module of the data tree node.
Class implementation for libyang C header xml.h.
struct lyd_node * lyd_dup_withsiblings(const struct lyd_node *node, int options)
Create a copy of the specified data tree and all its siblings (preceding as well as following)....
S_Data_Node dup(int recursive)
node's value representation
S_Data_Node first_sibling()
libyang representation of data model trees.
int lyd_wd_default(struct lyd_node_leaf_list *node)
Get know if the node contain (despite implicit or explicit) default value.
int merge(S_Data_Node source, int options)
int lyd_insert(struct lyd_node *parent, struct lyd_node *node)
Insert the node element as child to the parent element. The node is inserted as a last child of the p...
LY_DATA_TYPE _PACKED value_type
struct lyd_node * lyd_dup(const struct lyd_node *node, int options)
Create a copy of the specified data tree node. Schema references are kept the same....
Data_Node_Anydata(S_Data_Node derived)
Data_Node(struct lyd_node *node, S_Deleter deleter=nullptr)
struct lyd_node * lyd_new_path(struct lyd_node *data_tree, struct ly_ctx *ctx, const char *path, void *value, LYD_ANYDATA_VALUETYPE value_type, int options)
Create a new data node based on a simple XPath.
S_Set find_path(const char *expr)
libyang representation of data trees.
The main libyang public header.
Class implementation for libyang C header tree_schema.h.
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
std::vector< S_Data_Node > first()
Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects....
struct lyd_difflist * lyd_diff(struct lyd_node *first, struct lyd_node *second, int options)
Compare two data trees and provide list of differences.
S_Attr insert_attr(S_Module module, const char *name, const char *value)
unsigned int lyd_list_pos(const struct lyd_node *node)
Learn the relative instance position of a list or leaf-list within other instances of the same schema...
int lyd_schema_sort(struct lyd_node *sibling, int recursive)
Order siblings according to the schema node ordering.
Attr(struct lyd_attr *attr, S_Deleter deleter=nullptr)
S_Data_Node dup_withsiblings(int recursive)
#define LY_TREE_DFS_BEGIN(START, NEXT, ELEM)
Macro to iterate via all elements in a tree. This is the opening part to the LY_TREE_DFS_END - they a...
int lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node)
Insert the node element after the sibling element. If node and siblings are already siblings (just mo...
std::vector< S_Data_Node > second()
S_Difflist diff(S_Data_Node second, int options)
Structure for data nodes defined as LYS_LEAF or LYS_LEAFLIST.
struct lyd_node * leafref
#define LY_TREE_DFS_END(START, NEXT, ELEM)
int lyd_insert_sibling(struct lyd_node **sibling, struct lyd_node *node)
Insert the node element as a last sibling of the specified sibling element.
struct lyd_node * lyd_new_leaf(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str)
Create a new leaf or leaflist node in a data tree with a string value that is converted to the actual...
classes for wrapping lyd_node.
class for wrapping lyd_difflist.
struct lyd_node ** second
int lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node)
Insert the node element after the sibling element. If node and siblings are already siblings (just mo...
Structure for the result of lyd_diff(), describing differences between two data trees.
int validate_value(const char *value)
Main schema node structure representing YANG module.
Data_Node_Leaf_List(S_Data_Node derived)
int lyd_print_mem(char **strp, const struct lyd_node *root, LYD_FORMAT format, int options)
Print data tree in the specified format.
std::string print_mem(LYD_FORMAT format, int options)
#define LY_TREE_FOR(START, ELEM)
Macro to iterate via all sibling elements without affecting the list itself.
class for wrapping lyd_attr.
int insert_sibling(S_Data_Node new_node)
struct ly_set * lyd_find_instance(const struct lyd_node *data, const struct lys_node *schema)
Search in the given data for instances of the provided schema node.
struct lyd_node * lyd_first_sibling(struct lyd_node *node)
Get the first sibling of the given node.
Class implementation for libyang C header libyang.h.
LY_DATA_TYPE
YANG built-in types.
struct lyd_node * instance
std::vector< S_Data_Node > tree_dfs()
YANG type structure providing information from the schema.
struct ly_set * lyd_find_path(const struct lyd_node *ctx_node, const char *path)
Search in the given data for instances of nodes matching the provided path.
const struct lys_type * lyd_leaf_type(const struct lyd_node_leaf_list *leaf)
Get the type structure of a leaf.
Value(lyd_val value, LY_DATA_TYPE *value_type, uint8_t value_flags, S_Deleter deleter)
struct lyd_node * lyd_new(struct lyd_node *parent, const struct lys_module *module, const char *name)
Create a new container node in a data tree.
S_Data_Node new_path(S_Context ctx, const char *path, const char *value, LYD_ANYDATA_VALUETYPE value_type, int options)
int lyd_validate_value(struct lys_node *node, const char *value)
Check restrictions applicable to the particular leaf/leaf-list on the given string value.
Class implementation for libyang C header tree_data.h.
Generic structure for a data node, directly applicable to the data nodes defined as LYS_CONTAINER,...
std::vector< S_Data_Node > tree_for()
LYD_ANYDATA_VALUETYPE
List of possible value types stored in lyd_node_anydata.
int lyd_unlink(struct lyd_node *node)
Unlink the specified data subtree. All referenced namespaces are copied.
int lyd_change_leaf(struct lyd_node_leaf_list *leaf, const char *val_str)
Change value of a leaf node.
int lyd_merge(struct lyd_node *target, const struct lyd_node *source, int options)
Merge a (sub)tree into a data tree.
int insert_after(S_Data_Node new_node)
int lyd_merge_to_ctx(struct lyd_node **trg, const struct lyd_node *src, int options, struct ly_ctx *ctx)
Same as lyd_merge(), but moves the resulting data into the specified context.
S_Data_Node dup_to_ctx(int recursive, S_Context context)
S_Set find_instance(S_Schema_Node schema)