libyang  5.5.3
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 /* socket/ip includes in ly_config.h */
20 
21 #include <stddef.h>
22 #include <stdint.h>
23 #include <time.h>
24 
25 #include "log.h"
26 #include "ly_config.h"
27 #include "tree.h"
28 #include "tree_schema.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 struct ly_ctx;
35 struct ly_path;
36 struct ly_set;
37 struct lyd_node;
38 struct lyd_node_opaq;
39 struct lyd_node_term;
40 struct timespec;
41 struct lyxp_var;
42 struct rb_node;
43 
389 /* *INDENT-OFF* */
390 
416 #define LYD_TREE_DFS_BEGIN(START, ELEM) \
417  { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \
418  for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \
419  (ELEM); \
420  (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0)
421 
437 #define LYD_TREE_DFS_END(START, ELEM) \
438  /* select element for the next run - children first */ \
439  if (LYD_TREE_DFS_continue) { \
440  (LYD_TREE_DFS_next) = NULL; \
441  } else { \
442  (LYD_TREE_DFS_next) = lyd_child(ELEM); \
443  }\
444  if (!(LYD_TREE_DFS_next)) { \
445  /* no children */ \
446  if ((ELEM) == (struct lyd_node *)(START)) { \
447  /* we are done, (START) has no children */ \
448  break; \
449  } \
450  /* try siblings */ \
451  (LYD_TREE_DFS_next) = (ELEM)->next; \
452  } \
453  while (!(LYD_TREE_DFS_next)) { \
454  /* parent is already processed, go to its sibling */ \
455  (ELEM) = (struct lyd_node *)(ELEM)->parent; \
456  /* no siblings, go back through parents */ \
457  if ((ELEM)->parent == (START)->parent) { \
458  /* we are done, no next element to process */ \
459  break; \
460  } \
461  (LYD_TREE_DFS_next) = (ELEM)->next; \
462  } }
463 
471 #define LYD_LIST_FOR_INST(START, SCHEMA, ELEM) \
472  for (lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
473  (ELEM) && ((ELEM)->schema == (SCHEMA)); \
474  (ELEM) = (ELEM)->next)
475 
484 #define LYD_LIST_FOR_INST_SAFE(START, SCHEMA, NEXT, ELEM) \
485  for ((NEXT) = (ELEM) = NULL, lyd_find_sibling_val(START, SCHEMA, NULL, 0, &(ELEM)); \
486  (ELEM) && ((ELEM)->schema == (SCHEMA)) ? ((NEXT) = (ELEM)->next, 1) : 0; \
487  (ELEM) = (NEXT))
488 
489 /* *INDENT-ON* */
490 
494 #define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((const struct lyd_node_opaq *)(node))->ctx)
495 
503 #define LYD_NODE_IS_ALONE(NODE) \
504  (((NODE)->prev == NODE) || \
505  (((NODE)->prev->schema != (NODE)->schema) && (!(NODE)->next || ((NODE)->schema != (NODE)->next->schema))))
506 
511 typedef enum {
516 } LYD_FORMAT;
517 
523 struct lyd_value {
524  const char *_canonical;
527  const struct lysc_type *realtype;
535  union {
536  int8_t boolean;
537  int64_t dec64;
538  int8_t int8;
539  int16_t int16;
540  int32_t int32;
541  int64_t int64;
542  uint8_t uint8;
543  uint16_t uint16;
544  uint32_t uint32;
545  uint64_t uint64;
546  struct lysc_type_bitenum_item *enum_item;
547  struct lysc_ident *ident;
548  struct ly_path *target;
550  struct lyd_value_union *subvalue;
552  void *dyn_mem;
553  uint8_t fixed_mem[LYD_VALUE_FIXED_MEM_SIZE];
554  };
556 };
557 
566 #define LYD_VALUE_GET(value, type_val) \
567  ((sizeof *(type_val) > LYD_VALUE_FIXED_MEM_SIZE) \
568  ? ((type_val) = (((value)->dyn_mem))) \
569  : ((type_val) = ((void *)((value)->fixed_mem))))
570 
579  struct lyd_value value;
581  void *original;
582  uint64_t orig_size_bits;
583  uint32_t hints;
587  void *prefix_data;
588  const struct lysc_node *ctx_node;
589 };
590 
595  char *bitmap;
600 };
601 
606  void *data;
607  uint32_t size;
608 };
609 
614  struct in_addr addr;
615 };
616 
621  struct in_addr addr;
622  const char *zone;
623 };
624 
629  struct in_addr addr;
630  uint8_t prefix;
631 };
632 
637  struct in6_addr addr;
638 };
639 
644  struct in6_addr addr;
645  const char *zone;
646 };
647 
652  struct in6_addr addr;
653  uint8_t prefix;
654 };
655 
660  time_t time;
661  char *fractions_s;
663 };
664 
669  time_t time;
671 };
672 
677  time_t time;
678 };
679 
684  uint32_t seconds;
685  char *fractions_s;
687 };
688 
693  uint32_t seconds;
694  char *fractions_s;
695 };
696 
701  struct lyxp_expr *exp;
702  const struct ly_ctx *ctx;
703  void *prefix_data;
705 };
706 
711  struct rb_node *rbt;
712 };
713 
721 struct ly_opaq_name {
722  const char *name;
723  const char *prefix;
725  union {
726  const char *module_ns;
727  const char *module_name;
728  };
729 };
730 
734 struct lyd_attr {
736  struct lyd_attr *next;
738  const char *value;
739  uint32_t hints;
742 };
743 
744 #define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF)
745 #define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST)
746 #define LYD_NODE_ANY (LYS_ANYDATA)
773 #define LYD_DEFAULT 0x01
774 #define LYD_WHEN_TRUE 0x02
775 #define LYD_NEW 0x04
776 #define LYD_EXT 0x08
783 struct lyd_node {
784  uint32_t hash;
788  uint32_t flags;
789  const struct lysc_node *schema;
790  struct lyd_node *parent;
791  struct lyd_node *next;
792  struct lyd_node *prev;
796  struct lyd_meta *meta;
797  void *priv;
798 };
799 
804  union {
805  struct lyd_node node;
807  struct {
808  uint32_t hash;
813  uint32_t flags;
814  const struct lysc_node *schema;
815  struct lyd_node *parent;
816  struct lyd_node *next;
817  struct lyd_node *prev;
821  struct lyd_meta *meta;
822  void *priv;
823  };
824  };
826  struct lyd_node *child;
827  struct ly_ht *children_ht;
829 #define LYD_HT_MIN_ITEMS 4
830 };
831 
836  union {
837  struct lyd_node node;
839  struct {
840  uint32_t hash;
845  uint32_t flags;
846  const struct lysc_node *schema;
847  struct lyd_node *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 
864 struct lyd_node_any {
865  union {
866  struct lyd_node node;
868  struct {
869  uint32_t hash;
874  uint32_t flags;
875  const struct lysc_node *schema;
876  struct lyd_node *parent;
877  struct lyd_node *next;
878  struct lyd_node *prev;
882  struct lyd_meta *meta;
883  void *priv;
884  };
885  };
887  struct lyd_node *child;
888  struct ly_ht *children_ht;
889  const char *value;
890  uint32_t hints;
892 };
893 
900 #define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
901 
911 #define LYD_VALHINT_STRING 0x0001
912 #define LYD_VALHINT_DECNUM 0x0002
913 #define LYD_VALHINT_OCTNUM 0x0004
914 #define LYD_VALHINT_HEXNUM 0x0008
915 #define LYD_VALHINT_NUM64 0x0010
916 #define LYD_VALHINT_BOOLEAN 0x0020
917 #define LYD_VALHINT_EMPTY 0x0040
918 #define LYD_VALHINT_STRING_DATATYPES 0x0080
932 #define LYD_NODEHINT_LIST 0x1000
933 #define LYD_NODEHINT_LEAFLIST 0x2000
934 #define LYD_NODEHINT_CONTAINER 0x4000
949 #define LYD_HINT_DATA 0xFFF3
953 #define LYD_HINT_SCHEMA 0xFFFF
964 struct lyd_node_opaq {
965  union {
966  struct lyd_node node;
968  struct {
969  uint32_t hash;
970  uint32_t flags;
971  const struct lysc_node *schema;
972  struct lyd_node *parent;
973  struct lyd_node *next;
974  struct lyd_node *prev;
978  struct lyd_meta *meta;
979  void *priv;
980  };
981  };
983  struct lyd_node *child;
985  struct ly_opaq_name name;
986  const char *value;
987  uint32_t hints;
988  LY_VALUE_FORMAT format;
989  void *val_prefix_data;
991  struct lyd_attr *attr;
992  const struct ly_ctx *ctx;
993 };
999  const struct lyd_node_term *node;
1000  const struct lyd_node_term **leafref_nodes;
1006  const struct lyd_node_term **target_nodes;
1009 };
1010 
1018 #define lyd_parent(node) ((node) ? (node)->parent : NULL)
1019 
1031 static inline struct lyd_node *
1032 lyd_child(const struct lyd_node *node)
1033 {
1034  if (!node) {
1035  return NULL;
1036  }
1037 
1038  if (!node->schema) {
1039  /* opaq node */
1040  return ((const struct lyd_node_opaq *)node)->child;
1041  }
1042 
1044  return ((const struct lyd_node_inner *)node)->child;
1045  }
1046 
1047  return NULL;
1048 }
1049 
1061 static inline struct lyd_node *
1062 lyd_child_any(const struct lyd_node *node)
1063 {
1064  if (!node) {
1065  return NULL;
1066  }
1067 
1068  if (!node->schema) {
1069  /* opaq node */
1070  return ((const struct lyd_node_opaq *)node)->child;
1071  }
1072 
1074  return ((const struct lyd_node_inner *)node)->child;
1075  }
1076 
1077  return NULL;
1078 }
1079 
1088 LIBYANG_API_DECL struct lyd_node *lyd_child_no_keys(const struct lyd_node *node);
1089 
1099 LIBYANG_API_DECL const struct lys_module *lyd_owner_module(const struct lyd_node *node);
1100 
1107 LIBYANG_API_DECL const struct lys_module *lyd_node_module(const struct lyd_node *node);
1108 
1115 LIBYANG_API_DECL ly_bool lyd_is_default(const struct lyd_node *node);
1116 
1124 LIBYANG_API_DECL uint32_t lyd_list_pos(const struct lyd_node *instance);
1125 
1132 LIBYANG_API_DECL struct lyd_node *lyd_first_sibling(const struct lyd_node *node);
1133 
1143 LIBYANG_API_DECL LY_ERR lyd_parse_opaq_error(const struct lyd_node *node);
1144 
1154 LIBYANG_API_DECL const char *lyd_value_get_canonical(const struct ly_ctx *ctx, const struct lyd_value *value);
1155 
1162 static inline const char *
1163 lyd_get_value(const struct lyd_node *node)
1164 {
1165  if (!node) {
1166  return NULL;
1167  }
1168 
1169  if (!node->schema) {
1170  return ((const struct lyd_node_opaq *)node)->value;
1171  } else if (node->schema->nodetype & LYD_NODE_TERM) {
1172  const struct lyd_value *value = &((const struct lyd_node_term *)node)->value;
1173 
1174  return value->_canonical ? value->_canonical : lyd_value_get_canonical(LYD_CTX(node), value);
1175  }
1176 
1177  return NULL;
1178 }
1179 
1188 LIBYANG_API_DECL LY_ERR lyd_any_value_str(const struct lyd_node *any, LYD_FORMAT format, char **value_str);
1189 
1201 LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const struct lyd_node *child, const char *value,
1202  uint32_t hints);
1203 
1210 LIBYANG_API_DECL const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
1211 
1219 LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta);
1220 
1234 LIBYANG_API_DECL LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name,
1235  ly_bool output, struct lyd_node **node);
1236 
1258 #define LYD_NEW_VAL_OUTPUT 0x01
1260 #define LYD_NEW_VAL_STORE_ONLY 0x02
1261 #define LYD_NEW_VAL_CANON 0x04
1264 #define LYD_NEW_META_CLEAR_DFLT 0x08
1265 #define LYD_NEW_PATH_UPDATE 0x10
1269 #define LYD_NEW_PATH_OPAQ 0x20
1273 #define LYD_NEW_PATH_WITH_OPAQ 0x40
1274 #define LYD_NEW_PATH_ANY_DATATREE 0x80
1275 #define LYD_NEW_ANY_USE_VALUE 0x0100
1291 LIBYANG_API_DECL LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name,
1292  uint32_t options, struct lyd_node **node, ...);
1293 
1307 LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name,
1308  const char *keys, uint32_t options, struct lyd_node **node);
1309 
1323 LIBYANG_API_DECL LY_ERR lyd_new_list3(struct lyd_node *parent, const struct lys_module *module, const char *name,
1324  const void **key_values, uint32_t *value_sizes_bits, uint32_t options, struct lyd_node **node);
1325 
1337 LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name,
1338  const char *value, uint32_t options, struct lyd_node **node);
1339 
1353 LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name,
1354  const struct lyd_node *child, const char *value, uint32_t hints, uint32_t options, struct lyd_node **node);
1355 
1370 LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module,
1371  const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta);
1372 
1385 LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options,
1386  const struct lyd_attr *attr, struct lyd_meta **meta);
1387 
1400 LIBYANG_API_DECL LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1401  const char *prefix, const char *module_name, struct lyd_node **node);
1402 
1415 LIBYANG_API_DECL LY_ERR lyd_new_opaq2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value,
1416  const char *prefix, const char *module_ns, struct lyd_node **node);
1417 
1431 LIBYANG_API_DECL LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *value,
1432  struct lyd_attr **attr);
1433 
1446 LIBYANG_API_DECL LY_ERR lyd_new_attr2(struct lyd_node *parent, const char *module_ns, const char *name, const char *value,
1447  struct lyd_attr **attr);
1448 
1477 LIBYANG_API_DECL LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value,
1478  uint32_t options, struct lyd_node **node);
1479 
1505 LIBYANG_API_DECL LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path,
1506  const void *value, uint64_t value_size_bits, uint32_t any_hints, uint32_t options, struct lyd_node **new_parent,
1507  struct lyd_node **new_node);
1508 
1522 #define LYD_IMPLICIT_NO_STATE 0x01
1523 #define LYD_IMPLICIT_NO_CONFIG 0x02
1524 #define LYD_IMPLICIT_OUTPUT 0x04
1525 #define LYD_IMPLICIT_NO_DEFAULTS 0x08
1538 LIBYANG_API_DECL LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff);
1551 LIBYANG_API_DECL LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options,
1552  struct lyd_node **diff);
1553 
1565 LIBYANG_API_DECL LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module,
1566  uint32_t implicit_options, struct lyd_node **diff);
1567 
1581 LIBYANG_API_DECL LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str);
1582 
1597 LIBYANG_API_DECL LY_ERR lyd_change_term_canon(struct lyd_node *term, const char *val_str);
1598 
1608 LIBYANG_API_DECL LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str);
1609 
1621 LIBYANG_API_DECL LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node);
1622 
1635 LIBYANG_API_DECL LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first);
1636 
1648 LIBYANG_API_DECL LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
1649 
1661 LIBYANG_API_DECL LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
1662 
1670 LIBYANG_API_DECL LY_ERR lyd_unlink_siblings(struct lyd_node *node);
1671 
1679 LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node);
1680 
1686 LIBYANG_API_DECL void lyd_free_all(struct lyd_node *node);
1687 
1693 LIBYANG_API_DECL void lyd_free_siblings(struct lyd_node *node);
1694 
1700 LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node);
1701 
1707 LIBYANG_API_DECL void lyd_free_meta_single(struct lyd_meta *meta);
1708 
1714 LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta);
1715 
1722 LIBYANG_API_DECL void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr);
1723 
1730 LIBYANG_API_DECL void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr);
1731 
1749 LIBYANG_API_DECL LY_ERR lyd_value_validate(const struct lysc_node *schema, const char *value, uint32_t value_len,
1750  const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical);
1751 
1769 LIBYANG_API_DECL LY_ERR lyd_value_validate_dflt(const struct lysc_node *schema, const char *value,
1770  struct lysc_prefix *prefixes, const struct lyd_node *ctx_node, const struct lysc_type **realtype,
1771  const char **canonical);
1772 
1785 LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, uint32_t value_len);
1786 
1793 #define LYD_COMPARE_FULL_RECURSION 0x01 /* Lists and containers are the same only in case all they children
1794  (subtree, so direct as well as indirect children) are the same. By default,
1795  containers are the same in case of the same schema node and lists are the same
1796  in case of equal keys (keyless lists do the full recursion comparison all the time). */
1797 #define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag
1798  changes this behavior and implicit (automatically created default node) and explicit
1799  (explicitly created node with the default value) default nodes are considered different. */
1800 #define LYD_COMPARE_OPAQ 0x04 /* Opaque nodes can normally be never equal to data nodes. Using this flag even
1801  opaque nodes members are compared to data node schema and value and can result
1802  in a match. */
1803 
1816 LIBYANG_API_DECL LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1817 
1829 LIBYANG_API_DECL LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options);
1830 
1841 LIBYANG_API_DECL LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2);
1842 
1855 #define LYD_DUP_RECURSIVE 0x01
1857 #define LYD_DUP_NO_META 0x02
1859 #define LYD_DUP_WITH_PARENTS 0x04
1861 #define LYD_DUP_WITH_FLAGS 0x08
1863 #define LYD_DUP_NO_EXT 0x10
1864 #define LYD_DUP_WITH_PRIV 0x20
1866 #define LYD_DUP_NO_LYDS 0x40
1884 LIBYANG_API_DECL LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
1885  struct lyd_node **dup);
1886 
1900 LIBYANG_API_DECL LY_ERR lyd_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1901  struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
1902 
1914 LIBYANG_API_DECL LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node *parent, uint32_t options,
1915  struct lyd_node **dup);
1916 
1931 LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx,
1932  struct lyd_node *parent, uint32_t options, struct lyd_node **dup);
1933 
1942 LIBYANG_API_DECL LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup);
1943 
1958 #define LYD_MERGE_DESTRUCT 0x01
1959 #define LYD_MERGE_DEFAULTS 0x02
1960 #define LYD_MERGE_WITH_FLAGS 0x04
1984 LIBYANG_API_DECL LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
1985 
2007 LIBYANG_API_DECL LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options);
2008 
2018 typedef LY_ERR (*lyd_merge_cb)(struct lyd_node *trg_node, const struct lyd_node *src_node, void *cb_data);
2019 
2035 LIBYANG_API_DECL LY_ERR lyd_merge_module(struct lyd_node **target, const struct lyd_node *source, const struct lys_module *mod,
2036  lyd_merge_cb merge_cb, void *cb_data, uint16_t options);
2037 
2052 #define LYD_DIFF_DEFAULTS 0x01
2055 #define LYD_DIFF_META 0x02
2086 LIBYANG_API_DECL LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2087  struct lyd_node **diff);
2088 
2101 LIBYANG_API_DECL LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options,
2102  struct lyd_node **diff);
2103 
2112 typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data);
2113 
2130 LIBYANG_API_DECL LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff,
2131  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data);
2132 
2143 LIBYANG_API_DECL LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff);
2144 
2156 #define LYD_DIFF_MERGE_DEFAULTS 0x01
2184 LIBYANG_API_DECL LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff,
2185  const struct lys_module *mod, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2186 
2203 LIBYANG_API_DECL LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent,
2204  const struct lyd_node *src_sibling, lyd_diff_cb diff_cb, void *cb_data, uint16_t options);
2205 
2217 LIBYANG_API_DECL LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff, uint16_t options);
2218 
2228 LIBYANG_API_DECL LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff);
2229 
2233 typedef enum {
2234  LYD_PATH_STD,
2238 } LYD_PATH_TYPE;
2239 
2255 LIBYANG_API_DECL char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen);
2256 
2266 LIBYANG_API_DECL struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module,
2267  const char *name);
2268 
2280 LIBYANG_API_DECL LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target,
2281  struct lyd_node **match);
2282 
2307 LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema,
2308  const char *key_or_value, uint32_t val_len, struct lyd_node **match);
2309 
2321 LIBYANG_API_DECL LY_ERR lyd_find_sibling_dup_inst_set(const struct lyd_node *siblings, const struct lyd_node *target,
2322  struct ly_set **set);
2323 
2334 LIBYANG_API_DECL LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
2335 
2347 LIBYANG_API_DECL LY_ERR lyxp_vars_set(struct lyxp_var **vars, const char *name, const char *value);
2348 
2354 LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars);
2355 
2375 LIBYANG_API_DECL LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set);
2376 
2390 LIBYANG_API_DECL LY_ERR lyd_find_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars,
2391  struct ly_set **set);
2392 
2410 LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath,
2411  LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set);
2412 
2424 LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result);
2425 
2438 LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath,
2439  const struct lyxp_var *vars, ly_bool *result);
2440 
2456 LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod,
2457  const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result);
2458 
2462 typedef enum {
2464  LY_XPATH_STRING,
2465  LY_XPATH_NUMBER,
2467 } LY_XPATH_TYPE;
2468 
2491 LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree,
2492  const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data,
2493  const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string,
2494  long double *number, ly_bool *boolean);
2495 
2505 LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars);
2506 
2524 LIBYANG_API_DECL LY_ERR lyd_find_path(const struct lyd_node *ctx_node, const char *path, ly_bool output,
2525  struct lyd_node **match);
2526 
2537 LIBYANG_API_DECL LY_ERR lyd_find_target(const struct ly_path *path, const struct lyd_node *tree, struct lyd_node **match);
2538 
2544 LIBYANG_API_DECL int ly_time_tz_offset(void);
2545 
2552 LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time);
2553 
2562 LIBYANG_API_DECL LY_ERR ly_time_str2time(const char *value, time_t *time, char **fractions_s);
2563 
2572 LIBYANG_API_DECL LY_ERR ly_time_time2str(time_t time, const char *fractions_s, char **str);
2573 
2581 LIBYANG_API_DECL LY_ERR ly_time_str2ts(const char *value, struct timespec *ts);
2582 
2590 LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str);
2591 
2602 LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record);
2603 
2613 LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree);
2614 
2628 LIBYANG_API_DECL LY_ERR ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string,
2629  uint32_t str_len, void **pat_comp);
2630 
2640 LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, void **pat_comp);
2641 
2647 LIBYANG_API_DECL void ly_pattern_free(void *pat_comp);
2648 
2649 #ifdef __cplusplus
2650 }
2651 #endif
2652 
2653 #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...
Special lyd_value structure for ietf-yang-types date-no-zone values.
Definition: tree_data.h:676
LIBYANG_API_DECL void ly_pattern_free(void *pat_comp)
Free a compiled XML Schema regex pattern.
struct in_addr addr
Definition: tree_data.h:629
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...
Compiled prefix data pair mapping of prefixes to modules. In case the format is LY_VALUE_SCHEMA_RESOL...
Definition: tree_schema.h:1184
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.
struct lysc_type * realtype
Definition: tree_data.h:527
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...
Compiled YANG data node.
Definition: tree_schema.h:1431
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...
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:2042
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, lyd_new_path2 should be used instead, this function expects the value as string.
LIBYANG_API_DECL LY_ERR ly_time_ts2str(const struct timespec *ts, char **str)
Convert timespec into date-and-time string value.
LIBYANG_API_DECL LY_ERR lyd_eval_xpath4(const struct lyd_node *ctx_node, const struct lyd_node *tree, const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, LY_XPATH_TYPE *ret_type, struct ly_set **node_set, char **string, long double *number, ly_bool *boolean)
Evaluate an XPath on data and return the result or convert it first to an expected result type...
#define LYS_CONTAINER
Definition: tree_schema.h:236
Generic prefix and namespace mapping, meaning depends on the format.
Definition: tree_data.h:721
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_value_validate_dflt(const struct lysc_node *schema, const char *value, struct lysc_prefix *prefixes, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical)
Check type restrictions applicable to the particular leaf/leaf-list with the given string value...
const char * zone
Definition: tree_data.h:645
LIBYANG_API_DECL void lyxp_vars_free(struct lyxp_var *vars)
Free the XPath variables.
const char * prefix
Definition: tree_data.h:723
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:621
Generic structure for a data node.
Definition: tree_data.h:783
LIBYANG_API_DECL LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const struct lyd_node *child, const char *value, uint32_t hints, uint32_t options, struct lyd_node **node)
Create a new any node in the data tree.
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.
Special lyd_value structure for ietf-yang-types date values.
Definition: tree_data.h:668
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:784
uint32_t size
Definition: tree_data.h:607
const char * zone
Definition: tree_data.h:622
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:255
struct lyd_node_opaq * parent
Definition: tree_data.h:735
const char * name
Definition: metadata.h:40
void * priv
Definition: tree_data.h:797
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:29
LYD_PATH_TYPE
Types of the different data paths.
Definition: tree_data.h:2261
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 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_list3(struct lyd_node *parent, const struct lys_module *module, const char *name, const void **key_values, uint32_t *value_sizes_bits, uint32_t options, struct lyd_node **node)
Create a new list node in the data tree.
const char * name
Definition: tree_schema.h:1442
void * original
Definition: tree_data.h:581
YANG identity-stmt.
Definition: tree_schema.h:1222
struct lysc_node * parent
Definition: tree_schema.h:1436
libyang representation of YANG schema trees.
Special lyd_value structure for ietf-inet-types ipv4-address values.
Definition: tree_data.h:620
struct rb_node * rbt
Definition: tree_data.h:711
libyang generic macros and functions to work with YANG schema or data trees.
LIBYANG_API_DEF LY_ERR lyd_trim_xpath(struct lyd_node **tree, const char *xpath, const struct lyxp_var *vars)
Evaluate an XPath on data and free all the nodes except the subtrees selected by the expression...
Special lyd_value structure for ietf-inet-types ipv6-address-no-zone values.
Definition: tree_data.h:636
Special lyd_value structure for ietf-inet-types ipv4-address-no-zone values.
Definition: tree_data.h:613
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_any_value_str(const struct lyd_node *any, LYD_FORMAT format, char **value_str)
Get anydata string value.
Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notification...
Definition: tree_data.h:803
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_value value
Definition: metadata.h:41
struct lyd_node * child
Definition: tree_data.h:826
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_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, uint64_t value_size_bits, uint32_t any_hints, 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.
dup realtype
Definition: lyds_tree.c:98
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:652
void * prefix_data
Definition: tree_data.h:703
Special lyd_value structure for ietf-yang-types date-and-time values.
Definition: tree_data.h:659
ly_bool unknown_tz
Definition: tree_data.h:670
uint16_t nodetype
Definition: tree_schema.h:1432
struct lyd_meta * meta
Definition: tree_data.h:796
Data node structure for the terminal data tree nodes - leaves and leaf-lists.
Definition: tree_data.h:835
const char * value
Definition: tree_data.h:889
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_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.
struct lysc_node * schema
Definition: tree_data.h:789
LIBYANG_API_DECL 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_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.
struct lysc_node * ctx_node
Definition: tree_data.h:588
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:737
LIBYANG_API_DECL LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value, uint32_t val_len, struct lyd_node **match)
Search in the given siblings for the first schema instance. Uses hashes - should be used whenever pos...
LIBYANG_API_DECL LY_ERR lyd_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:739
LIBYANG_API_DECL LY_ERR lyd_eval_xpath3(const struct lyd_node *ctx_node, const struct lys_module *cur_mod, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
LIBYANG_API_DECL LY_ERR lyd_new_meta(const struct ly_ctx *ctx, struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str, uint32_t options, struct lyd_meta **meta)
Create a new metadata.
struct lysc_type_bitenum_item ** items
Definition: tree_data.h:598
libyang hash table.
Special lyd_value structure for ietf-inet-types ipv6-address values.
Definition: tree_data.h:643
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:511
LIBYANG_API_DECL struct lysc_node * lyd_node_schema(const struct lyd_node *node)
Get schema node of a data node. Useful especially for opaque nodes.
YANG data representation.
Definition: tree_data.h:523
const char * _canonical
Definition: tree_data.h:524
LY_XPATH_TYPE
XPath result type.
Definition: tree_data.h:2490
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 int ly_time_tz_offset(void)
Get current timezone (including DST setting) UTC (GMT) time offset in seconds.
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 ly_pattern_match(const struct ly_ctx *ctx, const char *pattern, const char *string, uint32_t str_len, void **pat_comp)
Check a string matches an XML Schema regex used in YANG.
Metadata structure.
Definition: metadata.h:36
#define LYS_ANYDATA
Definition: tree_schema.h:242
struct ly_ctx * ctx
Definition: tree_data.h:702
LIBYANG_API_DECL LY_ERR lyd_eval_xpath(const struct lyd_node *ctx_node, const char *xpath, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
LIBYANG_API_DECL 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_dup_siblings(const struct lyd_node *node, struct lyd_node *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are kept...
LIBYANG_API_DECL LY_ERR lyd_new_meta2(const struct ly_ctx *ctx, struct lyd_node *parent, uint32_t options, const struct lyd_attr *attr, struct lyd_meta **meta)
Create new metadata from an opaque node attribute if possible.
LIBYANG_API_DECL struct lys_module * lyd_node_module(const struct lyd_node *node)
Get the module of a node. Useful mainly for opaque nodes.
LIBYANG_API_DECL void lyd_free_tree(struct lyd_node *node)
Free (and unlink) the specified data (sub)tree.
LIBYANG_API_DECL LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys, uint32_t options, struct lyd_node **node)
Create a new list node in the data tree.
const char * name
Definition: tree_data.h:722
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:583
#define LYS_ACTION
Definition: tree_schema.h:246
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()...
Special lyd_value structure for ietf-inet-types ipv4-prefix values.
Definition: tree_data.h:628
LIBYANG_API_DECL LY_ERR lyd_leafref_link_node_tree(const struct lyd_node *tree)
Traverse through data tree including root node siblings and adds leafrefs links to the given nodes...
void * val_prefix_data
Definition: tree_data.h:741
struct lyd_node_term ** target_nodes
Definition: tree_data.h:1012
uint32_t flags
Definition: tree_data.h:788
uint32_t seconds
Definition: tree_data.h:693
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node...
Definition: set.h:47
void * prefix_data
Definition: tree_data.h:587
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:2256
Special lyd_value structure for ietf-yang-types time values.
Definition: tree_data.h:683
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:644
uint32_t seconds
Definition: tree_data.h:684
Special lyd_value structure for lyds tree value.
Definition: tree_data.h:710
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:2140
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 LY_ERR lyd_value_validate(const struct lysc_node *schema, const char *value, uint32_t value_len, const struct lyd_node *ctx_node, const struct lysc_type **realtype, const char **canonical)
Check type restrictions applicable to the particular leaf/leaf-list with the given string value...
LIBYANG_API_DECL 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.
struct lyd_node * child
Definition: tree_data.h:887
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_unlink_siblings(struct lyd_node *node)
Unlink the specified node with all the following siblings.
char * fractions_s
Definition: tree_data.h:694
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:738
Special lyd_value structure for ietf-inet-types ipv6-prefix values.
Definition: tree_data.h:651
Generic attribute structure.
Definition: tree_data.h:734
struct lys_module * module
Definition: tree_schema.h:1435
Special lyd_value structure for ietf-yang-types xpath1.0 values.
Definition: tree_data.h:700
#define LYD_CTX(node)
Macro to get context from a data tree node.
Definition: tree_data.h:494
struct lyd_attr * next
Definition: tree_data.h:736
Special lyd_value structure for ietf-yang-types time-no-zone values.
Definition: tree_data.h:692
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:704
LY_VALUE_FORMAT format
Definition: tree_data.h:740
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. Uses hashes to whatever extent possible.
LIBYANG_API_DECL int ly_time_tz_offset_at(time_t time)
Get UTC (GMT) timezone offset in seconds at a specific timestamp (including DST setting).
struct lyd_node_term * node
Definition: tree_data.h:1005
LY_VALUE_FORMAT
All kinds of supported value formats and prefix mappings to modules.
Definition: tree.h:234
LIBYANG_API_DECL LY_ERR lyd_dup_siblings_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node with any following siblings. Schema references are assi...
#define LYS_NOTIF
Definition: tree_schema.h:247
LIBYANG_API_DECL LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *value, uint32_t options, struct lyd_node **node)
Create a new term node in the data tree.
uint64_t orig_size_bits
Definition: tree_data.h:582
#define LYD_NODE_TERM
Definition: tree_data.h:745
#define LYS_RPC
Definition: tree_schema.h:245
char * bitmap
Definition: tree_data.h:595
struct lyd_value value
Definition: tree_data.h:858
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_dup_single_to_ctx(const struct lyd_node *node, const struct ly_ctx *trg_ctx, struct lyd_node *parent, uint32_t options, struct lyd_node **dup)
Create a copy of the specified data tree node. Schema references are assigned from trg_ctx...
LIBYANG_API_DECL LY_ERR lyd_eval_xpath2(const struct lyd_node *ctx_node, const char *xpath, const struct lyxp_var *vars, ly_bool *result)
Evaluate an XPath on data and return the result converted to boolean.
LIBYANG_API_DECL LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, uint32_t value_len)
Compare the node&#39;s value with the given string value. The string value is first validated according t...
LIBYANG_API_DECL LY_ERR ly_pattern_compile(const struct ly_ctx *ctx, const char *pattern, void **pat_comp)
Compile an XML Schema regex pattern prior to matching.
struct ly_ht * children_ht
Definition: tree_data.h:888
uint32_t hints
Definition: tree_data.h:890
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 &quot;when&quot; 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:970
struct lyxp_expr * exp
Definition: tree_data.h:701
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:864
LIBYANG_API_DECL LY_ERR lyd_any_copy_value(struct lyd_node *trg, const struct lyd_node *child, const char *value, uint32_t hints)
Copy anydata value from one node to another. Target value is freed first.
Logger manipulation routines and error definitions.
LIBYANG_API_DECL void lyd_free_meta_siblings(struct lyd_meta *meta)
Free the metadata instance with any following instances.
struct lyd_node_term ** leafref_nodes
Definition: tree_data.h:1006
Special lyd_value structure for built-in bits values.
Definition: tree_data.h:594
Special lyd_value structure for built-in union values.
Definition: tree_data.h:578
struct lyd_node * prev
Definition: tree_data.h:792
LY_VALUE_FORMAT format
Definition: tree_data.h:584
LIBYANG_API_DECL LY_ERR lyd_unlink_tree(struct lyd_node *node)
Unlink the specified data subtree.
LIBYANG_API_DECL ly_bool lyd_meta_is_internal(const struct lyd_meta *meta)
Check whether metadata are not an instance of internal metadata.
LIBYANG_API_DECL LY_ERR lyd_new_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 &quot;when&quot; 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.
ly_bool unknown_tz
Definition: tree_data.h:686
#define LYS_LIST
Definition: tree_schema.h:240
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 ly_ht * children_ht
Definition: tree_data.h:827
Special lyd_value structure for built-in binary values.
Definition: tree_data.h:605
struct lyd_value value
Definition: tree_data.h:579
LIBYANG_API_DECL LY_ERR lyd_find_xpath3(const struct lyd_node *ctx_node, const struct lyd_node *tree, const char *xpath, LY_VALUE_FORMAT format, void *prefix_data, const struct lyxp_var *vars, struct ly_set **set)
Search in the given data for instances of nodes matching the provided XPath.
struct lyd_node * next
Definition: tree_data.h:791
struct lyd_node * parent
Definition: tree_data.h:790
char * fractions_s
Definition: tree_data.h:685
LIBYANG_API_DECL LY_ERR lyd_leafref_get_links(const struct lyd_node_term *node, const struct lyd_leafref_links_rec **record)
Gets the leafref links record for given node.