libyang 5.0.2
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
15
16#ifndef LY_TREE_DATA_H_
17#define LY_TREE_DATA_H_
18
19/* socket/ip includes in ly_config.h */
20
21#include <stddef.h>
22#include <stdint.h>
23#include <time.h>
24
25#include "log.h"
26#include "ly_config.h"
27#include "tree.h"
28#include "tree_schema.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34struct ly_ctx;
35struct ly_path;
36struct ly_set;
37struct lyd_node;
38struct lyd_node_opaq;
39struct lyd_node_term;
40struct timespec;
41struct lyxp_var;
42struct rb_node;
43
196
314
367
379
387
388/* *INDENT-OFF* */
389
415#define LYD_TREE_DFS_BEGIN(START, ELEM) \
416 { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
417 for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
418 (ELEM); \
419 (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
420
436#define LYD_TREE_DFS_END(START, ELEM) \
437 /* select element for the next run - children first */ \
438 if (LYD_TREE_DFS_continue) { \
439 (LYD_TREE_DFS_next) = NULL; \
440 } else { \
441 (LYD_TREE_DFS_next) = lyd_child(ELEM); \
442 }\
443 if (!(LYD_TREE_DFS_next)) { \
444 /* no children */ \
445 if ((ELEM) == (struct lyd_node *)(START)) { \
446 /* we are done, (START) has no children */ \
447 break; \
448 } \
449 /* try siblings */ \
450 (LYD_TREE_DFS_next) = (ELEM)->next; \
451 } \
452 while (!(LYD_TREE_DFS_next)) { \
453 /* parent is already processed, go to its sibling */ \
454 (ELEM) = (struct lyd_node *)(ELEM)->parent; \
455 /* no siblings, go back through parents */ \
456 if ((ELEM)->parent == (START)->parent) { \
457 /* we are done, no next element to process */ \
458 break; \
459 } \
460 (LYD_TREE_DFS_next) = (ELEM)->next; \
461 } }
462
470#define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
471 for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
472 (ELEM) && ((ELEM)->schema == (SCHEMA)); \
473 (ELEM) = (ELEM)->next)
474
483#define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
484 for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
485 (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
486 (ELEM) = (NEXT))
487
488/* *INDENT-ON* */
489
493#define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
494
502#define LYD_NODE_IS_ALONE(NODE) \
503 (((NODE)->prev == NODE) || \
504 (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
505
516
531
533
537struct lyd_value {
538 const char *_canonical;
541 const struct lysc_type *realtype;
548
549 union {
550 int8_t boolean;
551 int64_t dec64;
552 int8_t int8;
553 int16_t int16;
554 int32_t int32;
555 int64_t int64;
556 uint8_t uint8;
557 uint16_t uint16;
558 uint32_t uint32;
559 uint64_t uint64;
561 struct lysc_ident *ident;
562 struct ly_path *target;
564 struct lyd_value_union *subvalue;
565
566 void *dyn_mem;
567 uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
568 };
569
570};
571
580#define LYD_VALUE_GET(value, type_val) \
581 ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
582 ? ((type_val) = (((value)->dyn_mem))) \
583 : ((type_val) = ((void *)((value)->fixed_mem))))
584
604
615
620 void *data;
621 uint32_t size;
622};
623
628 struct in_addr addr;
629};
630
635 struct in_addr addr;
636 const char *zone;
637};
638
643 struct in_addr addr;
644 uint8_t prefix;
645};
646
651 struct in6_addr addr;
652};
653
658 struct in6_addr addr;
659 const char *zone;
660};
661
666 struct in6_addr addr;
667 uint8_t prefix;
668};
669
678
686
691 time_t time;
692};
693
702
707 uint32_t seconds;
709};
710
715 struct lyxp_expr *exp;
716 const struct ly_ctx *ctx;
719};
720
725 struct rb_node *rbt;
726};
727
736 const char *name;
737 const char *prefix;
738
739 union {
740 const char *module_ns;
741 const char *module_name;
742 };
743};
744
757
758#define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
759#define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
760#define LYD_NODE_ANY (LYS_ANYDATA)
761
786
787#define LYD_DEFAULT 0x01
788#define LYD_WHEN_TRUE 0x02
789#define LYD_NEW 0x04
790#define LYD_EXT 0x08
791
793
797struct lyd_node {
798 uint32_t hash;
802 uint32_t flags;
803 const struct lysc_node *schema;
804 struct lyd_node *parent;
805 struct lyd_node *next;
806 struct lyd_node *prev;
810 struct lyd_meta *meta;
811 void *priv;
812};
813
818 union {
819 struct lyd_node node;
820
821 struct {
822 uint32_t hash;
827 uint32_t flags;
828 const struct lysc_node *schema;
829 struct lyd_node *parent;
830 struct lyd_node *next;
831 struct lyd_node *prev;
835 struct lyd_meta *meta;
836 void *priv;
837 };
838 };
839
840 struct lyd_node *child;
842
843#define LYD_HT_MIN_ITEMS 4
844};
845
850 union {
851 struct lyd_node node;
852
853 struct {
854 uint32_t hash;
859 uint32_t flags;
860 const struct lysc_node *schema;
861 struct lyd_node *parent;
862 struct lyd_node *next;
863 struct lyd_node *prev;
867 struct lyd_meta *meta;
868 void *priv;
869 };
870 };
871
873};
874
879 union {
880 struct lyd_node node;
881
882 struct {
883 uint32_t hash;
888 uint32_t flags;
889 const struct lysc_node *schema;
890 struct lyd_node *parent;
891 struct lyd_node *next;
892 struct lyd_node *prev;
896 struct lyd_meta *meta;
897 void *priv;
898 };
899 };
900
901 struct lyd_node *child;
903 const char *value;
905};
906
913#define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
914
924#define LYD_VALHINT_STRING 0x0001
925#define LYD_VALHINT_DECNUM 0x0002
926#define LYD_VALHINT_OCTNUM 0x0004
927#define LYD_VALHINT_HEXNUM 0x0008
928#define LYD_VALHINT_NUM64 0x0010
929#define LYD_VALHINT_BOOLEAN 0x0020
930#define LYD_VALHINT_EMPTY 0x0040
931#define LYD_VALHINT_STRING_DATATYPES 0x0080
935
945#define LYD_NODEHINT_LIST 0x0080
946#define LYD_NODEHINT_LEAFLIST 0x0100
947#define LYD_NODEHINT_CONTAINER 0x0200
951
962#define LYD_HINT_DATA 0x03F3
966#define LYD_HINT_SCHEMA 0x03FF
973
978 union {
979 struct lyd_node node;
980
981 struct {
982 uint32_t hash;
983 uint32_t flags;
984 const struct lysc_node *schema;
985 struct lyd_node *parent;
986 struct lyd_node *next;
987 struct lyd_node *prev;
991 struct lyd_meta *meta;
992 void *priv;
993 };
994 };
995
996 struct lyd_node *child;
997
999 const char *value;
1000 uint32_t hints;
1003
1004 struct lyd_attr *attr;
1005 const struct ly_ctx *ctx;
1006};
1007
1023
1031#define lyd_parent(node) ((node) ? (node)->parent : NULL)
1032
1044static inline struct lyd_node *
1045lyd_child(const struct lyd_node *node)
1046{
1047 if (!node) {
1048 return NULL;
1049 }
1050
1051 if (!node->schema) {
1052 /* opaq node */
1053 return ((const struct lyd_node_opaq *)node)->child;
1054 }
1055
1057 return ((const struct lyd_node_inner *)node)->child;
1058 }
1059
1060 return NULL;
1061}
1062
1074static inline struct lyd_node *
1075lyd_child_any(const struct lyd_node *node)
1076{
1077 if (!node) {
1078 return NULL;
1079 }
1080
1081 if (!node->schema) {
1082 /* opaq node */
1083 return ((const struct lyd_node_opaq *)node)->child;
1084 }
1085
1087 return ((const struct lyd_node_inner *)node)->child;
1088 }
1089
1090 return NULL;
1091}
1092
1101LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1102
1112LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1113
1120LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1121
1128LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1129
1137LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1138
1145LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1146
1156LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1157
1167LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1168
1175static inline const char *
1176lyd_get_value(const struct lyd_node *node)
1177{
1178 if (!node) {
1179 return NULL;
1180 }
1181
1182 if (!node->schema) {
1183 return ((const struct lyd_node_opaq *)node)->value;
1184 } else if (node->schema->nodetype & LYD_NODE_TERM) {
1185 const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1186
1188 }
1189
1190 return NULL;
1191}
1192
1200LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1201
1210LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const void *value, LYD_ANYDATA_VALUETYPE value_type);
1211
1218LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1219
1227LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
1228
1242LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1243 ly_bool output, struct lyd_node **node);
1244
1265
1266#define LYD_NEW_VAL_OUTPUT 0x01
1268#define LYD_NEW_VAL_STORE_ONLY 0x02
1269#define LYD_NEW_VAL_BIN 0x04
1271#define LYD_NEW_VAL_CANON 0x08
1274#define LYD_NEW_META_CLEAR_DFLT 0x10
1275#define LYD_NEW_PATH_UPDATE 0x20
1279#define LYD_NEW_PATH_OPAQ 0x40
1283#define LYD_NEW_PATH_WITH_OPAQ 0x80
1284#define LYD_NEW_ANY_USE_VALUE 0x100
1285
1287
1301LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1302 uint32_t options, struct lyd_node **node, ...);
1303
1317LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1318 const char *keys, uint32_t options, struct lyd_node **node);
1319
1333LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1334 const void **key_values, uint32_t *value_sizes_bits, uint32_t options, struct lyd_node **node);
1335
1349LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1350 const char *value, uint32_t options, struct lyd_node **node);
1351
1364LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1365 const void *value, uint32_t value_size_bits, uint32_t options, struct lyd_node **node);
1366
1379LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1380 const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1381
1396LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1397 const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1398
1411LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1412 const struct lyd_attr *attr, struct lyd_meta **meta);
1413
1426LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1427 const char *prefix, const char *module_name, struct lyd_node **node);
1428
1441LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1442 const char *prefix, const char *module_ns, struct lyd_node **node);
1443
1457LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1458 struct lyd_attr **attr);
1459
1472LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1473 struct lyd_attr **attr);
1474
1503LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1504 uint32_t options, struct lyd_node **node);
1505
1530LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1531 uint32_t value_size_bits, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1532 struct lyd_node **new_node);
1533
1546
1547#define LYD_IMPLICIT_NO_STATE 0x01
1548#define LYD_IMPLICIT_NO_CONFIG 0x02
1549#define LYD_IMPLICIT_OUTPUT 0x04
1550#define LYD_IMPLICIT_NO_DEFAULTS 0x08
1552
1554
1563LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1564
1576LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1577 struct lyd_node **diff);
1578
1590LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1591 uint32_t implicit_options, struct lyd_node **diff);
1592
1606LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1607
1622LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, uint32_t value_size_bits);
1623
1638LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1639
1649LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1650
1662LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1663
1676LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1677
1689LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1690
1702LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1703
1711LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1712
1720LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1721
1727LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1728
1734LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1735
1741LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1742
1748LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1749
1755LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1756
1763LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1764
1771LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1772
1790LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct lysc_node *schema, const char *value, uint32_t value_len,
1791 const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1792
1810LIBYANG_API_DECL LY_ERR lyd_value_validate_dflt(const struct lysc_node *schema, const char *value,
1811 struct lysc_prefix *prefixes, const struct lyd_node *ctx_node, const struct lysc_type **realtype,
1812 const char **canonical);
1813
1826LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, uint32_t value_len);
1827
1834#define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1835 (subtree, so direct as well as indirect children) are the same. By default,
1836 containers are the same in case of the same schema node and lists are the same
1837 in case of equal keys (keyless lists do the full recursion comparison all the time). */
1838#define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1839 changes this behavior and implicit (automatically created default node) and explicit
1840 (explicitly created node with the default value) default nodes are considered different. */
1841#define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1842 opaque nodes members are compared to data node schema and value and can result
1843 in a match. */
1845
1857LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1858
1870LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1871
1882LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1883
1896#define LYD_DUP_RECURSIVE 0x01
1898#define LYD_DUP_NO_META 0x02
1900#define LYD_DUP_WITH_PARENTS 0x04
1902#define LYD_DUP_WITH_FLAGS 0x08
1904#define LYD_DUP_NO_EXT 0x10
1905#define LYD_DUP_WITH_PRIV 0x20
1907#define LYD_DUP_NO_LYDS 0x40
1911
1913
1925LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
1926 struct lyd_node **dup);
1927
1941LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1942 struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
1943
1955LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
1956 struct lyd_node **dup);
1957
1972LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1973 struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
1974
1983LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
1984
1998
1999#define LYD_MERGE_DESTRUCT 0x01
2000#define LYD_MERGE_DEFAULTS 0x02
2001#define LYD_MERGE_WITH_FLAGS 0x04
2002
2004
2025LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2026
2048LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2049
2059typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2060
2076LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2077 lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2078
2092
2093#define LYD_DIFF_DEFAULTS 0x01
2096#define LYD_DIFF_META 0x02
2099
2101
2127LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2128 struct lyd_node **diff);
2129
2142LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2143 struct lyd_node **diff);
2144
2153typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2154
2171LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2172 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2173
2184LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2185
2196
2197#define LYD_DIFF_MERGE_DEFAULTS 0x01
2198
2200
2225LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2226 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2227
2244LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2245 const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2246
2258LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2259
2267 * @return LY_ERR on error.
2269LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2273
2274typedef enum {
2275 LYD_PATH_STD,
2280
2296LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2297
2307LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2308 const char *name);
2309
2321LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2322 struct lyd_node **match);
2323
2348LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2349 const char *key_or_value, uint32_t val_len, struct lyd_node **match);
2350
2362LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2363 struct ly_set **set);
2364
2375LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2376
2388LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2389
2395LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2396
2416LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2417
2431LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2432 struct ly_set **set);
2433
2451LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2452 LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2453
2465LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2466
2479LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2480 const struct lyxp_var *vars, ly_bool *result);
2481
2497LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2498 const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2502
2503typedef enum {
2509
2532LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2533 const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2534 const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2535 long double *number, ly_bool *boolean);
2536
2546LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2547
2565LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2566 struct lyd_node **match);
2567
2578LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2579
2585LIBYANG_API_DECL int ly_time_tz_offset(void);
2593LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
2594
2603LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2604
2613LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2614
2622LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2623
2631LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2632
2643LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2644
2654LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2655
2669LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
2670 uint32_t str_len, void **pat_comp);
2671
2681LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, void **pat_comp);
2682
2688LIBYANG_API_DECL void ly_pattern_free(void *pat_comp);
2689
2690#ifdef __cplusplus
2691}
2692#endif
2693
2694#endif /* LY_TREE_DATA_H_ */
libyang context handler.
LYD_ANYDATA_VALUETYPE
List of possible value types stored in lyd_node_any.
Definition tree_data.h:520
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition tree_data.h:510
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition tree_data.h:493
@ LYD_ANYDATA_DATATREE
Definition tree_data.h:521
@ LYD_ANYDATA_JSON
Definition tree_data.h:529
@ LYD_ANYDATA_XML
Definition tree_data.h:528
@ LYD_ANYDATA_STRING
Definition tree_data.h:525
@ LYD_LYB
Definition tree_data.h:514
@ LYD_XML
Definition tree_data.h:512
@ LYD_UNKNOWN
Definition tree_data.h:511
@ LYD_JSON
Definition tree_data.h:513
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 * 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...
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition tree.h:234
Logger manipulation routines and error definitions.
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 generic macros and functions to work with YANG schema or data trees.
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
LY_VALUE_FORMAT format
Definition tree_data.h:754
struct lyd_node * next
Definition tree_data.h:805
LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node)
Free all the nodes (even parents of the node) in the data tree.
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:1002
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 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:737
struct rb_node * rbt
Definition tree_data.h:725
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str)
Convert timespec into date-and-time string value.
struct in_addr addr
Definition tree_data.h:635
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.
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:2267
@ LYD_PATH_STD_NO_LAST_PRED
Definition tree_data.h:2270
@ LYD_PATH_STD
Definition tree_data.h:2268
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:872
LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, uint32_t value_size_bits, uint32_t options, struct lyd_node **node)
Create a new term node in the data tree based on binary value.
LIBYANG_API_DECL int ly_time_tz_offset(void)
Get current timezone (including DST setting) UTC (GMT) time offset in seconds.
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:541
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str)
Change the value of a metadata instance.
LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts)
Convert date-and-time from string to timespec.
uint32_t hints
Definition tree_data.h:753
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.
LYD_ANYDATA_VALUETYPE value_type
Definition tree_data.h:904
ly_bool unknown_tz
Definition tree_data.h:684
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:1013
struct lyd_attr * attr
Definition tree_data.h:1004
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:2146
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:996
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....
struct ly_path * target
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.
struct lysc_type_bitenum_item ** items
Definition tree_data.h:612
const struct ly_ctx * ctx
Definition tree_data.h:1005
char * fractions_s
Definition tree_data.h:699
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.
uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE]
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:2052
struct lyd_meta * meta
Definition tree_data.h:810
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.
const struct lyd_node_term ** target_nodes
Definition tree_data.h:1019
uint32_t flags
Definition tree_data.h:802
struct lysc_ident * ident
LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta)
Check whether metadata are not an instance of internal metadata.
LIBYANG_API_DECL void ly_pattern_free(void *pat_comp)
Free a compiled XML Schema regex pattern.
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
XPath result type.
Definition tree_data.h:2496
@ LY_XPATH_NODE_SET
Definition tree_data.h:2497
@ LY_XPATH_NUMBER
Definition tree_data.h:2499
@ LY_XPATH_STRING
Definition tree_data.h:2498
@ LY_XPATH_BOOLEAN
Definition tree_data.h:2500
const struct lysc_node * schema
Definition tree_data.h:803
uint32_t seconds
Definition tree_data.h:698
struct in6_addr addr
Definition tree_data.h:658
const char * value
Definition tree_data.h:903
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:715
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:999
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:804
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:736
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).
LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const void *value, LYD_ANYDATA_VALUETYPE value_type)
Copy anydata value from one node to another. Target value is freed first.
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, uint32_t value_size_bits, 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.
void * prefix_data
Definition tree_data.h:601
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_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.
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:1012
#define LYD_NODE_TERM
Definition tree_data.h:759
uint32_t hints
Definition tree_data.h:1000
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:751
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 LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, uint32_t value_size_bits)
Change the value of a term (leaf or leaf-list) node to a binary value.
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:798
void * val_prefix_data
Definition tree_data.h:755
struct in_addr addr
Definition tree_data.h:643
struct lyd_node * prev
Definition tree_data.h:806
ly_bool unknown_tz
Definition tree_data.h:700
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:840
struct ly_ht * children_ht
Definition tree_data.h:902
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:718
void * priv
Definition tree_data.h:811
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 lyd_value_union * subvalue
uint32_t orig_size_bits
Definition tree_data.h:596
struct ly_ht * children_ht
Definition tree_data.h:841
LY_VALUE_FORMAT format
Definition tree_data.h:1001
LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free a single attribute.
struct lysc_type_bitenum_item * enum_item
struct lyd_node * child
Definition tree_data.h:901
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:752
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:716
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:750
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:597
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:666
struct lyd_value value
Definition tree_data.h:593
const char * _canonical
Definition tree_data.h:538
struct lyd_node_opaq * parent
Definition tree_data.h:749
LY_VALUE_FORMAT format
Definition tree_data.h:598
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 ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string, uint32_t str_len, void **pat_comp)
Check a string matches an XML Schema regex used in YANG.
struct ly_opaq_name name
Definition tree_data.h:998
LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, void **pat_comp)
Compile an XML Schema regex pattern prior to matching.
LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta)
Free a single metadata instance.
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:602
LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str)
Get anydata string value.
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:735
Generic attribute structure.
Definition tree_data.h:748
Generic structure for a data node.
Definition tree_data.h:797
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition tree_data.h:878
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition tree_data.h:817
Data node structure for unparsed (opaque) nodes.
Definition tree_data.h:977
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition tree_data.h:849
YANG data representation.
Definition tree_data.h:537
Special lyd_value structure for built-in binary values.
Definition tree_data.h:619
Special lyd_value structure for built-in bits values.
Definition tree_data.h:608
Special lyd_value structure for ietf-yang-types date values.
Definition tree_data.h:682
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition tree_data.h:673
Special lyd_value structure for ietf-yang-types date-no-zone values.
Definition tree_data.h:690
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition tree_data.h:634
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition tree_data.h:627
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition tree_data.h:642
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition tree_data.h:657
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition tree_data.h:650
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition tree_data.h:665
Special lyd_value structure for lyds tree value.
Definition tree_data.h:724
Special lyd_value structure for ietf-yang-types time values.
Definition tree_data.h:697
Special lyd_value structure for ietf-yang-types time-no-zone values.
Definition tree_data.h:706
Special lyd_value structure for built-in union values.
Definition tree_data.h:592
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition tree_data.h:714
libyang representation of YANG schema trees.