libyang  2.0.164
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 
411 /* *INDENT-OFF* */
412 
438 #define LYD_TREE_DFS_BEGIN(START, ELEM) \
439  { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
440  for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
441  (ELEM); \
442  (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
443 
458 #define LYD_TREE_DFS_END(START, ELEM) \
459  /* select element for the next run - children first */ \
460  if (LYD_TREE_DFS_continue) { \
461  (LYD_TREE_DFS_next) = NULL; \
462  } else { \
463  (LYD_TREE_DFS_next) = lyd_child(ELEM); \
464  }\
465  if (!(LYD_TREE_DFS_next)) { \
466  /* no children */ \
467  if ((ELEM) == (struct lyd_node *)(START)) { \
468  /* we are done, (START) has no children */ \
469  break; \
470  } \
471  /* try siblings */ \
472  (LYD_TREE_DFS_next) = (ELEM)->next; \
473  } \
474  while (!(LYD_TREE_DFS_next)) { \
475  /* parent is already processed, go to its sibling */ \
476  (ELEM) = (struct lyd_node *)(ELEM)->parent; \
477  /* no siblings, go back through parents */ \
478  if ((ELEM)->parent == (START)->parent) { \
479  /* we are done, no next element to process */ \
480  break; \
481  } \
482  (LYD_TREE_DFS_next) = (ELEM)->next; \
483  } }
484 
492 #define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
493  for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
494  (ELEM) && ((ELEM)->schema == (SCHEMA)); \
495  (ELEM) = (ELEM)->next)
496 
505 #define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
506  for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
507  (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
508  (ELEM) = (NEXT))
509 
510 /* *INDENT-ON* */
511 
515 #define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
516 
521 typedef enum {
526 } LYD_FORMAT;
527 
531 typedef enum {
542 
548 struct lyd_value {
549  const char *_canonical;
552  const struct lysc_type *realtype;
560  union {
561  int8_t boolean;
562  int64_t dec64;
563  int8_t int8;
564  int16_t int16;
565  int32_t int32;
566  int64_t int64;
567  uint8_t uint8;
568  uint16_t uint16;
569  uint32_t uint32;
570  uint64_t uint64;
571  struct lysc_type_bitenum_item *enum_item;
572  struct lysc_ident *ident;
573  struct ly_path *target;
575  struct lyd_value_union *subvalue;
577  void *dyn_mem;
578  uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
579  };
581 };
582 
591 #define LYD_VALUE_GET(value, type_val) \
592  ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
593  ? ((type_val) = (((value)->dyn_mem))) \
594  : ((type_val) = ((void *)((value)->fixed_mem))))
595 
604  struct lyd_value value;
606  void *original;
607  size_t orig_len;
608  uint32_t hints;
612  void *prefix_data;
613  const struct lysc_node *ctx_node;
614 };
615 
620  char *bitmap;
625 };
626 
631  void *data;
632  size_t size;
633 };
634 
639  struct in_addr addr;
640 };
641 
646  struct in_addr addr;
647  const char *zone;
648 };
649 
654  struct in_addr addr;
655  uint8_t prefix;
656 };
657 
662  struct in6_addr addr;
663 };
664 
669  struct in6_addr addr;
670  const char *zone;
671 };
672 
677  struct in6_addr addr;
678  uint8_t prefix;
679 };
680 
685  time_t time;
686  char *fractions_s;
688 };
689 
694  struct lyxp_expr *exp;
695  const struct ly_ctx *ctx;
696  void *prefix_data;
698 };
699 
710 struct lyd_meta {
711  struct lyd_node *parent;
712  struct lyd_meta *next;
714  const char *name;
715  struct lyd_value value;
716 };
717 
725 struct ly_opaq_name {
726  const char *name;
727  const char *prefix;
728  union {
729  const char *module_ns;
730  const char *module_name;
731  };
732 };
733 
737 struct lyd_attr {
739  struct lyd_attr *next;
741  const char *value;
742  uint32_t hints;
745 };
746 
747 #define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
748 #define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
749 #define LYD_NODE_ANY (LYS_ANYDATA)
776 #define LYD_DEFAULT 0x01
777 #define LYD_WHEN_TRUE 0x02
778 #define LYD_NEW 0x04
779 #define LYD_EXT 0x08
786 struct lyd_node {
787  uint32_t hash;
791  uint32_t flags;
792  const struct lysc_node *schema;
794  struct lyd_node *next;
795  struct lyd_node *prev;
799  struct lyd_meta *meta;
800  void *priv;
801 };
802 
807  union {
808  struct lyd_node node;
809  struct {
810  uint32_t hash;
815  uint32_t flags;
816  const struct lysc_node *schema;
817  struct lyd_node_inner *parent;
818  struct lyd_node *next;
819  struct lyd_node *prev;
823  struct lyd_meta *meta;
824  void *priv;
825  };
826  };
828  struct lyd_node *child;
829  struct hash_table *children_ht;
830 #define LYD_HT_MIN_ITEMS 4
831 };
832 
837  union {
838  struct lyd_node node;
839  struct {
840  uint32_t hash;
845  uint32_t flags;
846  const struct lysc_node *schema;
847  struct lyd_node_inner *parent;
848  struct lyd_node *next;
849  struct lyd_node *prev;
853  struct lyd_meta *meta;
854  void *priv;
855  };
856  };
858  struct lyd_value value;
859 };
860 
865  struct lyd_node *tree;
866  const char *str;
867  const char *xml;
868  const char *json;
869  char *mem;
870 };
871 
876 struct lyd_node_any {
877  union {
878  struct lyd_node node;
879  struct {
880  uint32_t hash;
885  uint32_t flags;
886  const struct lysc_node *schema;
887  struct lyd_node_inner *parent;
888  struct lyd_node *next;
889  struct lyd_node *prev;
893  struct lyd_meta *meta;
894  void *priv;
895  };
896  };
898  union lyd_any_value value;
900 };
901 
908 #define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
909 
919 #define LYD_VALHINT_STRING 0x0001
920 #define LYD_VALHINT_DECNUM 0x0002
921 #define LYD_VALHINT_OCTNUM 0x0004
922 #define LYD_VALHINT_HEXNUM 0x0008
923 #define LYD_VALHINT_NUM64 0x0010
924 #define LYD_VALHINT_BOOLEAN 0x0020
925 #define LYD_VALHINT_EMPTY 0x0040
939 #define LYD_NODEHINT_LIST 0x0080
940 #define LYD_NODEHINT_LEAFLIST 0x0100
955 #define LYD_HINT_DATA 0x01F3
959 #define LYD_HINT_SCHEMA 0x01FF
970 struct lyd_node_opaq {
971  union {
972  struct lyd_node node;
973  struct {
974  uint32_t hash;
975  uint32_t flags;
976  const struct lysc_node *schema;
977  struct lyd_node_inner *parent;
978  struct lyd_node *next;
979  struct lyd_node *prev;
983  struct lyd_meta *meta;
984  void *priv;
985  };
986  };
988  struct lyd_node *child;
990  struct ly_opaq_name name;
991  const char *value;
992  uint32_t hints;
993  LY_VALUE_FORMAT format;
994  void *val_prefix_data;
996  struct lyd_attr *attr;
997  const struct ly_ctx *ctx;
998 };
1007 static inline struct lyd_node *
1008 lyd_parent(const struct lyd_node *node)
1009 {
1010  if (!node || !node->parent) {
1011  return NULL;
1012  }
1013 
1014  return &node->parent->node;
1015 }
1016 
1027 static inline struct lyd_node *
1028 lyd_child(const struct lyd_node *node)
1029 {
1030  if (!node) {
1031  return NULL;
1032  }
1033 
1034  if (!node->schema) {
1035  /* opaq node */
1036  return ((const struct lyd_node_opaq *)node)->child;
1037  }
1038 
1039  switch (node->schema->nodetype) {
1040  case LYS_CONTAINER:
1041  case LYS_LIST:
1042  case LYS_RPC:
1043  case LYS_ACTION:
1044  case LYS_NOTIF:
1045  return ((const struct lyd_node_inner *)node)->child;
1046  default:
1047  return NULL;
1048  }
1049 }
1050 
1061 LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1062 
1072 LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1073 
1080 LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1081 
1089 LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1090 
1097 LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1098 
1106 LIBYANG_API_DECL int lyd_lyb_data_length(const char *data);
1107 
1117 LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1118 
1128 LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1129 
1136 static inline const char *
1137 lyd_get_value(const struct lyd_node *node)
1138 {
1139  if (!node) {
1140  return NULL;
1141  }
1142 
1143  if (!node->schema) {
1144  return ((const struct lyd_node_opaq *)node)->value;
1145  } else if (node->schema->nodetype & LYD_NODE_TERM) {
1146  const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1148  }
1149 
1150  return NULL;
1151 }
1152 
1159 static inline const char *
1160 lyd_get_meta_value(const struct lyd_meta *meta)
1161 {
1162  if (meta) {
1163  const struct lyd_value *value = &meta->value;
1164  return value->_canonical ? value->_canonical : lyd_value_get_canonical(meta->annotation->module->ctx, value);
1165  }
1166 
1167  return NULL;
1168 }
1169 
1177 LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, char **value_str);
1178 
1187 LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value,
1188  LYD_ANYDATA_VALUETYPE value_type);
1189 
1205 LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1206  ly_bool output, struct lyd_node **node);
1207 
1221 LIBYANG_API_DECL LY_ERR lyd_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node);
1222 
1237 LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1238  ly_bool output, struct lyd_node **node, ...);
1239 
1253 LIBYANG_API_DECL LY_ERR lyd_new_list_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1254  ly_bool output, struct lyd_node **node, ...);
1255 
1269 LIBYANG_API_DECL LY_ERR lyd_new_list_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
1270  ly_bool output, struct lyd_node **node, ...);
1271 
1286 LIBYANG_API_DECL LY_ERR lyd_new_ext_list(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node, ...);
1287 
1302 LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1303  const char *keys, ly_bool output, struct lyd_node **node);
1304 
1319 LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1320  const char *val_str, ly_bool output, struct lyd_node **node);
1321 
1335 LIBYANG_API_DECL LY_ERR lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const char *name,
1336  const void *value, size_t value_len, ly_bool output, struct lyd_node **node);
1337 
1350 LIBYANG_API_DECL LY_ERR lyd_new_term_canon(struct lyd_node *parent, const struct lys_module *module, const char *name,
1351  const char *val_str, ly_bool output, struct lyd_node **node);
1352 
1366 LIBYANG_API_DECL LY_ERR lyd_new_ext_term(const struct lysc_ext_instance *ext, const char *name, const char *val_str,
1367  struct lyd_node **node);
1368 
1385 LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1386  const void *value, ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, ly_bool output, struct lyd_node **node);
1387 
1402 LIBYANG_API_DECL LY_ERR lyd_new_ext_any(const struct lysc_ext_instance *ext, const char *name, const void *value,
1403  ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, struct lyd_node **node);
1404 
1419 LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1420  const char *name, const char *val_str, ly_bool clear_dflt, struct lyd_meta **meta);
1421 
1434 LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, ly_bool clear_dflt,
1435  const struct lyd_attr *attr, struct lyd_meta **meta);
1436 
1449 LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1450  const char *prefix, const char *module_name, struct lyd_node **node);
1451 
1464 LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1465  const char *prefix, const char *module_ns, struct lyd_node **node);
1466 
1480 LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1481  struct lyd_attr **attr);
1482 
1495 LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1496  struct lyd_attr **attr);
1497 
1511 #define LYD_NEW_PATH_UPDATE 0x01
1515 #define LYD_NEW_PATH_OUTPUT 0x02
1517 #define LYD_NEW_PATH_OPAQ 0x04
1520 #define LYD_NEW_PATH_BIN_VALUE 0x08
1522 #define LYD_NEW_PATH_CANON_VALUE 0x10
1552 LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1553  uint32_t options, struct lyd_node **node);
1554 
1575 LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value,
1576  size_t value_len, LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent,
1577  struct lyd_node **new_node);
1578 
1597 LIBYANG_API_DECL LY_ERR lyd_new_ext_path(struct lyd_node *parent, const struct lysc_ext_instance *ext, const char *path,
1598  const void *value, uint32_t options, struct lyd_node **node);
1599 
1613 #define LYD_IMPLICIT_NO_STATE 0x01
1614 #define LYD_IMPLICIT_NO_CONFIG 0x02
1615 #define LYD_IMPLICIT_OUTPUT 0x04
1616 #define LYD_IMPLICIT_NO_DEFAULTS 0x08
1629 LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1642 LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1643  struct lyd_node **diff);
1644 
1656 LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1657  uint32_t implicit_options, struct lyd_node **diff);
1658 
1672 LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1673 
1688 LIBYANG_API_DECL LY_ERR lyd_change_term_bin(struct lyd_node *term, const void *value, size_t value_len);
1689 
1704 LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1705 
1715 LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1716 
1728 LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1729 
1742 LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1743 
1755 LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1756 
1768 LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1769 
1775 LIBYANG_API_DECL void lyd_unlink_siblings(struct lyd_node *node);
1776 
1782 LIBYANG_API_DECL void lyd_unlink_tree(struct lyd_node *node);
1783 
1789 LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1790 
1796 LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1797 
1803 LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1804 
1810 LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1811 
1817 LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1818 
1825 LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1826 
1833 LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1834 
1853 LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lysc_node *schema, const char *value,
1854  size_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1855 
1868 LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len);
1869 
1876 #define LYD_COMPARE_FULL_RECURSION 0x01 /* lists and containers are the same only in case all they children
1877  (subtree, so direct as well as indirect children) are the same. By default,
1878  containers are the same in case of the same schema node and lists are the same
1879  in case of equal keys (keyless lists do the full recursion comparison all the time). */
1880 #define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1881  changes this behavior and implicit (automatically created default node) and explicit
1882  (explicitly created node with the default value) default nodes are considered different. */
1883 
1896 LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1897 
1909 LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1910 
1921 LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1922 
1935 #define LYD_DUP_RECURSIVE 0x01
1937 #define LYD_DUP_NO_META 0x02
1938 #define LYD_DUP_WITH_PARENTS 0x04
1940 #define LYD_DUP_WITH_FLAGS 0x08
1956 LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
1957  struct lyd_node **dup);
1971 LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1972  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
1973 
1985 LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options,
1986  struct lyd_node **dup);
1987 
2001 LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
2002  struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup);
2003 
2012 LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
2013 
2028 #define LYD_MERGE_DESTRUCT 0x01
2029 #define LYD_MERGE_DEFAULTS 0x02
2030 #define LYD_MERGE_WITH_FLAGS 0x04
2054 LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2055 
2077 LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2078 
2088 typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2089 
2105 LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2106  lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2119 #define LYD_DIFF_DEFAULTS 0x01
2150 LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2151  struct lyd_node **diff);
2152 
2165 LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2166  struct lyd_node **diff);
2167 
2176 typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2177 
2194 LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2195  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2196 
2207 LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2208 
2220 #define LYD_DIFF_MERGE_DEFAULTS 0x01
2248 LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2249  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2250 
2267 LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2268  const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2269 
2281 LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2282 
2292 LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2293 
2302 LIBYANG_API_DECL const struct lyd_node_term *lyd_target(const struct ly_path *path, const struct lyd_node *tree);
2303 
2307 typedef enum {
2308  LYD_PATH_STD,
2312 } LYD_PATH_TYPE;
2313 
2325 LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2326 
2336 LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2337  const char *name);
2338 
2350 LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2351  struct lyd_node **match);
2352 
2377 LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2378  const char *key_or_value, size_t val_len, struct lyd_node **match);
2379 
2391 LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2392  struct ly_set **set);
2393 
2404 LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2405 
2417 LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2418 
2424 LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2425 
2441 LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2442 
2456 LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2457  struct ly_set **set);
2458 
2473 LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2474  const struct lyxp_var *vars, struct ly_set **set);
2475 
2492 LIBYANG_API_DECL LY_ERR lyd_find_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2493  LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2494 
2506 LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2507 
2520 LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2521  const struct lyxp_var *vars, ly_bool *result);
2522 
2538 LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2539  struct lyd_node **match);
2540 
2551 LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2552 
2561 LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2562 
2571 LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2572 
2580 LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2581 
2589 LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2590 
2591 #ifdef __cplusplus
2592 }
2593 #endif
2594 
2595 #endif /* LY_TREE_DATA_H_ */
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 in_addr addr
Definition: tree_data.h:654
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_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.
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_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.
Compiled YANG data node.
Definition: tree_schema.h:1666
LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options)
Merge the source data tree with any following siblings into the target data tree. Merge may not be co...
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str)
Convert timespec into date-and-time string value.
struct ly_ctx * ctx
Definition: tree_schema.h:2357
union for anydata/anyxml value representation.
Definition: tree_data.h:864
#define LYS_CONTAINER
Definition: tree_schema.h:239
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.
Generic prefix and namespace mapping, meaning depends on the format.
Definition: tree_data.h:725
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...
const char * zone
Definition: tree_data.h:670
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
const char * str
Definition: tree_data.h:866
const char * prefix
Definition: tree_data.h:727
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.
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 in_addr addr
Definition: tree_data.h:646
Generic structure for a data node.
Definition: tree_data.h:786
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.
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.
LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2)
Compare 2 metadata.
uint32_t hash
Definition: tree_data.h:787
const char * xml
Definition: tree_data.h:867
const char * zone
Definition: tree_data.h:647
YANG extension instance.
Definition: tree_schema.h:1445
struct lyd_node_opaq * parent
Definition: tree_data.h:738
void * priv
Definition: tree_data.h:800
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:27
LYD_PATH_TYPE
Types of the different data paths.
Definition: tree_data.h:2328
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.
const struct lysc_node * schema
Definition: tree_data.h:792
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.
void * original
Definition: tree_data.h:606
YANG identity-stmt.
Definition: tree_schema.h:1478
libyang representation of YANG schema trees.
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition: tree_data.h:645
libyang generic macros and functions to work with YANG schema or data trees.
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.
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition: tree_data.h:661
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition: tree_data.h:638
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.
size_t orig_len
Definition: tree_data.h:607
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition: tree_data.h:806
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.
struct lyd_node * child
Definition: tree_data.h:828
LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node)
Insert a child into a parent.
const struct lysc_node * ctx_node
Definition: tree_data.h:613
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).
struct in6_addr addr
Definition: tree_data.h:677
void * prefix_data
Definition: tree_data.h:696
struct lysc_ext_instance * annotation
Definition: tree_data.h:713
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition: tree_data.h:684
struct lys_module * module
Definition: tree_schema.h:1448
uint16_t nodetype
Definition: tree_schema.h:1667
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.
struct lyd_meta * meta
Definition: tree_data.h:799
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition: tree_data.h:836
struct lyd_node_inner * parent
Definition: tree_data.h:793
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...
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_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_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_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options)
Merge 2 diffs into each other.
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.
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...
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 ly_time_str2ts(const char *value, struct timespec *ts)
Convert date-and-time from string to timespec.
struct ly_opaq_name name
Definition: tree_data.h:740
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().
uint32_t hints
Definition: tree_data.h:742
Metadata structure.
Definition: tree_data.h:710
struct lysc_type_bitenum_item ** items
Definition: tree_data.h:623
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition: tree_data.h:668
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:2107
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:521
YANG data representation.
Definition: tree_data.h:548
const char * _canonical
Definition: tree_data.h:549
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_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 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_new_ext_inner(const struct lysc_ext_instance *ext, const char *name, struct lyd_node **node)
Create a new top-level inner node defined in the given extension instance.
LIBYANG_API_DECL LY_ERR lyd_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.
const struct lysc_type * realtype
Definition: tree_data.h:552
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_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options)
Compare 2 lists of siblings if they are equivalent.
LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str)
Change the value of a metadata instance.
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.
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. Generally, in case of augments it is the target module, recursively, otherwise it is the module where the data node is defined.
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...
LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node)
Free (and unlink) the specified data (sub)tree.
const char * name
Definition: tree_data.h:726
LIBYANG_API_DECL struct lyd_node * lyd_first_sibling(const struct lyd_node *node)
Get the first sibling of the given node.
uint32_t hints
Definition: tree_data.h:608
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.
#define LYS_ACTION
Definition: tree_schema.h:249
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_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_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.
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition: tree_data.h:653
const struct ly_ctx * ctx
Definition: tree_data.h:695
LIBYANG_API_DECL int lyd_lyb_data_length(const char *data)
Learn the length of LYB data.
void * val_prefix_data
Definition: tree_data.h:744
uint32_t flags
Definition: tree_data.h:791
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node...
Definition: set.h:46
void * prefix_data
Definition: tree_data.h:612
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.
LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta)
Free a single metadata instance.
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()...
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()...
Available YANG schema tree structures representing YANG module.
Definition: tree_schema.h:2356
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.
struct in6_addr addr
Definition: tree_data.h:669
char * mem
Definition: tree_data.h:869
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 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 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_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.
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 void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free the attribute with any following attributes.
const char * json
Definition: tree_data.h:868
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:2197
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_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...
const char * value
Definition: tree_data.h:741
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition: tree_data.h:676
Generic attribute structure.
Definition: tree_data.h:737
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition: tree_data.h:693
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition: tree_data.h:515
struct lyd_attr * next
Definition: tree_data.h:739
LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node)
Free all the sibling nodes (preceding as well as succeeding).
LY_VALUE_FORMAT format
Definition: tree_data.h:697
LY_VALUE_FORMAT format
Definition: tree_data.h:743
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.
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 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. Accepts only nodes that are allowed to have several exact same instances. Uses hashes to whatever extent possible.
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition: tree.h:235
#define LYS_NOTIF
Definition: tree_schema.h:250
const char * name
Definition: tree_data.h:714
LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len)
Compare the node&#39;s value with the given string value. The string value is first validated according t...
#define LYD_NODE_TERM
Definition: tree_data.h:748
#define LYS_RPC
Definition: tree_schema.h:248
char * bitmap
Definition: tree_data.h:620
struct lyd_value value
Definition: tree_data.h:858
struct lyd_value value
Definition: tree_data.h:715
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_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_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.
LYD_ANYDATA_VALUETYPE value_type
Definition: tree_data.h:899
LYD_ANYDATA_VALUETYPE
List of possible value types stored in lyd_node_any.
Definition: tree_data.h:531
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_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 void lyd_unlink_siblings(struct lyd_node *node)
Unlink the specified node with all the following siblings.
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_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...
Data node structure for unparsed (opaque) nodes.
Definition: tree_data.h:976
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:247
struct lyxp_expr * exp
Definition: tree_data.h:694
LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr)
Free a single attribute.
Data node structure for the anydata data tree nodes - anydata or anyxml.
Definition: tree_data.h:876
Logger manipulation routines and error definitions.
struct lyd_meta * next
Definition: tree_data.h:712
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_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.
Special lyd_value structure for built-in bits values.
Definition: tree_data.h:619
Special lyd_value structure for built-in union values.
Definition: tree_data.h:603
struct hash_table * children_ht
Definition: tree_data.h:829
struct lyd_node * prev
Definition: tree_data.h:795
LIBYANG_API_DECL void lyd_unlink_tree(struct lyd_node *node)
Unlink the specified data subtree.
LY_VALUE_FORMAT format
Definition: tree_data.h:609
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.
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_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup)
Create a copy of the metadata.
#define LYS_LIST
Definition: tree_schema.h:243
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 context handler.
struct lyd_node * tree
Definition: tree_data.h:865
Special lyd_value structure for built-in binary values.
Definition: tree_data.h:630
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...
struct lyd_value value
Definition: tree_data.h:604
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.
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...
struct lyd_node * next
Definition: tree_data.h:794
struct lyd_node * parent
Definition: tree_data.h:711