libyang 4.3.4
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#define PCRE2_CODE_UNIT_WIDTH 8
22
23#include <pcre2.h>
24#include <stddef.h>
25#include <stdint.h>
26#include <time.h>
27
28#include "log.h"
29#include "ly_config.h"
30#include "tree.h"
31#include "tree_schema.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37struct ly_ctx;
38struct ly_path;
39struct ly_set;
40struct lyd_node;
41struct lyd_node_opaq;
42struct lyd_node_term;
43struct timespec;
44struct lyxp_var;
45struct rb_node;
46
211
341
394
406
414
415/* *INDENT-OFF* */
416
442#define LYD_TREE_DFS_BEGIN(START, ELEM) \
443 { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
444 for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
445 (ELEM); \
446 (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
447
461
462#define LYD_TREE_DFS_END(START, ELEM) \
463 /* select element for the next run - children first */ \
464 if (LYD_TREE_DFS_continue) { \
465 (LYD_TREE_DFS_next) = NULL; \
466 } else { \
467 (LYD_TREE_DFS_next) = lyd_child(ELEM); \
468 }\
469 if (!(LYD_TREE_DFS_next)) { \
470 /* no children */ \
471 if ((ELEM) == (struct lyd_node *)(START)) { \
472 /* we are done, (START) has no children */ \
473 break; \
474 } \
475 /* try siblings */ \
476 (LYD_TREE_DFS_next) = (ELEM)->next; \
477 } \
478 while (!(LYD_TREE_DFS_next)) { \
479 /* parent is already processed, go to its sibling */ \
480 (ELEM) = (struct lyd_node *)(ELEM)->parent; \
481 /* no siblings, go back through parents */ \
482 if ((ELEM)->parent == (START)->parent) { \
483 /* we are done, no next element to process */ \
484 break; \
485 } \
486 (LYD_TREE_DFS_next) = (ELEM)->next; \
487 } }
488
496#define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
497 for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
498 (ELEM) && ((ELEM)->schema == (SCHEMA)); \
499 (ELEM) = (ELEM)->next)
500
509#define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
510 for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
511 (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
512 (ELEM) = (NEXT))
513
514/* *INDENT-ON* */
515
519#define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
520
528#define LYD_NODE_IS_ALONE(NODE) \
529 (((NODE)->prev == NODE) || \
530 (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
531
542
557
559
563struct lyd_value {
564 const char *_canonical;
567 const struct lysc_type *realtype;
574
575 union {
576 int8_t boolean;
577 int64_t dec64;
578 int8_t int8;
579 int16_t int16;
580 int32_t int32;
581 int64_t int64;
582 uint8_t uint8;
583 uint16_t uint16;
584 uint32_t uint32;
585 uint64_t uint64;
587 struct lysc_ident *ident;
588 struct ly_path *target;
590 struct lyd_value_union *subvalue;
591
592 void *dyn_mem;
593 uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
594 };
595
596};
597
606#define LYD_VALUE_GET(value, type_val) \
607 ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
608 ? ((type_val) = (((value)->dyn_mem))) \
609 : ((type_val) = ((void *)((value)->fixed_mem))))
610
631
642
647 void *data;
648 uint32_t size;
649};
650
655 struct in_addr addr;
656};
657
662 struct in_addr addr;
663 const char *zone;
664};
665
670 struct in_addr addr;
671 uint8_t prefix;
672};
673
678 struct in6_addr addr;
679};
680
685 struct in6_addr addr;
686 const char *zone;
687};
688
693 struct in6_addr addr;
694 uint8_t prefix;
695};
696
705
710 struct lyxp_expr *exp;
711 const struct ly_ctx *ctx;
714};
715
720 struct rb_node *rbt;
721};
722
731 const char *name;
732 const char *prefix;
733
734 union {
735 const char *module_ns;
736 const char *module_name;
737 };
738};
739
752
753#define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
754#define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
755#define LYD_NODE_ANY (LYS_ANYDATA)
756
781
782#define LYD_DEFAULT 0x01
783#define LYD_WHEN_TRUE 0x02
784#define LYD_NEW 0x04
785#define LYD_EXT 0x08
786
788
792struct lyd_node {
793 uint32_t hash;
797 uint32_t flags;
798 const struct lysc_node *schema;
800 struct lyd_node *next;
801 struct lyd_node *prev;
805 struct lyd_meta *meta;
806 void *priv;
807};
808
813 union {
814 struct lyd_node node;
815
816 struct {
817 uint32_t hash;
822 uint32_t flags;
823 const struct lysc_node *schema;
824 struct lyd_node_inner *parent;
825 struct lyd_node *next;
826 struct lyd_node *prev;
830 struct lyd_meta *meta;
831 void *priv;
832 };
833 };
834
835 struct lyd_node *child;
837
838#define LYD_HT_MIN_ITEMS 4
839};
840
845 union {
846 struct lyd_node node;
847
848 struct {
849 uint32_t hash;
854 uint32_t flags;
855 const struct lysc_node *schema;
856 struct lyd_node_inner *parent;
857 struct lyd_node *next;
858 struct lyd_node *prev;
862 struct lyd_meta *meta;
863 void *priv;
864 };
865 };
866
868};
869
874 struct lyd_node *tree;
875 const char *str;
876 const char *xml;
877 const char *json;
878};
879
885 union {
886 struct lyd_node node;
887
888 struct {
889 uint32_t hash;
894 uint32_t flags;
895 const struct lysc_node *schema;
896 struct lyd_node_inner *parent;
897 struct lyd_node *next;
898 struct lyd_node *prev;
902 struct lyd_meta *meta;
903 void *priv;
904 };
905 };
906
909};
910
917#define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
918
928#define LYD_VALHINT_STRING 0x0001
929#define LYD_VALHINT_DECNUM 0x0002
930#define LYD_VALHINT_OCTNUM 0x0004
931#define LYD_VALHINT_HEXNUM 0x0008
932#define LYD_VALHINT_NUM64 0x0010
933#define LYD_VALHINT_BOOLEAN 0x0020
934#define LYD_VALHINT_EMPTY 0x0040
935#define LYD_VALHINT_STRING_DATATYPES 0x0080
939
949#define LYD_NODEHINT_LIST 0x0080
950#define LYD_NODEHINT_LEAFLIST 0x0100
951#define LYD_NODEHINT_CONTAINER 0x0200
955
966#define LYD_HINT_DATA 0x03F3
970#define LYD_HINT_SCHEMA 0x03FF
977
982 union {
983 struct lyd_node node;
984
985 struct {
986 uint32_t hash;
987 uint32_t flags;
988 const struct lysc_node *schema;
989 struct lyd_node_inner *parent;
990 struct lyd_node *next;
991 struct lyd_node *prev;
995 struct lyd_meta *meta;
996 void *priv;
997 };
998 };
999
1000 struct lyd_node *child;
1001
1003 const char *value;
1004 uint32_t hints;
1007
1008 struct lyd_attr *attr;
1009 const struct ly_ctx *ctx;
1010};
1011
1027
1035static inline struct lyd_node *
1036lyd_parent(const struct lyd_node *node)
1037{
1038 return (node && node->parent) ? &node->parent->node : NULL;
1039}
1040
1051static inline struct lyd_node *
1052lyd_child(const struct lyd_node *node)
1053{
1054 if (!node) {
1055 return NULL;
1056 }
1057
1058 if (!node->schema) {
1059 /* opaq node */
1060 return ((const struct lyd_node_opaq *)node)->child;
1061 }
1062
1064 return ((const struct lyd_node_inner *)node)->child;
1065 }
1066
1067 return NULL;
1068}
1069
1080LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1081
1091LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1092
1099LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1100
1107LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1108
1116LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1117
1124LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1125
1135LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1136
1146LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1147
1154static inline const char *
1155lyd_get_value(const struct lyd_node *node)
1156{
1157 if (!node) {
1158 return NULL;
1159 }
1160
1161 if (!node->schema) {
1162 return ((const struct lyd_node_opaq *)node)->value;
1163 } else if (node->schema->nodetype & LYD_NODE_TERM) {
1164 const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1165
1167 }
1168
1169 return NULL;
1170}
1171
1179LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1180
1189LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value,
1190 LYD_ANYDATA_VALUETYPE value_type);
1191
1198LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1199
1207LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
1208
1224LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1225 ly_bool output, struct lyd_node **node);
1226
1240LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
1241
1262
1263#define LYD_NEW_VAL_OUTPUT 0x01
1265#define LYD_NEW_VAL_STORE_ONLY 0x02
1266#define LYD_NEW_VAL_BIN 0x04
1268#define LYD_NEW_VAL_CANON 0x08
1271#define LYD_NEW_META_CLEAR_DFLT 0x10
1272#define LYD_NEW_PATH_UPDATE 0x20
1276#define LYD_NEW_PATH_OPAQ 0x40
1280#define LYD_NEW_PATH_WITH_OPAQ 0x80
1281#define LYD_NEW_ANY_USE_VALUE 0x100
1282
1284
1298LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1299 uint32_t options, struct lyd_node **node, ...);
1300
1316LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options,
1317 struct lyd_node **node, ...);
1318
1332LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1333 const char *keys, uint32_t options, struct lyd_node **node);
1334
1348LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1349 const void **key_values, uint32_t *value_sizes_bits, uint32_t options, struct lyd_node **node);
1350
1365LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1366 const char *value, uint32_t options, struct lyd_node **node);
1367
1380LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1381 const void *value, uint32_t value_size_bits, uint32_t options, struct lyd_node **node);
1382
1397LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value,
1398 uint32_t value_size_bits, uint32_t options, struct lyd_node **node);
1399
1414LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1415 const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1416
1431LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value,
1432 LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1433
1448LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1449 const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1450
1463LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1464 const struct lyd_attr *attr, struct lyd_meta **meta);
1465
1478LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1479 const char *prefix, const char *module_name, struct lyd_node **node);
1480
1493LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1494 const char *prefix, const char *module_ns, struct lyd_node **node);
1495
1509LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1510 struct lyd_attr **attr);
1511
1524LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1525 struct lyd_attr **attr);
1526
1555LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1556 uint32_t options, struct lyd_node **node);
1557
1582LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1583 uint32_t value_size_bits, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1584 struct lyd_node **new_node);
1585
1608LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path,
1609 const char *value, uint32_t options, struct lyd_node **node);
1610
1623
1624#define LYD_IMPLICIT_NO_STATE 0x01
1625#define LYD_IMPLICIT_NO_CONFIG 0x02
1626#define LYD_IMPLICIT_OUTPUT 0x04
1627#define LYD_IMPLICIT_NO_DEFAULTS 0x08
1629
1631
1640LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1641
1653LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1654 struct lyd_node **diff);
1655
1667LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1668 uint32_t implicit_options, struct lyd_node **diff);
1669
1683LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1684
1699LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, uint32_t value_size_bits);
1700
1715LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1716
1726LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1727
1739LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1740
1753LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1754
1766LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1767
1779LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1780
1788LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1789
1797LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1798
1804LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1805
1811LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1812
1818LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1819
1825LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1826
1832LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1833
1840LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1841
1848LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1849
1867LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct lysc_node *schema, const char *value, uint32_t value_len,
1868 const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1869
1887LIBYANG_API_DECL LY_ERR lyd_value_validate_dflt(const struct lysc_node *schema, const char *value,
1888 struct lysc_prefix *prefixes, const struct lyd_node *ctx_node, const struct lysc_type **realtype,
1889 const char **canonical);
1890
1903LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, uint32_t value_len);
1904
1911#define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1912 (subtree, so direct as well as indirect children) are the same. By default,
1913 containers are the same in case of the same schema node and lists are the same
1914 in case of equal keys (keyless lists do the full recursion comparison all the time). */
1915#define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1916 changes this behavior and implicit (automatically created default node) and explicit
1917 (explicitly created node with the default value) default nodes are considered different. */
1918#define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1919 opaque nodes members are compared to data node schema and value and can result
1920 in a match. */
1922
1934LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1935
1947LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1948
1959LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1960
1973#define LYD_DUP_RECURSIVE 0x01
1975#define LYD_DUP_NO_META 0x02
1977#define LYD_DUP_WITH_PARENTS 0x04
1979#define LYD_DUP_WITH_FLAGS 0x08
1981#define LYD_DUP_NO_EXT 0x10
1982#define LYD_DUP_WITH_PRIV 0x20
1984#define LYD_DUP_NO_LYDS 0x40
1988
1990
2002LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
2003 struct lyd_node **dup);
2004
2018LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2019 struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2020
2032LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
2033 struct lyd_node **dup);
2034
2049LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2050 struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2051
2060LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
2061
2075
2076#define LYD_MERGE_DESTRUCT 0x01
2077#define LYD_MERGE_DEFAULTS 0x02
2078#define LYD_MERGE_WITH_FLAGS 0x04
2079
2081
2102LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2103
2125LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2126
2136typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2137
2153LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2154 lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2155
2169
2170#define LYD_DIFF_DEFAULTS 0x01
2173#define LYD_DIFF_META 0x02
2176
2178
2204LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2205 struct lyd_node **diff);
2206
2219LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2220 struct lyd_node **diff);
2221
2230typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2231
2248LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2249 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2250
2261LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2262
2273
2274#define LYD_DIFF_MERGE_DEFAULTS 0x01
2275
2277
2302LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2303 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2304
2321LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2322 const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2323
2335LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2336
2344 * @return LY_ERR on error.
2346LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2350
2351typedef enum {
2352 LYD_PATH_STD,
2357
2373LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2374
2384LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2385 const char *name);
2386
2398LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2399 struct lyd_node **match);
2400
2425LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2426 const char *key_or_value, uint32_t val_len, struct lyd_node **match);
2427
2439LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2440 struct ly_set **set);
2441
2452LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2453
2465LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2466
2472LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2473
2491LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2492
2506LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2507 struct ly_set **set);
2508
2526LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2527 LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2528
2540LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2541
2554LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2555 const struct lyxp_var *vars, ly_bool *result);
2556
2572LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2573 const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2577
2578typedef enum {
2584
2607LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2608 const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2609 const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2610 long double *number, ly_bool *boolean);
2611
2621LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2622
2640LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2641 struct lyd_node **match);
2642
2653LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2654
2660LIBYANG_API_DECL int ly_time_tz_offset(void);
2668LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
2669
2678LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2679
2688LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2689
2697LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2698
2706LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2707
2718LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2719
2729LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2730
2744LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
2745 uint32_t str_len, pcre2_code **pcode);
2746
2756LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, pcre2_code **pcode);
2757
2758#ifdef __cplusplus
2759}
2760#endif
2761
2762#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:546
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition tree_data.h:536
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition tree_data.h:519
@ LYD_ANYDATA_DATATREE
Definition tree_data.h:547
@ LYD_ANYDATA_JSON
Definition tree_data.h:555
@ LYD_ANYDATA_XML
Definition tree_data.h:554
@ LYD_ANYDATA_STRING
Definition tree_data.h:551
@ LYD_LYB
Definition tree_data.h:540
@ LYD_XML
Definition tree_data.h:538
@ LYD_UNKNOWN
Definition tree_data.h:537
@ LYD_JSON
Definition tree_data.h:539
LY_ERR
libyang's error codes returned by the libyang functions.
Definition log.h:237
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node,...
Definition set.h:47
YANG extension compiled instance.
#define LYS_NOTIF
#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:35
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:749
const struct lysc_ext_instance * top_ext
Definition tree_data.h:629
struct lyd_node * next
Definition tree_data.h:800
LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, pcre2_code **pcode)
Compile an XML Schema regex pattern prior to matching.
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:1006
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:732
struct rb_node * rbt
Definition tree_data.h:720
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:662
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.
const char * str
Definition tree_data.h:875
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:2344
@ LYD_PATH_STD_NO_LAST_PRED
Definition tree_data.h:2347
@ LYD_PATH_STD
Definition tree_data.h:2345
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:867
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:567
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str)
Change the value of a metadata instance.
struct lyd_node * tree
Definition tree_data.h:874
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:748
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:908
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:1017
struct lyd_attr * attr
Definition tree_data.h:1008
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:2223
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.
LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are assi...
struct lyd_node * child
Definition tree_data.h:1000
LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2)
Compare 2 metadata.
const char * json
Definition tree_data.h:877
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.
LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are assigned from trg_ctx.
struct lysc_type_bitenum_item ** items
Definition tree_data.h:639
const struct ly_ctx * ctx
Definition tree_data.h:1009
LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are kept...
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 LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path, const char *value, uint32_t options, struct lyd_node **node)
Create a new node defined in the given extension instance. In case of anyxml/anydata nodes,...
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:2129
struct lyd_meta * meta
Definition tree_data.h:805
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:1023
uint32_t flags
Definition tree_data.h:797
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 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:2571
@ LY_XPATH_NODE_SET
Definition tree_data.h:2572
@ LY_XPATH_NUMBER
Definition tree_data.h:2574
@ LY_XPATH_STRING
Definition tree_data.h:2573
@ LY_XPATH_BOOLEAN
Definition tree_data.h:2575
const struct lysc_node * schema
Definition tree_data.h:798
struct in6_addr addr
Definition tree_data.h:685
LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node)
Create a new top-level inner node defined in the given extension instance.
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:710
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:1003
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.
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:731
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_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:627
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 lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, uint32_t options, struct lyd_node **node,...)
Create a new top-level list node defined in the given extension instance.
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:1016
#define LYD_NODE_TERM
Definition tree_data.h:754
uint32_t hints
Definition tree_data.h:1004
LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value, LYD_ANYDATA_VALUETYPE value_type)
Copy anydata value from one node to another. Target value is freed first.
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 ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string, uint32_t str_len, pcre2_code **pcode)
Check a string matches an XML Schema regex used in YANG.
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:746
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_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are kept the same.
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:793
void * val_prefix_data
Definition tree_data.h:750
struct in_addr addr
Definition tree_data.h:670
struct lyd_node * prev
Definition tree_data.h:801
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 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:835
const char * xml
Definition tree_data.h:876
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:713
void * priv
Definition tree_data.h:806
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:622
struct ly_ht * children_ht
Definition tree_data.h:836
LY_VALUE_FORMAT format
Definition tree_data.h:1005
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
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:747
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:711
LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const void *value, uint32_t value_size_bits, uint32_t options, struct lyd_node **node)
Create a new top-level term node defined in the given extension instance.
LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node)
Unlink the specified data subtree.
union lyd_any_value value
Definition tree_data.h:907
struct lyd_attr * next
Definition tree_data.h:745
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.
LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node)
Create a new top-level any node defined in the given extension instance.
uint32_t hints
Definition tree_data.h:623
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:693
struct lyd_value value
Definition tree_data.h:619
const char * _canonical
Definition tree_data.h:564
struct lyd_node_opaq * parent
Definition tree_data.h:744
LY_VALUE_FORMAT format
Definition tree_data.h:624
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...
struct lyd_node_inner * parent
Definition tree_data.h:799
struct ly_opaq_name name
Definition tree_data.h:1002
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:628
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:730
Generic attribute structure.
Definition tree_data.h:743
Generic structure for a data node.
Definition tree_data.h:792
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition tree_data.h:884
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition tree_data.h:812
Data node structure for unparsed (opaque) nodes.
Definition tree_data.h:981
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition tree_data.h:844
YANG data representation.
Definition tree_data.h:563
Special lyd_value structure for built-in binary values.
Definition tree_data.h:646
Special lyd_value structure for built-in bits values.
Definition tree_data.h:635
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition tree_data.h:700
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition tree_data.h:661
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition tree_data.h:654
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition tree_data.h:669
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition tree_data.h:684
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition tree_data.h:677
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition tree_data.h:692
Special lyd_value structure for lyds tree value.
Definition tree_data.h:719
Special lyd_value structure for built-in union values.
Definition tree_data.h:618
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition tree_data.h:709
union for anydata/anyxml value representation.
Definition tree_data.h:873
libyang representation of YANG schema trees.