libyang  2.0.194
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
tree_data.h
Go to the documentation of this file.
1 
16 #ifndef LY_TREE_DATA_H_
17 #define LY_TREE_DATA_H_
18 
19 #ifdef _WIN32
20 # include <winsock2.h>
21 # include <ws2tcpip.h>
22 #else
23 # include <arpa/inet.h>
24 # if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__)
25 # include <netinet/in.h>
26 # include <sys/socket.h>
27 # endif
28 #endif
29 #include <stddef.h>
30 #include <stdint.h>
31 #include <time.h>
32 
33 #include "config.h"
34 #include "log.h"
35 #include "tree.h"
36 #include "tree_schema.h"
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 struct ly_ctx;
43 struct ly_path;
44 struct ly_set;
45 struct lyd_node;
46 struct lyd_node_opaq;
47 struct lyd_node_term;
48 struct timespec;
49 struct lyxp_var;
50 
423 /* *INDENT-OFF* */
424 
450 #define LYD_TREE_DFS_BEGIN(START, ELEM) \
451  { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
452  for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
453  (ELEM); \
454  (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
455 
470 #define LYD_TREE_DFS_END(START, ELEM) \
471  /* select element for the next run - children first */ \
472  if (LYD_TREE_DFS_continue) { \
473  (LYD_TREE_DFS_next) = NULL; \
474  } else { \
475  (LYD_TREE_DFS_next) = lyd_child(ELEM); \
476  }\
477  if (!(LYD_TREE_DFS_next)) { \
478  /* no children */ \
479  if ((ELEM) == (struct lyd_node *)(START)) { \
480  /* we are done, (START) has no children */ \
481  break; \
482  } \
483  /* try siblings */ \
484  (LYD_TREE_DFS_next) = (ELEM)->next; \
485  } \
486  while (!(LYD_TREE_DFS_next)) { \
487  /* parent is already processed, go to its sibling */ \
488  (ELEM) = (struct lyd_node *)(ELEM)->parent; \
489  /* no siblings, go back through parents */ \
490  if ((ELEM)->parent == (START)->parent) { \
491  /* we are done, no next element to process */ \
492  break; \
493  } \
494  (LYD_TREE_DFS_next) = (ELEM)->next; \
495  } }
496 
504 #define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
505  for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
506  (ELEM) && ((ELEM)->schema == (SCHEMA)); \
507  (ELEM) = (ELEM)->next)
508 
517 #define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
518  for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
519  (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
520  (ELEM) = (NEXT))
521 
522 /* *INDENT-ON* */
523 
527 #define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
528 
533 typedef enum {
537  LYD_LYB
539 
543 typedef enum {
554 
560 struct lyd_value {
561  const char *_canonical;
564  const struct lysc_type *realtype;
572  union {
573  int8_t boolean;
574  int64_t dec64;
575  int8_t int8;
576  int16_t int16;
577  int32_t int32;
578  int64_t int64;
579  uint8_t uint8;
580  uint16_t uint16;
581  uint32_t uint32;
582  uint64_t uint64;
583  struct lysc_type_bitenum_item *enum_item;
584  struct lysc_ident *ident;
585  struct ly_path *target;
587  struct lyd_value_union *subvalue;
589  void *dyn_mem;
590  uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
591  };
593 };
594 
603 #define LYD_VALUE_GET(value, type_val) \
604  ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
605  ? ((type_val) = (((value)->dyn_mem))) \
606  : ((type_val) = ((void *)((value)->fixed_mem))))
607 
616  struct lyd_value value;
618  void *original;
619  size_t orig_len;
620  uint32_t hints;
624  void *prefix_data;
625  const struct lysc_node *ctx_node;
626 };
627 
632  char *bitmap;
637 };
638 
643  void *data;
644  size_t size;
645 };
646 
651  struct in_addr addr;
652 };
653 
658  struct in_addr addr;
659  const char *zone;
660 };
661 
666  struct in_addr addr;
667  uint8_t prefix;
668 };
669 
674  struct in6_addr addr;
675 };
676 
681  struct in6_addr addr;
682  const char *zone;
683 };
684 
689  struct in6_addr addr;
690  uint8_t prefix;
691 };
692 
697  time_t time;
698  char *fractions_s;
700 };
701 
706  struct lyxp_expr *exp;
707  const struct ly_ctx *ctx;
708  void *prefix_data;
710 };
711 
722 struct lyd_meta {
723  struct lyd_node *parent;
724  struct lyd_meta *next;
726  const char *name;
727  struct lyd_value value;
728 };
729 
737 struct ly_opaq_name {
738  const char *name;
739  const char *prefix;
740  union {
741  const char *module_ns;
742  const char *module_name;
743  };
744 };
745 
749 struct lyd_attr {
751  struct lyd_attr *next;
752  struct ly_opaq_name name;
753  const char *value;
754  uint32_t hints;
757 };
758 
759 #define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
760 #define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
761 #define LYD_NODE_ANY (LYS_ANYDATA)
788 #define LYD_DEFAULT 0x01
789 #define LYD_WHEN_TRUE 0x02
790 #define LYD_NEW 0x04
791 #define LYD_EXT 0x08
798 struct lyd_node {
799  uint32_t hash;
803  uint32_t flags;
804  const struct lysc_node *schema;
806  struct lyd_node *next;
807  struct lyd_node *prev;
811  struct lyd_meta *meta;
812  void *priv;
813 };
814 
819  union {
820  struct lyd_node node;
821  struct {
822  uint32_t hash;
827  uint32_t flags;
828  const struct lysc_node *schema;
829  struct lyd_node_inner *parent;
830  struct lyd_node *next;
831  struct lyd_node *prev;
835  struct lyd_meta *meta;
836  void *priv;
837  };
838  };
840  struct lyd_node *child;
841  struct hash_table *children_ht;
842 #define LYD_HT_MIN_ITEMS 4
843 };
844 
849  union {
850  struct lyd_node node;
851  struct {
852  uint32_t hash;
857  uint32_t flags;
858  const struct lysc_node *schema;
859  struct lyd_node_inner *parent;
860  struct lyd_node *next;
861  struct lyd_node *prev;
865  struct lyd_meta *meta;
866  void *priv;
867  };
868  };
870  struct lyd_value value;
871 };
872 
877  struct lyd_node *tree;
878  const char *str;
879  const char *xml;
880  const char *json;
881  char *mem;
882 };
883 
888 struct lyd_node_any {
889  union {
890  struct lyd_node node;
891  struct {
892  uint32_t hash;
897  uint32_t flags;
898  const struct lysc_node *schema;
899  struct lyd_node_inner *parent;
900  struct lyd_node *next;
901  struct lyd_node *prev;
905  struct lyd_meta *meta;
906  void *priv;
907  };
908  };
910  union lyd_any_value value;
912 };
913 
920 #define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
921 
931 #define LYD_VALHINT_STRING 0x0001
932 #define LYD_VALHINT_DECNUM 0x0002
933 #define LYD_VALHINT_OCTNUM 0x0004
934 #define LYD_VALHINT_HEXNUM 0x0008
935 #define LYD_VALHINT_NUM64 0x0010
936 #define LYD_VALHINT_BOOLEAN 0x0020
937 #define LYD_VALHINT_EMPTY 0x0040
951 #define LYD_NODEHINT_LIST 0x0080
952 #define LYD_NODEHINT_LEAFLIST 0x0100
967 #define LYD_HINT_DATA 0x01F3
971 #define LYD_HINT_SCHEMA 0x01FF
983  union {
984  struct lyd_node node;
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  };
1000  struct lyd_node *child;
1002  struct ly_opaq_name name;
1003  const char *value;
1004  uint32_t hints;
1008  struct lyd_attr *attr;
1009  const struct ly_ctx *ctx;
1010 };
1011 
1019 static inline struct lyd_node *
1020 lyd_parent(const struct lyd_node *node)
1021 {
1022  if (!node || !node->parent) {
1023  return NULL;
1024  }
1025 
1026  return &node->parent->node;
1027 }
1028 
1039 static inline struct lyd_node *
1040 lyd_child(const struct lyd_node *node)
1041 {
1042  if (!node) {
1043  return NULL;
1044  }
1045 
1046  if (!node->schema) {
1047  /* opaq node */
1048  return ((const struct lyd_node_opaq *)node)->child;
1049  }
1050 
1051  switch (node->schema->nodetype) {
1052  case LYS_CONTAINER:
1053  case LYS_LIST:
1054  case LYS_RPC:
1055  case LYS_ACTION:
1056  case LYS_NOTIF:
1057  return ((const struct lyd_node_inner *)node)->child;
1058  default:
1059  return NULL;
1060  }
1061 }
1062 
1073 LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1074 
1084 LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1085 
1092 LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1093 
1101 LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1102 
1109 LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1110 
1118 LIBYANG_API_DECL int lyd_lyb_data_length(const char *data);
1119 
1129 LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1130 
1140 LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1141 
1148 static inline const char *
1149 lyd_get_value(const struct lyd_node *node)
1150 {
1151  if (!node) {
1152  return NULL;
1153  }
1154 
1155  if (!node->schema) {
1156  return ((const struct lyd_node_opaq *)node)->value;
1157  } else if (node->schema->nodetype & LYD_NODE_TERM) {
1158  const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1160  }
1161 
1162  return NULL;
1163 }
1164 
1171 static inline const char *
1172 lyd_get_meta_value(const struct lyd_meta *meta)
1173 {
1174  if (meta) {
1175  const struct lyd_value *value = &meta->value;
1176  return value->_canonical ? value->_canonical : lyd_value_get_canonical(meta->annotation->module->ctx, value);
1177  }
1178 
1179  return NULL;
1180 }
1181 
1189 LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1190 
1199 LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value,
1200  LYD_ANYDATA_VALUETYPE value_type);
1201 
1217 LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1218  ly_bool output, struct lyd_node **node);
1219 
1233 LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
1234 
1249 LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1250  ly_bool output, struct lyd_node **node, ...);
1251 
1265 LIBYANG_API_DECL LY_ERR lyd_new_list_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1266  ly_bool output, struct lyd_node **node, ...);
1267 
1281 LIBYANG_API_DECL LY_ERR lyd_new_list_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
1282  ly_bool output, struct lyd_node **node, ...);
1283 
1298 LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node, ...);
1299 
1314 LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1315  const char *keys, ly_bool output, struct lyd_node **node);
1316 
1331 LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1332  const char *val_str, ly_bool output, struct lyd_node **node);
1333 
1347 LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1348  const void *value, size_t value_len, ly_bool output, struct lyd_node **node);
1349 
1362 LIBYANG_API_DECL LY_ERR lyd_new_term_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
1363  const char *val_str, ly_bool output, struct lyd_node **node);
1364 
1378 LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str,
1379  struct lyd_node **node);
1380 
1397 LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1398  const void *value, ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, ly_bool output, struct lyd_node **node);
1399 
1414 LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value,
1415  ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, struct lyd_node **node);
1416 
1431 LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1432  const char *name, const char *val_str, ly_bool clear_dflt, struct lyd_meta **meta);
1433 
1446 LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_dflt,
1447  const struct lyd_attr *attr, struct lyd_meta **meta);
1448 
1461 LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1462  const char *prefix, const char *module_name, struct lyd_node **node);
1463 
1476 LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1477  const char *prefix, const char *module_ns, struct lyd_node **node);
1478 
1492 LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1493  struct lyd_attr **attr);
1494 
1507 LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1508  struct lyd_attr **attr);
1509 
1523 #define LYD_NEW_PATH_UPDATE 0x01
1527 #define LYD_NEW_PATH_OUTPUT 0x02
1529 #define LYD_NEW_PATH_OPAQ 0x04
1532 #define LYD_NEW_PATH_BIN_VALUE 0x08
1534 #define LYD_NEW_PATH_CANON_VALUE 0x10
1564 LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1565  uint32_t options, struct lyd_node **node);
1566 
1587 LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1588  size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1589  struct lyd_node **new_node);
1590 
1609 LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path,
1610  const void *value, uint32_t options, struct lyd_node **node);
1611 
1625 #define LYD_IMPLICIT_NO_STATE 0x01
1626 #define LYD_IMPLICIT_NO_CONFIG 0x02
1627 #define LYD_IMPLICIT_OUTPUT 0x04
1628 #define LYD_IMPLICIT_NO_DEFAULTS 0x08
1641 LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1642 
1654 LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1655  struct lyd_node **diff);
1656 
1668 LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1669  uint32_t implicit_options, struct lyd_node **diff);
1670 
1684 LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1685 
1700 LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len);
1701 
1716 LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1717 
1727 LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1728 
1740 LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1741 
1754 LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1755 
1767 LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1768 
1780 LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1781 
1787 LIBYANG_API_DECL void lyd_unlink_siblings(struct lyd_node *node);
1788 
1794 LIBYANG_API_DECL void lyd_unlink_tree(struct lyd_node *node);
1795 
1801 LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1802 
1808 LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1809 
1815 LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1816 
1822 LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1823 
1829 LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1830 
1837 LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1838 
1845 LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1846 
1865 LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value,
1866  size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1867 
1880 LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len);
1881 
1888 #define LYD_COMPARE_FULL_RECURSION 0x01 /* lists and containers are the same only in case all they children
1889  (subtree, so direct as well as indirect children) are the same. By default,
1890  containers are the same in case of the same schema node and lists are the same
1891  in case of equal keys (keyless lists do the full recursion comparison all the time). */
1892 #define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1893  changes this behavior and implicit (automatically created default node) and explicit
1894  (explicitly created node with the default value) default nodes are considered different. */
1908 LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1909 
1921 LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1922 
1933 LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1934 
1947 #define LYD_DUP_RECURSIVE 0x01
1949 #define LYD_DUP_NO_META 0x02
1950 #define LYD_DUP_WITH_PARENTS 0x04
1952 #define LYD_DUP_WITH_FLAGS 0x08
1968 LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
1969  struct lyd_node **dup);
1970 
1983 LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1984  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
1985 
1997 LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
1998  struct lyd_node **dup);
1999 
2013 LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2014  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2015 
2024 LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
2025 
2040 #define LYD_MERGE_DESTRUCT 0x01
2041 #define LYD_MERGE_DEFAULTS 0x02
2042 #define LYD_MERGE_WITH_FLAGS 0x04
2066 LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2067 
2089 LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2090 
2100 typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2101 
2117 LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2118  lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2119 
2131 #define LYD_DIFF_DEFAULTS 0x01
2162 LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2163  struct lyd_node **diff);
2164 
2177 LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2178  struct lyd_node **diff);
2179 
2188 typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2189 
2206 LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2207  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2208 
2219 LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2220 
2232 #define LYD_DIFF_MERGE_DEFAULTS 0x01
2260 LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2261  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2262 
2279 LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2280  const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2281 
2293 LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2294 
2304 LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2305 
2314 LIBYANG_API_DECL const struct lyd_node_term *lyd_target(const struct ly_path *path, const struct lyd_node *tree);
2315 
2319 typedef enum {
2320  LYD_PATH_STD,
2324 } LYD_PATH_TYPE;
2325 
2337 LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2338 
2348 LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2349  const char *name);
2350 
2362 LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2363  struct lyd_node **match);
2364 
2389 LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2390  const char *key_or_value, size_t val_len, struct lyd_node **match);
2391 
2403 LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2404  struct ly_set **set);
2405 
2416 LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2417 
2429 LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2430 
2436 LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2437 
2453 LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2454 
2468 LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2469  struct ly_set **set);
2470 
2485 LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2486  const struct lyxp_var *vars, struct ly_set **set);
2487 
2504 LIBYANG_API_DECL LY_ERR lyd_find_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2505  LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2506 
2518 LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2519 
2532 LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2533  const struct lyxp_var *vars, ly_bool *result);
2534 
2550 LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2551  struct lyd_node **match);
2552 
2563 LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2564 
2573 LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2574 
2583 LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2584 
2592 LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2593 
2601 LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2602 
2603 #ifdef __cplusplus
2604 }
2605 #endif
2606 
2607 #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:543
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:533
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition: tree_data.h:527
@ LYD_ANYDATA_DATATREE
Definition: tree_data.h:544
@ LYD_ANYDATA_JSON
Definition: tree_data.h:551
@ LYD_ANYDATA_XML
Definition: tree_data.h:550
@ LYD_ANYDATA_LYB
Definition: tree_data.h:552
@ LYD_ANYDATA_STRING
Definition: tree_data.h:547
@ LYD_LYB
Definition: tree_data.h:537
@ LYD_XML
Definition: tree_data.h:535
@ LYD_UNKNOWN
Definition: tree_data.h:534
@ LYD_JSON
Definition: tree_data.h:536
LY_ERR
libyang's error codes returned by the libyang functions.
Definition: log.h:244
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node,...
Definition: set.h:46
#define LYS_NOTIF
Definition: tree_schema.h:250
#define LYS_RPC
Definition: tree_schema.h:248
#define LYS_CONTAINER
Definition: tree_schema.h:239
#define LYS_ACTION
Definition: tree_schema.h:249
#define LYS_LIST
Definition: tree_schema.h:243
uint16_t nodetype
Definition: tree_schema.h:1651
struct lys_module * module
Definition: tree_schema.h:1432
struct ly_ctx * ctx
Definition: tree_schema.h:2342
Available YANG schema tree structures representing YANG module.
Definition: tree_schema.h:2341
YANG extension instance.
Definition: tree_schema.h:1429
YANG identity-stmt.
Definition: tree_schema.h:1462
Compiled YANG data node.
Definition: tree_schema.h:1650
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition: tree.h:235
Logger manipulation routines and error definitions.
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:27
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:755
struct lyd_node * next
Definition: tree_data.h:806
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...
struct lyd_meta * next
Definition: tree_data.h:724
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:739
LIBYANG_API_DECL void lyd_unlink_siblings(struct lyd_node *node)
Unlink the specified node with all the following siblings.
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:658
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,...
const char * str
Definition: tree_data.h:878
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:2314
@ LYD_PATH_STD_NO_LAST_PRED
Definition: tree_data.h:2317
@ LYD_PATH_STD
Definition: tree_data.h:2315
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.
LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent, struct lyd_node **new_node)
Create a new node in the data tree based on a path. All node types can be created.
struct lyd_value value
Definition: tree_data.h:870
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.
LIBYANG_API_DECL LY_ERR lyd_new_list_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output, struct lyd_node **node,...)
Create a new list node in the data tree.
const struct lysc_type * realtype
Definition: tree_data.h:564
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str)
Change the value of a metadata instance.
char * mem
Definition: tree_data.h:881
LIBYANG_API_DECL struct lyd_node * lyd_first_sibling(const struct lyd_node *node)
Get the first sibling of the given node.
struct lyd_node * tree
Definition: tree_data.h:877
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:754
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:911
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 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, ly_bool clear_dflt, struct lyd_meta **meta)
Create new metadata.
struct lyd_attr * attr
Definition: tree_data.h:1008
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 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....
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:2183
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:880
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_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, struct lyd_node **diff)
Learn the differences between 2 data trees.
LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff)
Add any missing implicit nodes into a data subtree. Default nodes with a false "when" are not added.
LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target, struct lyd_node **match)
Search in the given siblings (NOT recursively) for the first target instance with the same value....
LIBYANG_API_DECL LY_ERR lyd_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:635
LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value, ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, struct lyd_node **node)
Create a new top-level any node defined in the given extension instance.
LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys, ly_bool output, struct lyd_node **node)
Create a new list node in the data tree.
const struct ly_ctx * ctx
Definition: tree_data.h:1009
LIBYANG_API_DECL LY_ERR lyd_new_term_canon(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str, ly_bool output, struct lyd_node **node)
Create a new term node in the data tree.
LIBYANG_API_DECL const struct lyd_node_term * lyd_target(const struct ly_path *path, const struct lyd_node *tree)
Deprecated, use lyd_find_target() instead.
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....
void * original
Definition: tree_data.h:618
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.
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:2095
struct lyd_meta * meta
Definition: tree_data.h:811
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_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 char * name
Definition: tree_data.h:726
uint32_t flags
Definition: tree_data.h:803
LIBYANG_API_DECL int lyd_lyb_data_length(const char *data)
Learn the length of LYB data.
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.
struct lyd_value value
Definition: tree_data.h:727
const struct lysc_node * schema
Definition: tree_data.h:804
struct in6_addr addr
Definition: tree_data.h:681
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 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:706
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 LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node,...)
Create a new top-level list node defined in the given extension instance.
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_list(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output, struct lyd_node **node,...)
Create a new list node in the data tree.
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_find_xpath4(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.
const char * name
Definition: tree_data.h:738
void * prefix_data
Definition: tree_data.h:624
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.
struct lysc_ext_instance * annotation
Definition: tree_data.h:725
const char * zone
Definition: tree_data.h:682
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_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len)
Compare the node's value with the given string value. The string value is first validated according t...
#define LYD_NODE_TERM
Definition: tree_data.h:760
LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value, size_t val_len, struct lyd_node **match)
Search in the given siblings for the first schema instance. Uses hashes - should be used whenever pos...
uint32_t hints
Definition: tree_data.h:1004
LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path, const void *value, uint32_t options, struct lyd_node **node)
Create a new node defined in the given extension instance. In case of anyxml/anydata nodes,...
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...
struct hash_table * children_ht
Definition: tree_data.h:841
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,...
struct ly_opaq_name name
Definition: tree_data.h:752
LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str, ly_bool output, struct lyd_node **node)
Create a new term node in the data tree.
const char * zone
Definition: tree_data.h:659
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_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:799
void * val_prefix_data
Definition: tree_data.h:756
struct in_addr addr
Definition: tree_data.h:666
LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, ly_bool output, struct lyd_node **node)
Create a new any node in the data tree.
LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len)
Change the value of a term (leaf or leaf-list) node to a binary value.
struct lyd_node * prev
Definition: tree_data.h:807
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_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_list_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output, struct lyd_node **node,...)
Create a new list node in the data tree.
struct lyd_node * child
Definition: tree_data.h:840
const char * xml
Definition: tree_data.h:879
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:709
void * priv
Definition: tree_data.h:812
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_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value, size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical)
Check type restrictions applicable to the particular leaf/leaf-list with the given string value.
LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str, struct lyd_node **node)
Create a new top-level term node defined in the given extension instance.
LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, size_t value_len, ly_bool output, struct lyd_node **node)
Create a new term node in the data tree.
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.
char * bitmap
Definition: tree_data.h:632
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.
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:753
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 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:707
union lyd_any_value value
Definition: tree_data.h:910
struct lyd_attr * next
Definition: tree_data.h:751
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_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_dflt, const struct lyd_attr *attr, struct lyd_meta **meta)
Create new metadata from an opaque node attribute if possible.
uint32_t hints
Definition: tree_data.h:620
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:689
size_t orig_len
Definition: tree_data.h:619
LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, 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.
struct lyd_value value
Definition: tree_data.h:616
const char * _canonical
Definition: tree_data.h:561
struct lyd_node_opaq * parent
Definition: tree_data.h:750
void * prefix_data
Definition: tree_data.h:708
LY_VALUE_FORMAT format
Definition: tree_data.h:621
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:805
struct ly_opaq_name name
Definition: tree_data.h:1002
LIBYANG_API_DECL void lyd_unlink_tree(struct lyd_node *node)
Unlink the specified data subtree.
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_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first)
Insert a node into siblings.
struct lyd_node * parent
Definition: tree_data.h:723
const struct lysc_node * ctx_node
Definition: tree_data.h:625
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:737
Generic attribute structure.
Definition: tree_data.h:749
Metadata structure.
Definition: tree_data.h:722
Generic structure for a data node.
Definition: tree_data.h:798
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition: tree_data.h:888
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition: tree_data.h:818
Data node structure for unparsed (opaque) nodes.
Definition: tree_data.h:982
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition: tree_data.h:848
YANG data representation.
Definition: tree_data.h:560
Special lyd_value structure for built-in binary values.
Definition: tree_data.h:642
Special lyd_value structure for built-in bits values.
Definition: tree_data.h:631
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition: tree_data.h:696
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition: tree_data.h:657
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition: tree_data.h:650
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition: tree_data.h:665
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition: tree_data.h:680
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition: tree_data.h:673
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition: tree_data.h:688
Special lyd_value structure for built-in union values.
Definition: tree_data.h:615
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition: tree_data.h:705
union for anydata/anyxml value representation.
Definition: tree_data.h:876
libyang representation of YANG schema trees.