Loading...
Searching...
No Matches
tree_data.h
Go to the documentation of this file.
#ifndef LY_TREE_DATA_H_
#define LY_TREE_DATA_H_
/* socket/ip includes in ly_config.h */
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#include <stddef.h>
#include <stdint.h>
#include <time.h>
#include "log.h"
#include "ly_config.h"
#include "tree.h"
#include "tree_schema.h"
#ifdef __cplusplus
extern "C" {
#endif
struct ly_ctx;
struct ly_path;
struct ly_set;
struct lyd_node;
struct lyd_node_opaq;
struct lyd_node_term;
struct timespec;
struct lyxp_var;
struct rb_node;
/* *INDENT-OFF* */
#define LYD_TREE_DFS_BEGIN(START, ELEM) \
{ ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
(ELEM); \
(ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
#define LYD_TREE_DFS_END(START, ELEM) \
/* select element for the next run - children first */ \
if (LYD_TREE_DFS_continue) { \
(LYD_TREE_DFS_next) = NULL; \
} else { \
(LYD_TREE_DFS_next) = lyd_child(ELEM); \
}\
if (!(LYD_TREE_DFS_next)) { \
/* no children */ \
if ((ELEM) == (struct lyd_node *)(START)) { \
/* we are done, (START) has no children */ \
break; \
} \
/* try siblings */ \
(LYD_TREE_DFS_next) = (ELEM)->next; \
} \
while (!(LYD_TREE_DFS_next)) { \
/* parent is already processed, go to its sibling */ \
(ELEM) = (struct lyd_node *)(ELEM)->parent; \
/* no siblings, go back through parents */ \
if ((ELEM)->parent == (START)->parent) { \
/* we are done, no next element to process */ \
break; \
} \
(LYD_TREE_DFS_next) = (ELEM)->next; \
} }
#define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
(ELEM) && ((ELEM)->schema == (SCHEMA)); \
(ELEM) = (ELEM)->next)
#define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
(ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
(ELEM) = (NEXT))
/* *INDENT-ON* */
#define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
#define LYD_NODE_IS_ALONE(NODE) \
(((NODE)->prev == NODE) || \
(((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
typedef enum {
LYD_UNKNOWN = 0,
LYD_XML,
LYD_JSON,
LYD_LYB
} LYD_FORMAT;
typedef enum {
LYD_ANYDATA_DATATREE,
LYD_ANYDATA_STRING,
LYD_ANYDATA_XML,
LYD_ANYDATA_JSON,
LYD_ANYDATA_LYB
} LYD_ANYDATA_VALUETYPE;
struct lyd_value {
const char *_canonical;
const struct lysc_type *realtype;
union {
int8_t boolean;
int64_t dec64;
int8_t int8;
int16_t int16;
int32_t int32;
int64_t int64;
uint8_t uint8;
uint16_t uint16;
uint32_t uint32;
uint64_t uint64;
struct lysc_type_bitenum_item *enum_item;
struct lysc_ident *ident;
struct ly_path *target;
struct lyd_value_union *subvalue;
void *dyn_mem;
uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
};
};
#define LYD_VALUE_GET(value, type_val) \
((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
? ((type_val) = (((value)->dyn_mem))) \
: ((type_val) = ((void *)((value)->fixed_mem))))
struct lyd_value_union {
struct lyd_value value;
void *original;
size_t orig_len;
uint32_t hints;
LY_VALUE_FORMAT format;
void *prefix_data;
const struct lysc_node *ctx_node;
};
struct lyd_value_bits {
char *bitmap;
struct lysc_type_bitenum_item **items;
};
struct lyd_value_binary {
void *data;
size_t size;
};
struct lyd_value_ipv4_address_no_zone {
struct in_addr addr;
};
struct lyd_value_ipv4_address {
struct in_addr addr;
const char *zone;
};
struct lyd_value_ipv4_prefix {
struct in_addr addr;
uint8_t prefix;
};
struct lyd_value_ipv6_address_no_zone {
struct in6_addr addr;
};
struct lyd_value_ipv6_address {
struct in6_addr addr;
const char *zone;
};
struct lyd_value_ipv6_prefix {
struct in6_addr addr;
uint8_t prefix;
};
struct lyd_value_date_and_time {
time_t time;
char *fractions_s;
ly_bool unknown_tz;
};
struct lyd_value_xpath10 {
struct lyxp_expr *exp;
const struct ly_ctx *ctx;
void *prefix_data;
LY_VALUE_FORMAT format;
};
struct lyd_value_lyds_tree {
struct rb_node *rbt;
};
struct ly_opaq_name {
const char *name;
const char *prefix;
union {
const char *module_ns;
const char *module_name;
};
};
struct lyd_attr {
struct lyd_node_opaq *parent;
struct lyd_attr *next;
struct ly_opaq_name name;
const char *value;
uint32_t hints;
LY_VALUE_FORMAT format;
void *val_prefix_data;
};
#define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
#define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
#define LYD_NODE_ANY (LYS_ANYDATA)
#define LYD_DEFAULT 0x01
#define LYD_WHEN_TRUE 0x02
#define LYD_NEW 0x04
#define LYD_EXT 0x08
struct lyd_node {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
void *priv;
};
struct lyd_node_inner {
union {
struct lyd_node node;
struct {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
void *priv;
};
};
struct lyd_node *child;
struct ly_ht *children_ht;
#define LYD_HT_MIN_ITEMS 4
};
struct lyd_node_term {
union {
struct lyd_node node;
struct {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
void *priv;
};
};
struct lyd_value value;
};
union lyd_any_value {
struct lyd_node *tree;
const char *str;
const char *xml;
const char *json;
char *mem;
};
struct lyd_node_any {
union {
struct lyd_node node;
struct {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
void *priv;
};
};
union lyd_any_value value;
LYD_ANYDATA_VALUETYPE value_type;
};
#define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
#define LYD_VALHINT_STRING 0x0001
#define LYD_VALHINT_DECNUM 0x0002
#define LYD_VALHINT_OCTNUM 0x0004
#define LYD_VALHINT_HEXNUM 0x0008
#define LYD_VALHINT_NUM64 0x0010
#define LYD_VALHINT_BOOLEAN 0x0020
#define LYD_VALHINT_EMPTY 0x0040
#define LYD_VALHINT_STRING_DATATYPES 0x0080
#define LYD_NODEHINT_LIST 0x0080
#define LYD_NODEHINT_LEAFLIST 0x0100
#define LYD_NODEHINT_CONTAINER 0x0200
#define LYD_HINT_DATA 0x03F3
#define LYD_HINT_SCHEMA 0x03FF
struct lyd_node_opaq {
union {
struct lyd_node node;
struct {
uint32_t hash;
uint32_t flags;
const struct lysc_node *schema;
struct lyd_node_inner *parent;
struct lyd_node *next;
struct lyd_node *prev;
struct lyd_meta *meta;
void *priv;
};
};
struct lyd_node *child;
struct ly_opaq_name name;
const char *value;
uint32_t hints;
LY_VALUE_FORMAT format;
void *val_prefix_data;
struct lyd_attr *attr;
const struct ly_ctx *ctx;
};
struct lyd_leafref_links_rec {
const struct lyd_node_term *node;
const struct lyd_node_term **leafref_nodes;
const struct lyd_node_term **target_nodes;
};
static inline struct lyd_node *
lyd_parent(const struct lyd_node *node)
{
return (node && node->parent) ? &node->parent->node : NULL;
}
static inline struct lyd_node *
lyd_child(const struct lyd_node *node)
{
if (!node) {
return NULL;
}
if (!node->schema) {
/* opaq node */
return ((const struct lyd_node_opaq *)node)->child;
}
if (node->schema->nodetype & (LYS_CONTAINER | LYS_LIST | LYS_RPC | LYS_ACTION | LYS_NOTIF)) {
return ((const struct lyd_node_inner *)node)->child;
}
return NULL;
}
LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
LIBYANG_API_DECL int lyd_lyb_data_length(const char *data);
LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
static inline const char *
lyd_get_value(const struct lyd_node *node)
{
if (!node) {
return NULL;
}
if (!node->schema) {
return ((const struct lyd_node_opaq *)node)->value;
} else if (node->schema->nodetype & LYD_NODE_TERM) {
const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
return value->_canonical ? value->_canonical : lyd_value_get_canonical(LYD_CTX(node), value);
}
return NULL;
}
LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value,
LYD_ANYDATA_VALUETYPE value_type);
LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
ly_bool output, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
#define LYD_NEW_VAL_OUTPUT 0x01
#define LYD_NEW_VAL_STORE_ONLY 0x02
#define LYD_NEW_VAL_BIN 0x04
#define LYD_NEW_VAL_CANON 0x08
#define LYD_NEW_META_CLEAR_DFLT 0x10
#define LYD_NEW_PATH_UPDATE 0x20
#define LYD_NEW_PATH_OPAQ 0x40
#define LYD_NEW_PATH_WITH_OPAQ 0x80
#define LYD_NEW_ANY_USE_VALUE 0x100
LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
uint32_t options, struct lyd_node **node, ...);
LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options,
struct lyd_node **node, ...);
LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
const char *keys, uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
const char **key_values, uint32_t *value_lengths, uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
const char *value, uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
const void *value, size_t value_len, uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value,
size_t value_len, uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value,
LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
const struct lyd_attr *attr, struct lyd_meta **meta);
LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
const char *prefix, const char *module_name, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
const char *prefix, const char *module_ns, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
struct lyd_attr **attr);
LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
struct lyd_attr **attr);
LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
uint32_t options, struct lyd_node **node);
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
struct lyd_node **new_node);
LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path,
const void *value, uint32_t options, struct lyd_node **node);
#define LYD_IMPLICIT_NO_STATE 0x01
#define LYD_IMPLICIT_NO_CONFIG 0x02
#define LYD_IMPLICIT_OUTPUT 0x04
#define LYD_IMPLICIT_NO_DEFAULTS 0x08
LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
struct lyd_node **diff);
LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
uint32_t implicit_options, struct lyd_node **diff);
LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len);
LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value,
size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len);
#define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
(subtree, so direct as well as indirect children) are the same. By default,
containers are the same in case of the same schema node and lists are the same
in case of equal keys (keyless lists do the full recursion comparison all the time). */
#define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
changes this behavior and implicit (automatically created default node) and explicit
(explicitly created node with the default value) default nodes are considered different. */
#define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
opaque nodes members are compared to data node schema and value and can result
in a match. */
LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
#define LYD_DUP_RECURSIVE 0x01
#define LYD_DUP_NO_META 0x02
#define LYD_DUP_WITH_PARENTS 0x04
#define LYD_DUP_WITH_FLAGS 0x08
#define LYD_DUP_NO_EXT 0x10
#define LYD_DUP_WITH_PRIV 0x20
#define LYD_DUP_NO_LYDS 0x40
LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
struct lyd_node **dup);
LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
struct lyd_node **dup);
LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
#define LYD_MERGE_DESTRUCT 0x01
#define LYD_MERGE_DEFAULTS 0x02
#define LYD_MERGE_WITH_FLAGS 0x04
LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
#define LYD_DIFF_DEFAULTS 0x01
#define LYD_DIFF_META 0x02
LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
struct lyd_node **diff);
LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
struct lyd_node **diff);
typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
#define LYD_DIFF_MERGE_DEFAULTS 0x01
LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
typedef enum {
LYD_PATH_STD,
LYD_PATH_STD_NO_LAST_PRED
} LYD_PATH_TYPE;
LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
const char *name);
LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
struct lyd_node **match);
LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
const char *key_or_value, size_t val_len, struct lyd_node **match);
LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
struct ly_set **set);
LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
struct ly_set **set);
LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
const struct lyxp_var *vars, ly_bool *result);
LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
typedef enum {
LY_XPATH_NODE_SET,
LY_XPATH_STRING,
LY_XPATH_NUMBER,
LY_XPATH_BOOLEAN
} LY_XPATH_TYPE;
LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
long double *number, ly_bool *boolean);
LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
struct lyd_node **match);
LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
LIBYANG_API_DECL int ly_time_tz_offset(void);
LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
uint32_t str_len, pcre2_code **pcode);
LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, pcre2_code **pcode);
#ifdef __cplusplus
}
#endif
#endif /* LY_TREE_DATA_H_ */
ly_ctx
libyang context handler.
LYD_ANYDATA_VALUETYPE
LYD_ANYDATA_VALUETYPE
List of possible value types stored in lyd_node_any.
Definition tree_data.h:549
LYD_FORMAT
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition tree_data.h:539
LYD_CTX
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition tree_data.h:522
LYD_ANYDATA_DATATREE
@ LYD_ANYDATA_DATATREE
Definition tree_data.h:550
LYD_ANYDATA_JSON
@ LYD_ANYDATA_JSON
Definition tree_data.h:558
LYD_ANYDATA_XML
@ LYD_ANYDATA_XML
Definition tree_data.h:557
LYD_ANYDATA_LYB
@ LYD_ANYDATA_LYB
Definition tree_data.h:559
LYD_ANYDATA_STRING
@ LYD_ANYDATA_STRING
Definition tree_data.h:554
LYD_LYB
@ LYD_LYB
Definition tree_data.h:543
LYD_XML
@ LYD_XML
Definition tree_data.h:541
LYD_UNKNOWN
@ LYD_UNKNOWN
Definition tree_data.h:540
LYD_JSON
@ LYD_JSON
Definition tree_data.h:542
LY_ERR
LY_ERR
libyang's error codes returned by the libyang functions.
Definition log.h:237
ly_set
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node,...
Definition set.h:47
lysc_ext_instance
YANG extension compiled instance.
Definition plugins_exts.h:437
LYS_NOTIF
#define LYS_NOTIF
Definition tree_schema.h:251
LYS_RPC
#define LYS_RPC
Definition tree_schema.h:249
LYS_CONTAINER
#define LYS_CONTAINER
Definition tree_schema.h:240
LYS_ACTION
#define LYS_ACTION
Definition tree_schema.h:250
LYS_LIST
#define LYS_LIST
Definition tree_schema.h:244
lysc_node::nodetype
uint16_t nodetype
Definition tree_schema.h:1422
lysc_node::parent
struct lys_module *struct lysc_node * parent
Definition tree_schema.h:1426
lysc_node::name
const char * name
Definition tree_schema.h:1432
lys_module
Available YANG schema tree structures representing YANG module.
Definition tree_schema.h:2137
lysc_ident
YANG identity-stmt.
Definition tree_schema.h:1212
lysc_node
Compiled YANG data node.
Definition tree_schema.h:1421
lysc_type
Definition tree_schema.h:1283
lysc_type_bitenum_item
Definition tree_schema.h:1324
LY_VALUE_FORMAT
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition tree.h:234
log.h
Logger manipulation routines and error definitions.
ly_bool
uint8_t ly_bool
Type to indicate boolean value.
Definition log.h:35
lyd_meta::name
const char * name
Definition metadata.h:40
lyd_meta::value
struct lyd_value value
Definition metadata.h:41
lyd_meta
Metadata structure.
Definition metadata.h:36
ly_ht
libyang hash table.
tree.h
libyang generic macros and functions to work with YANG schema or data trees.
lyxp_vars_free
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
lyd_attr::format
LY_VALUE_FORMAT format
Definition tree_data.h:752
lyd_node::next
struct lyd_node * next
Definition tree_data.h:803
ly_pattern_compile
LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, pcre2_code **pcode)
Compile an XML Schema regex pattern prior to matching.
lyd_free_all
LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node)
Free all the nodes (even parents of the node) in the data tree.
lyd_find_sibling_opaq_next
LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match)
Search the given siblings for an opaque node with a specific name.
lyd_node_opaq::val_prefix_data
void * val_prefix_data
Definition tree_data.h:1010
lyd_merge_siblings
LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options)
Merge the source data tree with any following siblings into the target data tree. Merge may not be co...
lyd_free_meta_siblings
LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta)
Free the metadata instance with any following instances.
lyd_find_xpath
LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
ly_opaq_name::prefix
const char * prefix
Definition tree_data.h:735
lyd_value_lyds_tree::rbt
struct rb_node * rbt
Definition tree_data.h:723
ly_time_ts2str
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str)
Convert timespec into date-and-time string value.
lyd_value_ipv4_address::addr
struct in_addr addr
Definition tree_data.h:665
ly_time_str2time
LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s)
Convert date-and-time from string to UNIX timestamp and fractions of a second.
lyd_new_path
LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value, uint32_t options, struct lyd_node **node)
Create a new node in the data tree based on a path. If creating anyxml/anydata nodes,...
lyd_value_get_canonical
LIBYANG_API_DECL const char * lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value)
Get the (canonical) value of a lyd_value.
lyd_path
LIBYANG_API_DECL char * lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen)
Generate path of the given node in the requested format.
lyd_any_value::str
const char * str
Definition tree_data.h:878
lyd_find_target
LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match)
Find the target node of a compiled path (lyd_value instance-identifier).
LYD_PATH_TYPE
LYD_PATH_TYPE
Types of the different data paths.
Definition tree_data.h:2337
LYD_PATH_STD_NO_LAST_PRED
@ LYD_PATH_STD_NO_LAST_PRED
Definition tree_data.h:2340
LYD_PATH_STD
@ LYD_PATH_STD
Definition tree_data.h:2338
lyd_new_implicit_module
LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module, uint32_t implicit_options, struct lyd_node **diff)
Add any missing implicit nodes of one module. Default nodes with a false "when" are not added.
lyd_new_path2
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent, struct lyd_node **new_node)
Create a new node in the data tree based on a path. All node types can be created.
lyd_node_term::value
struct lyd_value value
Definition tree_data.h:870
ly_time_tz_offset
LIBYANG_API_DECL int ly_time_tz_offset(void)
Get current timezone (including DST setting) UTC (GMT) time offset in seconds.
lyd_find_path
LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output, struct lyd_node **match)
Search in given data for a node uniquely identified by a path.
lyd_value::realtype
const struct lysc_type * realtype
Definition tree_data.h:571
lyd_change_meta
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str)
Change the value of a metadata instance.
lyd_new_list3
LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name, const char **key_values, uint32_t *value_lengths, uint32_t options, struct lyd_node **node)
Create a new list node in the data tree.
lyd_any_value::mem
char * mem
Definition tree_data.h:881
lyd_any_value::tree
struct lyd_node * tree
Definition tree_data.h:877
ly_time_str2ts
LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts)
Convert date-and-time from string to timespec.
lyd_value_ipv4_address_no_zone::addr
struct in_addr addr
Definition tree_data.h:658
lyd_attr::hints
uint32_t hints
Definition tree_data.h:751
lyd_new_opaq
LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value, const char *prefix, const char *module_name, struct lyd_node **node)
Create a new JSON opaque node in the data tree. To create an XML opaque node, use lyd_new_opaq2().
lyd_change_term
LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str)
Change the value of a term (leaf or leaf-list) node to a string value.
lyd_node_any::value_type
LYD_ANYDATA_VALUETYPE value_type
Definition tree_data.h:912
lyd_new_attr
LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value, struct lyd_attr **attr)
Create new JSON attribute for an opaque data node. To create an XML attribute, use lyd_new_attr2().
lyd_insert_child
LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node)
Insert a child into a parent.
lyd_first_sibling
LIBYANG_API_DECL struct lyd_node * lyd_first_sibling(const struct lyd_node *node)
Get the first sibling of the given node.
lyd_leafref_links_rec::leafref_nodes
const struct lyd_node_term ** leafref_nodes
Definition tree_data.h:1021
lyd_node_opaq::attr
struct lyd_attr * attr
Definition tree_data.h:1012
lyd_new_list
LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, uint32_t options, struct lyd_node **node,...)
Create a new list node in the data tree.
lyd_new_implicit_all
LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options, struct lyd_node **diff)
Add any missing implicit nodes. Default nodes with a false "when" are not added.
lyd_diff_cb
LY_ERR(* lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data)
Callback for diff nodes.
Definition tree_data.h:2216
lyd_node_module
LIBYANG_API_DECL const struct lys_module * lyd_node_module(const struct lyd_node *node)
Get the module of a node. Useful mainly for opaque nodes.
lyd_dup_siblings_to_ctx
LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are assi...
lyd_node_opaq::child
struct lyd_node * child
Definition tree_data.h:1004
lyd_compare_meta
LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2)
Compare 2 metadata.
lyd_value_binary::data
void * data
Definition tree_data.h:650
lyd_any_value::json
const char * json
Definition tree_data.h:880
lyd_free_tree
LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node)
Free (and unlink) the specified data (sub)tree.
lyd_new_meta
LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta)
Create a new metadata.
lyd_diff_tree
LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, struct lyd_node **diff)
Learn the differences between 2 data trees.
lyd_new_implicit_tree
LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff)
Add any missing implicit nodes into a data subtree. Default nodes with a false "when" are not added.
lyd_find_sibling_first
LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target, struct lyd_node **match)
Search in the given siblings (NOT recursively) for the first target instance with the same value....
lyd_eval_xpath4
LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree, const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string, long double *number, ly_bool *boolean)
Evaluate an XPath on data and return the result or convert it first to an expected result type.
lyd_leafref_link_node_tree
LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree)
Traverse through data tree including root node siblings and adds leafrefs links to the given nodes.
lyd_dup_single_to_ctx
LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are assigned from trg_ctx.
lyd_value_bits::items
struct lysc_type_bitenum_item ** items
Definition tree_data.h:642
lyd_node_opaq::ctx
const struct ly_ctx * ctx
Definition tree_data.h:1013
lyd_dup_siblings
LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are kept...
lyd_find_sibling_dup_inst_set
LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target, struct ly_set **set)
Search the given siblings for all the exact same instances of a specific node instance....
lyd_value_union::original
void * original
Definition tree_data.h:625
lyd_eval_xpath
LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
lyd_node_schema
LIBYANG_API_DECL const struct lysc_node * lyd_node_schema(const struct lyd_node *node)
Get schema node of a data node. Useful especially for opaque nodes.
lyd_new_term
LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *value, uint32_t options, struct lyd_node **node)
Create a new term node in the data tree.
lyd_merge_cb
LY_ERR(* lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data)
Callback for matching merge nodes.
Definition tree_data.h:2122
lyd_node::meta
struct lyd_meta * meta
Definition tree_data.h:808
lyd_diff_merge_module
LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff, const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options)
Merge 2 diffs into each other but restrict the operation to one module.
lyd_leafref_links_rec::target_nodes
const struct lyd_node_term ** target_nodes
Definition tree_data.h:1027
lyd_node::flags
uint32_t flags
Definition tree_data.h:800
lyd_lyb_data_length
LIBYANG_API_DECL int lyd_lyb_data_length(const char *data)
Learn the length of LYB data.
lyd_meta_is_internal
LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta)
Check whether metadata are not an instance of internal metadata.
lyd_new_any
LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node)
Create a new any node in the data tree.
LY_XPATH_TYPE
LY_XPATH_TYPE
XPath result type.
Definition tree_data.h:2564
LY_XPATH_NODE_SET
@ LY_XPATH_NODE_SET
Definition tree_data.h:2565
LY_XPATH_NUMBER
@ LY_XPATH_NUMBER
Definition tree_data.h:2567
LY_XPATH_STRING
@ LY_XPATH_STRING
Definition tree_data.h:2566
LY_XPATH_BOOLEAN
@ LY_XPATH_BOOLEAN
Definition tree_data.h:2568
lyd_value_binary::size
size_t size
Definition tree_data.h:651
lyd_value_date_and_time::unknown_tz
ly_bool unknown_tz
Definition tree_data.h:706
lyd_node::schema
const struct lysc_node * schema
Definition tree_data.h:801
lyd_value_ipv6_address::addr
struct in6_addr addr
Definition tree_data.h:688
lyd_new_ext_inner
LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node)
Create a new top-level inner node defined in the given extension instance.
lyd_unlink_siblings
LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node)
Unlink the specified node with all the following siblings.
lyd_free_siblings
LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node)
Free all the sibling nodes (preceding as well as succeeding).
lyd_value_xpath10::exp
struct lyxp_expr * exp
Definition tree_data.h:713
lyd_diff_merge_all
LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options)
Merge 2 diffs into each other.
lyd_node_opaq::value
const char * value
Definition tree_data.h:1007
lyxp_vars_set
LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value)
Set a new XPath variable to vars.
lyd_child_no_keys
LIBYANG_API_DECL struct lyd_node * lyd_child_no_keys(const struct lyd_node *node)
Get the child pointer of a generic data node but skip its keys in case it is LYS_LIST.
lyd_value_ipv6_address_no_zone::addr
struct in6_addr addr
Definition tree_data.h:681
lyd_insert_before
LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node)
Insert a node before another node, can be used only for user-ordered nodes. If inserting several sibl...
lyd_new_meta2
LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options, const struct lyd_attr *attr, struct lyd_meta **meta)
Create new metadata from an opaque node attribute if possible.
lyd_diff_siblings
LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, struct lyd_node **diff)
Learn the differences between 2 data trees including all the following siblings.
lyd_leafref_get_links
LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record)
Gets the leafref links record for given node.
ly_opaq_name::name
const char * name
Definition tree_data.h:734
ly_time_tz_offset_at
LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time)
Get UTC (GMT) timezone offset in seconds at a specific timestamp (including DST setting).
lyd_value_union::prefix_data
void * prefix_data
Definition tree_data.h:631
lyd_compare_siblings
LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options)
Compare 2 lists of siblings if they are equivalent.
lyd_value_ipv6_address::zone
const char * zone
Definition tree_data.h:689
lyd_new_ext_list
LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options, struct lyd_node **node,...)
Create a new top-level list node defined in the given extension instance.
lyd_value_date_and_time::time
time_t time
Definition tree_data.h:704
ly_time_time2str
LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str)
Convert UNIX timestamp and fractions of a second into canonical date-and-time string value.
lyd_trim_xpath
LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars)
Evaluate an XPath on data and free all the nodes except the subtrees selected by the expression.
lyd_leafref_links_rec::node
const struct lyd_node_term * node
Definition tree_data.h:1020
lyd_value_compare
LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len)
Compare the node's value with the given string value. The string value is first validated according t...
LYD_NODE_TERM
#define LYD_NODE_TERM
Definition tree_data.h:757
lyd_find_sibling_val
LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value, size_t val_len, struct lyd_node **match)
Search in the given siblings for the first schema instance. Uses hashes - should be used whenever pos...
lyd_node_opaq::hints
uint32_t hints
Definition tree_data.h:1008
lyd_new_ext_path
LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path, const void *value, uint32_t options, struct lyd_node **node)
Create a new node defined in the given extension instance. In case of anyxml/anydata nodes,...
lyd_any_copy_value
LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value, LYD_ANYDATA_VALUETYPE value_type)
Copy anydata value from one node to another. Target value is freed first.
lyd_list_pos
LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance)
Learn the relative position of a list or leaf-list instance within other instances of the same schema...
lyd_insert_after
LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node)
Insert a node after another node, can be used only for user-ordered nodes. If inserting several sibli...
lyd_diff_reverse_all
LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff)
Reverse a diff and make the opposite changes. Meaning change create to delete, delete to create,...
ly_pattern_match
LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string, uint32_t str_len, pcre2_code **pcode)
Check a string matches an XML Schema regex used in YANG.
lyd_find_xpath3
LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
lyd_attr::name
struct ly_opaq_name name
Definition tree_data.h:749
lyd_value_ipv4_address::zone
const char * zone
Definition tree_data.h:666
lyd_compare_single
LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options)
Compare 2 data nodes if they are equivalent.
lyd_find_meta
LIBYANG_API_DECL struct lyd_meta * lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module, const char *name)
Find a specific metadata.
lyd_merge_tree
LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options)
Merge the source data subtree into the target data tree. Merge may not be complete until validation i...
lyd_dup_single
LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are kept the same.
lyd_new_attr2
LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value, struct lyd_attr **attr)
Create new XML attribute for an opaque data node. To create a JSON attribute, use lyd_new_attr().
lyd_node::hash
uint32_t hash
Definition tree_data.h:796
lyd_attr::val_prefix_data
void * val_prefix_data
Definition tree_data.h:753
lyd_value_ipv4_prefix::prefix
uint8_t prefix
Definition tree_data.h:674
lyd_value_ipv4_prefix::addr
struct in_addr addr
Definition tree_data.h:673
lyd_change_term_bin
LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len)
Change the value of a term (leaf or leaf-list) node to a binary value.
lyd_node::prev
struct lyd_node * prev
Definition tree_data.h:804
lyd_find_xpath2
LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
lyd_new_list2
LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys, uint32_t options, struct lyd_node **node)
Create a new list node in the data tree.
lyd_owner_module
LIBYANG_API_DECL const struct lys_module * lyd_owner_module(const struct lyd_node *node)
Get the owner module of the data node. It is the module of the top-level schema node....
lyd_value_ipv6_prefix::prefix
uint8_t prefix
Definition tree_data.h:697
lyd_node_inner::child
struct lyd_node * child
Definition tree_data.h:838
lyd_any_value::xml
const char * xml
Definition tree_data.h:879
lyd_free_attr_siblings
LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free the attribute with any following attributes.
lyd_parse_opaq_error
LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node)
Check node parsed into an opaque node for the reason (error) why it could not be parsed as data node.
lyd_value_xpath10::format
LY_VALUE_FORMAT format
Definition tree_data.h:716
lyd_node::priv
void * priv
Definition tree_data.h:809
lyd_is_default
LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node)
Check whether a node value equals to its default one.
lyd_diff_merge_tree
LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent, const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options)
Merge 2 diff trees into each other.
lyd_value_validate
LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value, size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical)
Check type restrictions applicable to the particular leaf/leaf-list with the given string value.
lyd_new_inner
LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output, struct lyd_node **node)
Create a new inner node in the data tree.
lyd_value_bits::bitmap
char * bitmap
Definition tree_data.h:639
lyd_node_inner::children_ht
struct ly_ht * children_ht
Definition tree_data.h:839
lyd_node_opaq::format
LY_VALUE_FORMAT format
Definition tree_data.h:1009
lyd_free_attr_single
LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free a single attribute.
lyd_diff_apply_module
LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff, const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data)
Apply the whole diff on a data tree but restrict the operation to one module.
lyd_attr::value
const char * value
Definition tree_data.h:750
lyd_dup_meta_single
LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup)
Create a copy of the metadata.
lyd_value_xpath10::ctx
const struct ly_ctx * ctx
Definition tree_data.h:714
lyd_unlink_tree
LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node)
Unlink the specified data subtree.
lyd_node_any::value
union lyd_any_value value
Definition tree_data.h:911
lyd_attr::next
struct lyd_attr * next
Definition tree_data.h:748
lyd_diff_apply_all
LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff)
Apply the whole diff tree on a data tree.
lyd_new_ext_any
LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node)
Create a new top-level any node defined in the given extension instance.
lyd_value_union::hints
uint32_t hints
Definition tree_data.h:627
lyd_new_ext_term
LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value, size_t value_len, uint32_t options, struct lyd_node **node)
Create a new top-level term node defined in the given extension instance.
lyd_value_date_and_time::fractions_s
char * fractions_s
Definition tree_data.h:705
lyd_eval_xpath2
LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
lyd_value_ipv6_prefix::addr
struct in6_addr addr
Definition tree_data.h:696
lyd_value_union::orig_len
size_t orig_len
Definition tree_data.h:626
lyd_value_union::value
struct lyd_value value
Definition tree_data.h:623
lyd_value::_canonical
const char * _canonical
Definition tree_data.h:568
lyd_attr::parent
struct lyd_node_opaq * parent
Definition tree_data.h:747
lyd_value_xpath10::prefix_data
void * prefix_data
Definition tree_data.h:715
lyd_value_union::format
LY_VALUE_FORMAT format
Definition tree_data.h:628
lyd_merge_module
LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod, lyd_merge_cb merge_cb, void *cb_data, uint16_t options)
Merge all the nodes of a module from source data tree into the target data tree. Merge may not be com...
lyd_new_term_bin
LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, size_t value_len, uint32_t options, struct lyd_node **node)
Create a new term node in the data tree based on binary value.
lyd_node::parent
struct lyd_node_inner * parent
Definition tree_data.h:802
lyd_node_opaq::name
struct ly_opaq_name name
Definition tree_data.h:1006
lyd_free_meta_single
LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta)
Free a single metadata instance.
lyd_change_term_canon
LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str)
Change the value of a term (leaf or leaf-list) node to a canonical string value.
lyd_eval_xpath3
LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
lyd_insert_sibling
LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first)
Insert a node into siblings.
lyd_value_union::ctx_node
const struct lysc_node * ctx_node
Definition tree_data.h:632
lyd_any_value_str
LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str)
Get anydata string value.
lyd_new_opaq2
LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value, const char *prefix, const char *module_ns, struct lyd_node **node)
Create a new XML opaque node in the data tree. To create a JSON opaque node, use lyd_new_opaq().
ly_opaq_name
Generic prefix and namespace mapping, meaning depends on the format.
Definition tree_data.h:733
lyd_attr
Generic attribute structure.
Definition tree_data.h:746
lyd_leafref_links_rec
Structure of leafref links record.
Definition tree_data.h:1019
lyd_node
Generic structure for a data node.
Definition tree_data.h:795
lyd_node_any
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition tree_data.h:888
lyd_node_inner
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition tree_data.h:815
lyd_node_opaq
Data node structure for unparsed (opaque) nodes.
Definition tree_data.h:985
lyd_node_term
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition tree_data.h:847
lyd_value
YANG data representation.
Definition tree_data.h:567
lyd_value_binary
Special lyd_value structure for built-in binary values.
Definition tree_data.h:649
lyd_value_bits
Special lyd_value structure for built-in bits values.
Definition tree_data.h:638
lyd_value_date_and_time
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition tree_data.h:703
lyd_value_ipv4_address
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition tree_data.h:664
lyd_value_ipv4_address_no_zone
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition tree_data.h:657
lyd_value_ipv4_prefix
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition tree_data.h:672
lyd_value_ipv6_address
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition tree_data.h:687
lyd_value_ipv6_address_no_zone
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition tree_data.h:680
lyd_value_ipv6_prefix
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition tree_data.h:695
lyd_value_lyds_tree
Special lyd_value structure for lyds tree value.
Definition tree_data.h:722
lyd_value_union
Special lyd_value structure for built-in union values.
Definition tree_data.h:622
lyd_value_xpath10
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition tree_data.h:712
lyd_any_value
union for anydata/anyxml value representation.
Definition tree_data.h:876
tree_schema.h
libyang representation of YANG schema trees.