libyang 5.0.8
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
199
317
370
382
390
391/* *INDENT-OFF* */
392
418#define LYD_TREE_DFS_BEGIN(START, ELEM) \
419 { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
420 for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
421 (ELEM); \
422 (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
423
439#define LYD_TREE_DFS_END(START, ELEM) \
440 /* select element for the next run - children first */ \
441 if (LYD_TREE_DFS_continue) { \
442 (LYD_TREE_DFS_next) = NULL; \
443 } else { \
444 (LYD_TREE_DFS_next) = lyd_child(ELEM); \
445 }\
446 if (!(LYD_TREE_DFS_next)) { \
447 /* no children */ \
448 if ((ELEM) == (struct lyd_node *)(START)) { \
449 /* we are done, (START) has no children */ \
450 break; \
451 } \
452 /* try siblings */ \
453 (LYD_TREE_DFS_next) = (ELEM)->next; \
454 } \
455 while (!(LYD_TREE_DFS_next)) { \
456 /* parent is already processed, go to its sibling */ \
457 (ELEM) = (struct lyd_node *)(ELEM)->parent; \
458 /* no siblings, go back through parents */ \
459 if ((ELEM)->parent == (START)->parent) { \
460 /* we are done, no next element to process */ \
461 break; \
462 } \
463 (LYD_TREE_DFS_next) = (ELEM)->next; \
464 } }
465
473#define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
474 for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
475 (ELEM) && ((ELEM)->schema == (SCHEMA)); \
476 (ELEM) = (ELEM)->next)
477
486#define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
487 for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
488 (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
489 (ELEM) = (NEXT))
490
491/* *INDENT-ON* */
492
496#define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
497
505#define LYD_NODE_IS_ALONE(NODE) \
506 (((NODE)->prev == NODE) || \
507 (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
508
519
534
536
540struct lyd_value {
541 const char *_canonical;
544 const struct lysc_type *realtype;
551
552 union {
553 int8_t boolean;
554 int64_t dec64;
555 int8_t int8;
556 int16_t int16;
557 int32_t int32;
558 int64_t int64;
559 uint8_t uint8;
560 uint16_t uint16;
561 uint32_t uint32;
562 uint64_t uint64;
564 struct lysc_ident *ident;
565 struct ly_path *target;
567 struct lyd_value_union *subvalue;
568
569 void *dyn_mem;
570 uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
571 };
572
573};
574
583#define LYD_VALUE_GET(value, type_val) \
584 ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
585 ? ((type_val) = (((value)->dyn_mem))) \
586 : ((type_val) = ((void *)((value)->fixed_mem))))
587
607
618
623 void *data;
624 uint32_t size;
625};
626
631 struct in_addr addr;
632};
633
638 struct in_addr addr;
639 const char *zone;
640};
641
646 struct in_addr addr;
647 uint8_t prefix;
648};
649
654 struct in6_addr addr;
655};
656
661 struct in6_addr addr;
662 const char *zone;
663};
664
669 struct in6_addr addr;
670 uint8_t prefix;
671};
672
681
689
694 time_t time;
695};
696
705
710 uint32_t seconds;
712};
713
718 struct lyxp_expr *exp;
719 const struct ly_ctx *ctx;
722};
723
728 struct rb_node *rbt;
729};
730
739 const char *name;
740 const char *prefix;
741
742 union {
743 const char *module_ns;
744 const char *module_name;
745 };
746};
747
760
761#define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
762#define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
763#define LYD_NODE_ANY (LYS_ANYDATA)
764
789
790#define LYD_DEFAULT 0x01
791#define LYD_WHEN_TRUE 0x02
792#define LYD_NEW 0x04
793#define LYD_EXT 0x08
794
796
800struct lyd_node {
801 uint32_t hash;
805 uint32_t flags;
806 const struct lysc_node *schema;
807 struct lyd_node *parent;
808 struct lyd_node *next;
809 struct lyd_node *prev;
813 struct lyd_meta *meta;
814 void *priv;
815};
816
821 union {
822 struct lyd_node node;
823
824 struct {
825 uint32_t hash;
830 uint32_t flags;
831 const struct lysc_node *schema;
832 struct lyd_node *parent;
833 struct lyd_node *next;
834 struct lyd_node *prev;
838 struct lyd_meta *meta;
839 void *priv;
840 };
841 };
842
843 struct lyd_node *child;
845
846#define LYD_HT_MIN_ITEMS 4
847};
848
853 union {
854 struct lyd_node node;
855
856 struct {
857 uint32_t hash;
862 uint32_t flags;
863 const struct lysc_node *schema;
864 struct lyd_node *parent;
865 struct lyd_node *next;
866 struct lyd_node *prev;
870 struct lyd_meta *meta;
871 void *priv;
872 };
873 };
874
876};
877
882 union {
883 struct lyd_node node;
884
885 struct {
886 uint32_t hash;
891 uint32_t flags;
892 const struct lysc_node *schema;
893 struct lyd_node *parent;
894 struct lyd_node *next;
895 struct lyd_node *prev;
899 struct lyd_meta *meta;
900 void *priv;
901 };
902 };
903
904 struct lyd_node *child;
906 const char *value;
908};
909
916#define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
917
927#define LYD_VALHINT_STRING 0x0001
928#define LYD_VALHINT_DECNUM 0x0002
929#define LYD_VALHINT_OCTNUM 0x0004
930#define LYD_VALHINT_HEXNUM 0x0008
931#define LYD_VALHINT_NUM64 0x0010
932#define LYD_VALHINT_BOOLEAN 0x0020
933#define LYD_VALHINT_EMPTY 0x0040
934#define LYD_VALHINT_STRING_DATATYPES 0x0080
938
948#define LYD_NODEHINT_LIST 0x0080
949#define LYD_NODEHINT_LEAFLIST 0x0100
950#define LYD_NODEHINT_CONTAINER 0x0200
954
965#define LYD_HINT_DATA 0x03F3
969#define LYD_HINT_SCHEMA 0x03FF
976
981 union {
982 struct lyd_node node;
983
984 struct {
985 uint32_t hash;
986 uint32_t flags;
987 const struct lysc_node *schema;
988 struct lyd_node *parent;
989 struct lyd_node *next;
990 struct lyd_node *prev;
994 struct lyd_meta *meta;
995 void *priv;
996 };
997 };
998
999 struct lyd_node *child;
1000
1002 const char *value;
1003 uint32_t hints;
1006
1007 struct lyd_attr *attr;
1008 const struct ly_ctx *ctx;
1009};
1010
1026
1034#define lyd_parent(node) ((node) ? (node)->parent : NULL)
1035
1047static inline struct lyd_node *
1048lyd_child(const struct lyd_node *node)
1049{
1050 if (!node) {
1051 return NULL;
1052 }
1053
1054 if (!node->schema) {
1055 /* opaq node */
1056 return ((const struct lyd_node_opaq *)node)->child;
1057 }
1058
1060 return ((const struct lyd_node_inner *)node)->child;
1061 }
1062
1063 return NULL;
1064}
1065
1077static inline struct lyd_node *
1078lyd_child_any(const struct lyd_node *node)
1079{
1080 if (!node) {
1081 return NULL;
1082 }
1083
1084 if (!node->schema) {
1085 /* opaq node */
1086 return ((const struct lyd_node_opaq *)node)->child;
1087 }
1088
1090 return ((const struct lyd_node_inner *)node)->child;
1091 }
1092
1093 return NULL;
1094}
1095
1104LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1105
1115LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1116
1123LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1124
1131LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1132
1140LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1141
1148LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1149
1159LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1160
1170LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1171
1178static inline const char *
1179lyd_get_value(const struct lyd_node *node)
1180{
1181 if (!node) {
1182 return NULL;
1183 }
1184
1185 if (!node->schema) {
1186 return ((const struct lyd_node_opaq *)node)->value;
1187 } else if (node->schema->nodetype & LYD_NODE_TERM) {
1188 const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1189
1191 }
1192
1193 return NULL;
1194}
1195
1203LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1204
1213LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const void *value, LYD_ANYDATA_VALUETYPE value_type);
1214
1221LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1222
1230LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
1231
1245LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1246 ly_bool output, struct lyd_node **node);
1247
1268
1269#define LYD_NEW_VAL_OUTPUT 0x01
1271#define LYD_NEW_VAL_STORE_ONLY 0x02
1272#define LYD_NEW_VAL_BIN 0x04
1274#define LYD_NEW_VAL_CANON 0x08
1277#define LYD_NEW_META_CLEAR_DFLT 0x10
1278#define LYD_NEW_PATH_UPDATE 0x20
1282#define LYD_NEW_PATH_OPAQ 0x40
1286#define LYD_NEW_PATH_WITH_OPAQ 0x80
1287#define LYD_NEW_ANY_USE_VALUE 0x100
1288
1290
1304LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1305 uint32_t options, struct lyd_node **node, ...);
1306
1320LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1321 const char *keys, uint32_t options, struct lyd_node **node);
1322
1336LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1337 const void **key_values, uint32_t *value_sizes_bits, uint32_t options, struct lyd_node **node);
1338
1352LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1353 const char *value, uint32_t options, struct lyd_node **node);
1354
1367LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1368 const void *value, uint32_t value_size_bits, uint32_t options, struct lyd_node **node);
1369
1382LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1383 const void *value, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node);
1384
1399LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1400 const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1401
1414LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1415 const struct lyd_attr *attr, struct lyd_meta **meta);
1416
1429LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1430 const char *prefix, const char *module_name, struct lyd_node **node);
1431
1444LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1445 const char *prefix, const char *module_ns, struct lyd_node **node);
1446
1460LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1461 struct lyd_attr **attr);
1462
1475LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1476 struct lyd_attr **attr);
1477
1506LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1507 uint32_t options, struct lyd_node **node);
1508
1533LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1534 uint32_t value_size_bits, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1535 struct lyd_node **new_node);
1536
1549
1550#define LYD_IMPLICIT_NO_STATE 0x01
1551#define LYD_IMPLICIT_NO_CONFIG 0x02
1552#define LYD_IMPLICIT_OUTPUT 0x04
1553#define LYD_IMPLICIT_NO_DEFAULTS 0x08
1555
1557
1566LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1567
1579LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1580 struct lyd_node **diff);
1581
1593LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1594 uint32_t implicit_options, struct lyd_node **diff);
1595
1609LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1610
1625LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, uint32_t value_size_bits);
1626
1641LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1642
1652LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1653
1665LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1666
1679LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1680
1692LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1693
1705LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1706
1714LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1715
1723LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1724
1730LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1731
1737LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1738
1744LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1745
1751LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1752
1758LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1759
1766LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1767
1774LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1775
1793LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct lysc_node *schema, const char *value, uint32_t value_len,
1794 const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1795
1813LIBYANG_API_DECL LY_ERR lyd_value_validate_dflt(const struct lysc_node *schema, const char *value,
1814 struct lysc_prefix *prefixes, const struct lyd_node *ctx_node, const struct lysc_type **realtype,
1815 const char **canonical);
1816
1829LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, uint32_t value_len);
1830
1837#define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1838 (subtree, so direct as well as indirect children) are the same. By default,
1839 containers are the same in case of the same schema node and lists are the same
1840 in case of equal keys (keyless lists do the full recursion comparison all the time). */
1841#define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1842 changes this behavior and implicit (automatically created default node) and explicit
1843 (explicitly created node with the default value) default nodes are considered different. */
1844#define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1845 opaque nodes members are compared to data node schema and value and can result
1846 in a match. */
1848
1860LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1861
1873LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1874
1885LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1886
1899#define LYD_DUP_RECURSIVE 0x01
1901#define LYD_DUP_NO_META 0x02
1903#define LYD_DUP_WITH_PARENTS 0x04
1905#define LYD_DUP_WITH_FLAGS 0x08
1907#define LYD_DUP_NO_EXT 0x10
1908#define LYD_DUP_WITH_PRIV 0x20
1910#define LYD_DUP_NO_LYDS 0x40
1914
1916
1928LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
1929 struct lyd_node **dup);
1930
1944LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1945 struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
1946
1958LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
1959 struct lyd_node **dup);
1960
1975LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1976 struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
1977
1986LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
1987
2001
2002#define LYD_MERGE_DESTRUCT 0x01
2003#define LYD_MERGE_DEFAULTS 0x02
2004#define LYD_MERGE_WITH_FLAGS 0x04
2005
2007
2028LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2029
2051LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2052
2062typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2063
2079LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2080 lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2081
2095
2096#define LYD_DIFF_DEFAULTS 0x01
2099#define LYD_DIFF_META 0x02
2102
2104
2130LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2131 struct lyd_node **diff);
2132
2145LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2146 struct lyd_node **diff);
2147
2156typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2157
2174LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2175 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2176
2187LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2188
2199
2200#define LYD_DIFF_MERGE_DEFAULTS 0x01
2201
2203
2228LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2229 const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2230
2247LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2248 const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2249
2261LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2262
2270 * @return LY_ERR on error.
2272LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2276
2277typedef enum {
2278 LYD_PATH_STD,
2283
2299LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2300
2310LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2311 const char *name);
2312
2324LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2325 struct lyd_node **match);
2326
2351LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2352 const char *key_or_value, uint32_t val_len, struct lyd_node **match);
2353
2365LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2366 struct ly_set **set);
2367
2378LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2379
2391LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2392
2398LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2399
2419LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2420
2434LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2435 struct ly_set **set);
2436
2454LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2455 LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2456
2468LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2469
2482LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2483 const struct lyxp_var *vars, ly_bool *result);
2484
2500LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2501 const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2505
2506typedef enum {
2512
2535LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2536 const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2537 const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2538 long double *number, ly_bool *boolean);
2539
2549LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2550
2568LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2569 struct lyd_node **match);
2570
2581LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2582
2588LIBYANG_API_DECL int ly_time_tz_offset(void);
2596LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
2597
2606LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2607
2616LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2617
2625LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2626
2634LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2635
2646LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2647
2657LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2658
2672LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
2673 uint32_t str_len, void **pat_comp);
2674
2684LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, void **pat_comp);
2685
2691LIBYANG_API_DECL void ly_pattern_free(void *pat_comp);
2692
2693#ifdef __cplusplus
2694}
2695#endif
2696
2697#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:523
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition tree_data.h:513
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition tree_data.h:496
@ LYD_ANYDATA_DATATREE
Definition tree_data.h:524
@ LYD_ANYDATA_JSON
Definition tree_data.h:532
@ LYD_ANYDATA_XML
Definition tree_data.h:531
@ LYD_ANYDATA_STRING
Definition tree_data.h:528
@ LYD_LYB
Definition tree_data.h:517
@ LYD_XML
Definition tree_data.h:515
@ LYD_UNKNOWN
Definition tree_data.h:514
@ LYD_JSON
Definition tree_data.h:516
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:757
struct lyd_node * next
Definition tree_data.h:808
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:1005
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:740
struct rb_node * rbt
Definition tree_data.h:728
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:638
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:2270
@ LYD_PATH_STD_NO_LAST_PRED
Definition tree_data.h:2273
@ LYD_PATH_STD
Definition tree_data.h:2271
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:875
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:544
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:756
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:907
ly_bool unknown_tz
Definition tree_data.h:687
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:1016
struct lyd_attr * attr
Definition tree_data.h:1007
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:2149
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:999
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:615
const struct ly_ctx * ctx
Definition tree_data.h:1008
char * fractions_s
Definition tree_data.h:702
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:2055
struct lyd_meta * meta
Definition tree_data.h:813
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:1022
uint32_t flags
Definition tree_data.h:805
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:2499
@ LY_XPATH_NODE_SET
Definition tree_data.h:2500
@ LY_XPATH_NUMBER
Definition tree_data.h:2502
@ LY_XPATH_STRING
Definition tree_data.h:2501
@ LY_XPATH_BOOLEAN
Definition tree_data.h:2503
const struct lysc_node * schema
Definition tree_data.h:806
uint32_t seconds
Definition tree_data.h:701
struct in6_addr addr
Definition tree_data.h:661
const char * value
Definition tree_data.h:906
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:718
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:1002
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:807
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:739
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:604
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:1015
#define LYD_NODE_TERM
Definition tree_data.h:762
uint32_t hints
Definition tree_data.h:1003
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:754
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:801
void * val_prefix_data
Definition tree_data.h:758
struct in_addr addr
Definition tree_data.h:646
struct lyd_node * prev
Definition tree_data.h:809
ly_bool unknown_tz
Definition tree_data.h:703
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:843
struct ly_ht * children_ht
Definition tree_data.h:905
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:721
void * priv
Definition tree_data.h:814
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:599
struct ly_ht * children_ht
Definition tree_data.h:844
LY_VALUE_FORMAT format
Definition tree_data.h:1004
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:904
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:755
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:719
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:753
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:600
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:669
struct lyd_value value
Definition tree_data.h:596
const char * _canonical
Definition tree_data.h:541
struct lyd_node_opaq * parent
Definition tree_data.h:752
LY_VALUE_FORMAT format
Definition tree_data.h:601
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:1001
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:605
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:738
Generic attribute structure.
Definition tree_data.h:751
Generic structure for a data node.
Definition tree_data.h:800
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition tree_data.h:881
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition tree_data.h:820
Data node structure for unparsed (opaque) nodes.
Definition tree_data.h:980
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition tree_data.h:852
YANG data representation.
Definition tree_data.h:540
Special lyd_value structure for built-in binary values.
Definition tree_data.h:622
Special lyd_value structure for built-in bits values.
Definition tree_data.h:611
Special lyd_value structure for ietf-yang-types date values.
Definition tree_data.h:685
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition tree_data.h:676
Special lyd_value structure for ietf-yang-types date-no-zone values.
Definition tree_data.h:693
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition tree_data.h:637
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition tree_data.h:630
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition tree_data.h:645
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition tree_data.h:660
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition tree_data.h:653
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition tree_data.h:668
Special lyd_value structure for lyds tree value.
Definition tree_data.h:727
Special lyd_value structure for ietf-yang-types time values.
Definition tree_data.h:700
Special lyd_value structure for ietf-yang-types time-no-zone values.
Definition tree_data.h:709
Special lyd_value structure for built-in union values.
Definition tree_data.h:595
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition tree_data.h:717
libyang representation of YANG schema trees.