libyang 6.4.3
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
Loading...
Searching...
No Matches
tree_data.h
Go to the documentation of this file.
1
16#ifndef LY_TREE_DATA_H_
17#define LY_TREE_DATA_H_
18
19#include <stddef.h>
20#include <stdint.h>
21#include <time.h>
22
23#include "ly_config.h"
24#include "tree_schema.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30struct ly_ctx;
31struct ly_path;
32struct ly_set;
33struct lyd_node;
34struct lyd_node_opaq;
35struct lyd_node_term;
36struct timespec;
37struct lyxp_var;
38struct rb_node;
39
451/* *INDENT-OFF* */
452
478#define LYD_TREE_DFS_BEGIN(START, ELEM) \
479 { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
480 for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
481 (ELEM); \
482 (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
483
487#define _LYD_TREE_DFS_END(START, ELEM, FUNC) \
488 /* select element for the next run - children first */ \
489 if (LYD_TREE_DFS_continue) { \
490 (LYD_TREE_DFS_next) = NULL; \
491 } else { \
492 (LYD_TREE_DFS_next) = FUNC(ELEM); \
493 }\
494 if (!(LYD_TREE_DFS_next)) { \
495 /* no children */ \
496 if ((ELEM) == (struct lyd_node *)(START)) { \
497 /* we are done, (START) has no children */ \
498 break; \
499 } \
500 /* try siblings */ \
501 (LYD_TREE_DFS_next) = (ELEM)->next; \
502 } \
503 while (!(LYD_TREE_DFS_next)) { \
504 /* parent is already processed, go to its sibling */ \
505 (ELEM) = (struct lyd_node *)(ELEM)->parent; \
506 /* no siblings, go back through parents */ \
507 if ((ELEM)->parent == (START)->parent) { \
508 /* we are done, no next element to process */ \
509 break; \
510 } \
511 (LYD_TREE_DFS_next) = (ELEM)->next; \
512 } }
513
529#define LYD_TREE_DFS_END(START, ELEM) \
530 _LYD_TREE_DFS_END(START, ELEM, lyd_child)
531
547#define LYD_TREE_ANY_DFS_END(START, ELEM) \
548 _LYD_TREE_DFS_END(START, ELEM, lyd_child_any)
549
557#define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
558 for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
559 (ELEM) && ((ELEM)->schema == (SCHEMA)); \
560 (ELEM) = (ELEM)->next)
561
570#define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
571 for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
572 (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
573 (ELEM) = (NEXT))
574
575/* *INDENT-ON* */
576
580#define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
581
589#define LYD_NODE_IS_ALONE(NODE) \
590 (((NODE)->prev == NODE) || \
591 (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
592
604
610struct lyd_value {
611 const char *_canonical;
614 const struct lysc_type *realtype;
622 union {
623 int8_t boolean;
624 int64_t dec64;
625 int8_t int8;
626 int16_t int16;
627 int32_t int32;
628 int64_t int64;
629 uint8_t uint8;
630 uint16_t uint16;
631 uint32_t uint32;
632 uint64_t uint64;
633 struct lysc_type_bitenum_item *enum_item;
634 struct lysc_ident *ident;
635 struct ly_path *target;
637 struct lyd_value_union *subvalue;
639 void *dyn_mem;
640 uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
641 };
643};
644
653#define LYD_VALUE_GET(value, type_val) \
654 ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
655 ? ((type_val) = (((value)->dyn_mem))) \
656 : ((type_val) = ((void *)((value)->fixed_mem))))
657
677
688
693 void *data;
694 uint32_t size;
695};
696
701 struct in_addr addr;
702};
703
708 struct in_addr addr;
709 const char *zone;
710};
711
716 struct in_addr addr;
717 uint8_t prefix;
718};
719
724 struct in6_addr addr;
725};
726
731 struct in6_addr addr;
732 const char *zone;
733};
734
739 struct in6_addr addr;
740 uint8_t prefix;
741};
742
751
759
764 time_t time;
765};
766
775
780 uint32_t seconds;
782};
783
788 struct lyxp_expr *exp;
789 const struct ly_ctx *ctx;
792};
793
798 struct rb_node *rbt;
799};
800
809 const char *name;
810 const char *prefix;
812 union {
813 const char *module_ns;
814 const char *module_name;
815 };
816};
817
830
831#define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
832#define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
833#define LYD_NODE_ANY (LYS_ANYDATA)
862#define LYD_DEFAULT 0x01
863#define LYD_WHEN_TRUE 0x02
864#define LYD_NEW 0x04
865#define LYD_EXT 0x08
866#define LYD_WHEN_FALSE 0x10
875struct lyd_node {
876 uint32_t hash;
880 uint32_t flags;
881 const struct lysc_node *schema;
882 struct lyd_node *parent;
883 struct lyd_node *next;
884 struct lyd_node *prev;
888 struct lyd_meta *meta;
889 void *priv;
890};
891
896 union {
897 struct lyd_node node;
899 struct {
900 uint32_t hash;
905 uint32_t flags;
906 const struct lysc_node *schema;
907 struct lyd_node *parent;
908 struct lyd_node *next;
909 struct lyd_node *prev;
913 struct lyd_meta *meta;
914 void *priv;
915 };
916 };
918 struct lyd_node *child;
921#define LYD_HT_MIN_ITEMS 4
922};
923
928 union {
929 struct lyd_node node;
931 struct {
932 uint32_t hash;
937 uint32_t flags;
938 const struct lysc_node *schema;
939 struct lyd_node *parent;
940 struct lyd_node *next;
941 struct lyd_node *prev;
945 struct lyd_meta *meta;
946 void *priv;
947 };
948 };
951};
952
957 union {
958 struct lyd_node node;
960 struct {
961 uint32_t hash;
966 uint32_t flags;
967 const struct lysc_node *schema;
968 struct lyd_node *parent;
969 struct lyd_node *next;
970 struct lyd_node *prev;
974 struct lyd_meta *meta;
975 void *priv;
976 };
977 };
979 struct lyd_node *child;
981 const char *value;
982 uint32_t hints;
984};
985
992#define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
993
1003#define LYD_VALHINT_STRING 0x0001
1004#define LYD_VALHINT_DECNUM 0x0002
1005#define LYD_VALHINT_OCTNUM 0x0004
1006#define LYD_VALHINT_HEXNUM 0x0008
1007#define LYD_VALHINT_NUM64 0x0010
1008#define LYD_VALHINT_BOOLEAN 0x0020
1009#define LYD_VALHINT_EMPTY 0x0040
1010#define LYD_VALHINT_STRING_DATATYPES 0x0080
1024#define LYD_NODEHINT_LIST 0x1000
1025#define LYD_NODEHINT_LEAFLIST 0x2000
1026#define LYD_NODEHINT_CONTAINER 0x4000
1041#define LYD_HINT_DATA 0xFFF3
1045#define LYD_HINT_SCHEMA 0xFFFF
1057 union {
1058 struct lyd_node node;
1060 struct {
1061 uint32_t hash;
1062 uint32_t flags;
1063 const struct lysc_node *schema;
1064 struct lyd_node *parent;
1065 struct lyd_node *next;
1066 struct lyd_node *prev;
1070 struct lyd_meta *meta;
1071 void *priv;
1072 };
1073 };
1075 struct lyd_node *child;
1078 const char *value;
1079 uint32_t hints;
1083 struct lyd_attr *attr;
1084 const struct ly_ctx *ctx;
1085};
1086
1102
1110#define lyd_parent(node) ((node) ? (node)->parent : NULL)
1111
1123static inline struct lyd_node *
1124lyd_child(const struct lyd_node *node)
1125{
1126 if (!node) {
1127 return NULL;
1128 }
1129
1130 if (!node->schema) {
1131 /* opaq node */
1132 return ((const struct lyd_node_opaq *)node)->child;
1133 }
1134
1136 return ((const struct lyd_node_inner *)node)->child;
1137 }
1138
1139 return NULL;
1140}
1141
1153static inline struct lyd_node *
1154lyd_child_any(const struct lyd_node *node)
1155{
1156 if (!node) {
1157 return NULL;
1158 }
1159
1160 if (!node->schema) {
1161 /* opaq node */
1162 return ((const struct lyd_node_opaq *)node)->child;
1163 }
1164
1166 return ((const struct lyd_node_inner *)node)->child;
1167 }
1168
1169 return NULL;
1170}
1171
1180LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1181
1191LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1192
1199LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1200
1207LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1208
1216LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1217
1224LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1225
1235LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1236
1246LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1247
1254static inline const char *
1255lyd_get_value(const struct lyd_node *node)
1256{
1257 if (!node) {
1258 return NULL;
1259 }
1260
1261 if (!node->schema) {
1262 return ((const struct lyd_node_opaq *)node)->value;
1263 } else if (node->schema->nodetype & LYD_NODE_TERM) {
1264 const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1265
1267 }
1268
1269 return NULL;
1270}
1271
1280LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, LYD_FORMAT format, char **value_str);
1281
1293LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const struct lyd_node *child, const char *value,
1294 uint32_t hints);
1295
1302LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1303
1311LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
1312
1326LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1327 ly_bool output, struct lyd_node **node);
1328
1350#define LYD_NEW_VAL_OUTPUT 0x01
1352#define LYD_NEW_VAL_STORE_ONLY 0x02
1353#define LYD_NEW_VAL_CANON 0x04
1356#define LYD_NEW_META_CLEAR_DFLT 0x08
1357#define LYD_NEW_PATH_UPDATE 0x10
1361#define LYD_NEW_PATH_OPAQ 0x20
1365#define LYD_NEW_PATH_WITH_OPAQ 0x40
1366#define LYD_NEW_PATH_ANY_DATATREE 0x80
1367#define LYD_NEW_ANY_USE_VALUE 0x0100
1383LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1384 uint32_t options, struct lyd_node **node, ...);
1385
1399LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1400 const char *keys, uint32_t options, struct lyd_node **node);
1401
1415LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1416 const void **key_values, uint32_t *value_sizes_bits, uint32_t options, struct lyd_node **node);
1417
1429LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1430 const char *value, uint32_t options, struct lyd_node **node);
1431
1454LIBYANG_API_DECL LY_ERR lyd_new_term_raw_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
1455 const void *value_ptr, uint32_t value_size, const char *canon, uint32_t options, struct lyd_node **node);
1456
1460LIBYANG_API_DECL LY_ERR lyd_new_term_raw(struct lyd_node *parent, const struct lys_module *module, const char *name,
1461 const void *value_ptr, uint32_t value_size, uint32_t options, struct lyd_node **node) _DEPRECATED;
1462
1476LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1477 const struct lyd_node *child, const char *value, uint32_t hints, uint32_t options, struct lyd_node **node);
1478
1493LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1494 const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1495
1508LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1509 const struct lyd_attr *attr, struct lyd_meta **meta);
1510
1523LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1524 const char *prefix, const char *module_name, struct lyd_node **node);
1525
1538LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1539 const char *prefix, const char *module_ns, struct lyd_node **node);
1540
1554LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1555 struct lyd_attr **attr);
1556
1569LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1570 struct lyd_attr **attr);
1571
1600LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1601 uint32_t options, struct lyd_node **node);
1602
1628LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path,
1629 const void *value, uint64_t value_size_bits, uint32_t any_hints, uint32_t options, struct lyd_node **new_parent,
1630 struct lyd_node **new_node);
1631
1645#define LYD_IMPLICIT_NO_STATE 0x01
1646#define LYD_IMPLICIT_NO_CONFIG 0x02
1647#define LYD_IMPLICIT_OUTPUT 0x04
1648#define LYD_IMPLICIT_NO_DEFAULTS 0x08
1661LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1662
1674LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1675 struct lyd_node **diff);
1676
1688LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1689 uint32_t implicit_options, struct lyd_node **diff);
1690
1704LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1705
1720LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1721
1731LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1732
1744LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1745
1758LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1759
1771LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1772
1784LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1785
1793LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1794
1802LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1803
1809LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1810
1816LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1817
1823LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1824
1830LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1831
1837LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1838
1845LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1846
1853LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1854
1872LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct lysc_node *schema, const char *value, uint32_t value_len,
1873 const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1874
1892LIBYANG_API_DECL LY_ERR lyd_value_validate_dflt(const struct lysc_node *schema, const char *value,
1893 struct lysc_prefix *prefixes, const struct lyd_node *ctx_node, const struct lysc_type **realtype,
1894 const char **canonical);
1895
1908LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, uint32_t value_len);
1909
1916#define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1917 (subtree, so direct as well as indirect children) are the same. By default,
1918 containers are the same in case of the same schema node and lists are the same
1919 in case of equal keys (keyless lists do the full recursion comparison all the time). */
1920#define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1921 changes this behavior and implicit (automatically created default node) and explicit
1922 (explicitly created node with the default value) default nodes are considered different. */
1923#define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1924 opaque nodes members are compared to data node schema and value and can result
1925 in a match. */
1939LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1940
1952LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1953
1964LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1965
1978#define LYD_DUP_RECURSIVE 0x01
1980#define LYD_DUP_NO_META 0x02
1982#define LYD_DUP_WITH_PARENTS 0x04
1984#define LYD_DUP_WITH_FLAGS 0x08
1986#define LYD_DUP_NO_EXT 0x10
1987#define LYD_DUP_WITH_PRIV 0x20
1989#define LYD_DUP_NO_LYDS 0x40
2007LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
2008 struct lyd_node **dup);
2009
2023LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2024 struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
2025
2037LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
2038 struct lyd_node **dup);
2039
2054LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2055 struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
2056
2065LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
2066
2081#define LYD_MERGE_DESTRUCT 0x01
2082#define LYD_MERGE_DEFAULTS 0x02
2083#define LYD_MERGE_WITH_FLAGS 0x04
2107LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2108
2130LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2131
2141typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2142
2158LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2159 lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2160
2175#define LYD_DIFF_DEFAULTS 0x01
2178#define LYD_DIFF_META 0x02
2209LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2210 struct lyd_node **diff);
2211
2224LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2225 struct lyd_node **diff);
2226
2235typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2236
2253LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2254 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2255
2266LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2267
2279#define LYD_DIFF_MERGE_DEFAULTS 0x01
2307LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2308 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2309
2326LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2327 const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2328
2340LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2341
2351LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2352
2356typedef enum {
2357 LYD_PATH_STD,
2362
2378LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2379
2389LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2390 const char *name);
2391
2403LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2404 struct lyd_node **match);
2405
2430LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2431 const char *key_or_value, uint32_t val_len, struct lyd_node **match);
2432
2444LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2445 struct ly_set **set);
2446
2457LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2458
2470LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2471
2477LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2478
2498LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2499
2513LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2514 struct ly_set **set);
2515
2533LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2534 LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2535
2547LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2548
2561LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2562 const struct lyxp_var *vars, ly_bool *result);
2563
2579LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2580 const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2585typedef enum {
2591
2614LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2615 const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2616 const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2617 long double *number, ly_bool *boolean);
2618
2628LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2629
2647LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2648 struct lyd_node **match);
2649
2660LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2661
2672LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2673
2683LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2684
2685#ifdef __cplusplus
2686}
2687#endif
2688
2689#endif /* LY_TREE_DATA_H_ */
libyang context handler.
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition tree_data.h:597
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition tree_data.h:580
@ LYD_CBOR
Definition tree_data.h:602
@ LYD_LYB
Definition tree_data.h:601
@ LYD_XML
Definition tree_data.h:599
@ LYD_UNKNOWN
Definition tree_data.h:598
@ LYD_JSON
Definition tree_data.h:600
LY_ERR
libyang's error codes returned by the libyang functions.
Definition log.h:252
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node,...
Definition set.h:47
#define LYS_NOTIF
#define LYS_ANYDATA
#define LYS_RPC
#define LYS_CONTAINER
#define LYS_ACTION
#define LYS_LIST
uint16_t nodetype
struct lys_module *struct lysc_node * parent
const char * name
Available YANG schema tree structures representing YANG module.
YANG identity-stmt.
Compiled YANG data node.
Compiled prefix data pair mapping of prefixes to modules. In case the format is LY_VALUE_SCHEMA_RESOL...
uint8_t ly_bool
Type to indicate boolean value.
Definition log.h:36
const char * name
Definition metadata.h:40
struct lyd_value value
Definition metadata.h:41
Metadata structure.
Definition metadata.h:36
libyang hash table.
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
LY_VALUE_FORMAT format
Definition tree_data.h:827
uint64_t orig_size_bits
Definition tree_data.h:669
struct lyd_node * next
Definition tree_data.h:883
LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node)
Free all the nodes (even parents of the node) in the data tree.
uint32_t hints
Definition tree_data.h:982
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.
void * val_prefix_data
Definition tree_data.h:1081
LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node *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...
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...
LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const struct lyd_node *child, const char *value, uint32_t hints)
Copy anydata value from one node to another. Target value is freed first.
LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta)
Free the metadata instance with any following instances.
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.
const char * prefix
Definition tree_data.h:810
struct rb_node * rbt
Definition tree_data.h:798
struct in_addr addr
Definition tree_data.h:708
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,...
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.
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.
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
Types of the different data paths.
Definition tree_data.h:2349
@ LYD_PATH_STD_NO_LAST_PRED
Definition tree_data.h:2352
@ LYD_PATH_STD
Definition tree_data.h:2350
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.
struct lyd_value value
Definition tree_data.h:950
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.
const struct lysc_type * realtype
Definition tree_data.h:614
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str)
Change the value of a metadata instance.
uint32_t hints
Definition tree_data.h:826
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().
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.
ly_bool unknown_tz
Definition tree_data.h:757
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().
LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node)
Insert a child into a parent.
LIBYANG_API_DECL struct lyd_node * lyd_first_sibling(const struct lyd_node *node)
Get the first sibling of the given node.
const struct lyd_node_term ** leafref_nodes
Definition tree_data.h:1092
struct lyd_attr * attr
Definition tree_data.h:1083
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.
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.
LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct lysc_node *schema, const char *value, uint32_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.
LIBYANG_API_DECL LY_ERR lyd_value_validate_dflt(const struct lysc_node *schema, const char *value, struct lysc_prefix *prefixes, 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.
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:2228
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.
struct lyd_node * child
Definition tree_data.h:1075
LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2)
Compare 2 metadata.
LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node)
Free (and unlink) the specified data (sub)tree.
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.
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.
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.
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....
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.
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.
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, uint64_t value_size_bits, uint32_t any_hints, 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.
struct lysc_type_bitenum_item ** items
Definition tree_data.h:685
const struct ly_ctx * ctx
Definition tree_data.h:1084
char * fractions_s
Definition tree_data.h:772
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....
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.
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.
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.
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:2134
struct lyd_meta * meta
Definition tree_data.h:888
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.
LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, LYD_FORMAT format, char **value_str)
Get anydata string value.
const struct lyd_node_term ** target_nodes
Definition tree_data.h:1098
uint32_t flags
Definition tree_data.h:880
LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta)
Check whether metadata are not an instance of internal metadata.
LY_XPATH_TYPE
XPath result type.
Definition tree_data.h:2578
@ LY_XPATH_NODE_SET
Definition tree_data.h:2579
@ LY_XPATH_NUMBER
Definition tree_data.h:2581
@ LY_XPATH_STRING
Definition tree_data.h:2580
@ LY_XPATH_BOOLEAN
Definition tree_data.h:2582
const struct lysc_node * schema
Definition tree_data.h:881
uint32_t seconds
Definition tree_data.h:771
struct in6_addr addr
Definition tree_data.h:731
const char * value
Definition tree_data.h:981
LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node)
Unlink the specified node with all the following siblings.
LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node)
Free all the sibling nodes (preceding as well as succeeding).
struct lyxp_expr * exp
Definition tree_data.h:788
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.
const char * value
Definition tree_data.h:1078
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.
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.
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...
LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name, const void **key_values, uint32_t *value_sizes_bits, uint32_t options, struct lyd_node **node)
Create a new list node in the data tree.
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.
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.
struct lyd_node * parent
Definition tree_data.h:882
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.
const char * name
Definition tree_data.h:809
void * prefix_data
Definition tree_data.h:674
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.
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.
const struct lyd_node_term * node
Definition tree_data.h:1091
#define LYD_NODE_TERM
Definition tree_data.h:832
uint32_t hints
Definition tree_data.h:1079
LIBYANG_API_DECL LY_ERR lyd_new_term_raw_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value_ptr, uint32_t value_size, const char *canon, uint32_t options, struct lyd_node **node)
Create a new term node in the data tree and set its value directly in its internal raw representation...
LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are kept the same.
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...
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...
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,...
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.
struct ly_opaq_name name
Definition tree_data.h:824
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.
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.
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...
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().
uint32_t hash
Definition tree_data.h:876
void * val_prefix_data
Definition tree_data.h:828
struct in_addr addr
Definition tree_data.h:716
struct lyd_node * prev
Definition tree_data.h:884
ly_bool unknown_tz
Definition tree_data.h:773
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.
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.
LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node *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...
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....
struct lyd_node * child
Definition tree_data.h:918
struct ly_ht * children_ht
Definition tree_data.h:980
LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free the attribute with any following attributes.
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.
LY_VALUE_FORMAT format
Definition tree_data.h:791
void * priv
Definition tree_data.h:889
LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node)
Check whether a node value equals to its default one.
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.
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.
struct ly_ht * children_ht
Definition tree_data.h:919
LY_VALUE_FORMAT format
Definition tree_data.h:1080
LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free a single attribute.
struct lyd_node * child
Definition tree_data.h:979
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.
const char * value
Definition tree_data.h:825
LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value, uint32_t val_len, struct lyd_node **match)
Search in the given siblings for the first schema instance. Uses hashes - should be used whenever pos...
LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, uint32_t value_len)
Compare the node's value with the given string value. The string value is first validated according t...
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.
const struct ly_ctx * ctx
Definition tree_data.h:789
LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node)
Unlink the specified data subtree.
struct lyd_attr * next
Definition tree_data.h:823
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.
uint32_t hints
Definition tree_data.h:670
LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are assigned from trg_ctx.
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.
struct in6_addr addr
Definition tree_data.h:739
struct lyd_value value
Definition tree_data.h:666
const char * _canonical
Definition tree_data.h:611
struct lyd_node_opaq * parent
Definition tree_data.h:822
LY_VALUE_FORMAT format
Definition tree_data.h:671
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...
LIBYANG_API_DECL LY_ERR lyd_new_term_raw(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value_ptr, uint32_t value_size, uint32_t options, struct lyd_node **node) _DEPRECATED
Deprecated, use lyd_new_term_raw_canon() instead. Produces nodes without canonical values.
struct ly_opaq_name name
Definition tree_data.h:1077
LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta)
Free a single metadata instance.
LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const struct lyd_node *child, const char *value, uint32_t hints, uint32_t options, struct lyd_node **node)
Create a new any node in the data tree.
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.
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.
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.
const struct lysc_node * ctx_node
Definition tree_data.h:675
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().
Generic prefix and namespace mapping, meaning depends on the format.
Definition tree_data.h:808
Generic attribute structure.
Definition tree_data.h:821
Generic structure for a data node.
Definition tree_data.h:875
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition tree_data.h:956
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition tree_data.h:895
Data node structure for unparsed (opaque) nodes.
Definition tree_data.h:1056
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition tree_data.h:927
YANG data representation.
Definition tree_data.h:610
Special lyd_value structure for built-in binary values.
Definition tree_data.h:692
Special lyd_value structure for built-in bits values.
Definition tree_data.h:681
Special lyd_value structure for ietf-yang-types date values.
Definition tree_data.h:755
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition tree_data.h:746
Special lyd_value structure for ietf-yang-types date-no-zone values.
Definition tree_data.h:763
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition tree_data.h:707
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition tree_data.h:700
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition tree_data.h:715
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition tree_data.h:730
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition tree_data.h:723
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition tree_data.h:738
Special lyd_value structure for lyds tree value.
Definition tree_data.h:797
Special lyd_value structure for ietf-yang-types time values.
Definition tree_data.h:770
Special lyd_value structure for ietf-yang-types time-no-zone values.
Definition tree_data.h:779
Special lyd_value structure for built-in union values.
Definition tree_data.h:665
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition tree_data.h:787
libyang representation of YANG schema trees.
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition utils.h:93