Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @file tree_data.h |
| 3 | * @author Radek Krejci <rkrejci@cesnet.cz> |
| 4 | * @brief libyang representation of YANG data trees. |
| 5 | * |
| 6 | * Copyright (c) 2015 - 2019 CESNET, z.s.p.o. |
| 7 | * |
| 8 | * This source code is licensed under BSD 3-Clause License (the "License"). |
| 9 | * You may not use this file except in compliance with the License. |
| 10 | * You may obtain a copy of the License at |
| 11 | * |
| 12 | * https://opensource.org/licenses/BSD-3-Clause |
| 13 | */ |
| 14 | |
| 15 | #ifndef LY_TREE_DATA_H_ |
| 16 | #define LY_TREE_DATA_H_ |
| 17 | |
| 18 | #include <stddef.h> |
| 19 | #include <stdint.h> |
| 20 | |
| 21 | #include "log.h" |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 22 | |
Radek Krejci | ca376bd | 2020-06-11 16:04:06 +0200 | [diff] [blame] | 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 27 | struct ly_ctx; |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 28 | struct ly_path; |
Radek Krejci | 535ea9f | 2020-05-29 16:01:05 +0200 | [diff] [blame] | 29 | struct ly_set; |
| 30 | struct lyd_node; |
| 31 | struct lyd_node_opaq; |
| 32 | struct lys_module; |
| 33 | struct lysc_node; |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 34 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 35 | /** |
| 36 | * @defgroup datatree Data Tree |
Radek Krejci | 2ff0d57 | 2020-05-21 15:27:28 +0200 | [diff] [blame] | 37 | * @ingroup trees |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 38 | * @{ |
| 39 | * |
| 40 | * Data structures and functions to manipulate and access instance data tree. |
| 41 | */ |
| 42 | |
Michal Vasko | 64246d8 | 2020-08-19 12:35:00 +0200 | [diff] [blame] | 43 | /* *INDENT-OFF* */ |
| 44 | |
Michal Vasko | a276cd9 | 2020-08-10 15:10:08 +0200 | [diff] [blame] | 45 | /** |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 46 | * @brief Macro to iterate via all elements in a data tree. This is the opening part |
| 47 | * to the #LYD_TREE_DFS_END - they always have to be used together. |
| 48 | * |
| 49 | * The function follows deep-first search algorithm: |
| 50 | * <pre> |
| 51 | * 1 |
| 52 | * / \ |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 53 | * 2 4 |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 54 | * / / \ |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 55 | * 3 5 6 |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 56 | * </pre> |
| 57 | * |
Radek Krejci | 0935f41 | 2019-08-20 16:15:18 +0200 | [diff] [blame] | 58 | * Use the same parameters for #LYD_TREE_DFS_BEGIN and #LYD_TREE_DFS_END. While |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 59 | * START can be any of the lyd_node* types, ELEM variable must be a pointer to |
| 60 | * the generic struct lyd_node. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 61 | * |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 62 | * To skip a particular subtree, instead of the continue statement, set LYD_TREE_DFS_continue |
| 63 | * variable to non-zero value. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 64 | * |
| 65 | * Use with opening curly bracket '{' after the macro. |
| 66 | * |
| 67 | * @param START Pointer to the starting element processed first. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 68 | * @param ELEM Iterator intended for use in the block. |
| 69 | */ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 70 | #define LYD_TREE_DFS_BEGIN(START, ELEM) \ |
Radek Krejci | 857189e | 2020-09-01 13:26:36 +0200 | [diff] [blame] | 71 | { ly_bool LYD_TREE_DFS_continue = 0; struct lyd_node *LYD_TREE_DFS_next; \ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 72 | for ((ELEM) = (LYD_TREE_DFS_next) = (struct lyd_node *)(START); \ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 73 | (ELEM); \ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 74 | (ELEM) = (LYD_TREE_DFS_next), LYD_TREE_DFS_continue = 0) |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * @brief Macro to iterate via all elements in a tree. This is the closing part |
| 78 | * to the #LYD_TREE_DFS_BEGIN - they always have to be used together. |
| 79 | * |
| 80 | * Use the same parameters for #LYD_TREE_DFS_BEGIN and #LYD_TREE_DFS_END. While |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 81 | * START can be any of the lyd_node* types, ELEM variable must be a pointer |
| 82 | * to the generic struct lyd_node. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 83 | * |
| 84 | * Use with closing curly bracket '}' after the macro. |
| 85 | * |
| 86 | * @param START Pointer to the starting element processed first. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 87 | * @param ELEM Iterator intended for use in the block. |
| 88 | */ |
| 89 | |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 90 | #define LYD_TREE_DFS_END(START, ELEM) \ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 91 | /* select element for the next run - children first */ \ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 92 | if (LYD_TREE_DFS_continue) { \ |
| 93 | (LYD_TREE_DFS_next) = NULL; \ |
| 94 | } else { \ |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 95 | (LYD_TREE_DFS_next) = lyd_child(ELEM); \ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 96 | }\ |
| 97 | if (!(LYD_TREE_DFS_next)) { \ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 98 | /* no children */ \ |
| 99 | if ((ELEM) == (struct lyd_node*)(START)) { \ |
| 100 | /* we are done, (START) has no children */ \ |
| 101 | break; \ |
| 102 | } \ |
| 103 | /* try siblings */ \ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 104 | (LYD_TREE_DFS_next) = (ELEM)->next; \ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 105 | } \ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 106 | while (!(LYD_TREE_DFS_next)) { \ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 107 | /* parent is already processed, go to its sibling */ \ |
| 108 | (ELEM) = (struct lyd_node*)(ELEM)->parent; \ |
| 109 | /* no siblings, go back through parents */ \ |
| 110 | if ((ELEM)->parent == (START)->parent) { \ |
| 111 | /* we are done, no next element to process */ \ |
| 112 | break; \ |
| 113 | } \ |
Michal Vasko | 56daf73 | 2020-08-10 10:57:18 +0200 | [diff] [blame] | 114 | (LYD_TREE_DFS_next) = (ELEM)->next; \ |
| 115 | } } \ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 116 | |
Michal Vasko | 64246d8 | 2020-08-19 12:35:00 +0200 | [diff] [blame] | 117 | /* *INDENT-ON* */ |
| 118 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 119 | /** |
Michal Vasko | 03ff5a7 | 2019-09-11 13:49:33 +0200 | [diff] [blame] | 120 | * @brief Macro to get context from a data tree node. |
| 121 | */ |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 122 | #define LYD_CTX(node) ((node)->schema ? (node)->schema->module->ctx : ((struct lyd_node_opaq *)(node))->ctx) |
Michal Vasko | 03ff5a7 | 2019-09-11 13:49:33 +0200 | [diff] [blame] | 123 | |
| 124 | /** |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 125 | * @brief Data input/output formats supported by libyang [parser](@ref howtodataparsers) and |
Michal Vasko | c8a230d | 2020-08-14 12:17:10 +0200 | [diff] [blame] | 126 | * [printer](@ref howtodataprinters) functions. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 127 | */ |
| 128 | typedef enum { |
Michal Vasko | c8a230d | 2020-08-14 12:17:10 +0200 | [diff] [blame] | 129 | LYD_UNKNOWN = 0, /**< unknown data format, invalid value */ |
| 130 | LYD_XML, /**< XML instance data format */ |
| 131 | LYD_JSON, /**< JSON instance data format */ |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 132 | LYD_LYB /**< LYB instance data format */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 133 | } LYD_FORMAT; |
| 134 | |
| 135 | /** |
Michal Vasko | c8a230d | 2020-08-14 12:17:10 +0200 | [diff] [blame] | 136 | * @brief All kinds of supported prefix mappings to modules. |
| 137 | */ |
| 138 | typedef enum { |
| 139 | LY_PREF_SCHEMA, /**< value prefixes map to YANG import prefixes */ |
Michal Vasko | c979558 | 2020-10-08 16:22:17 +0200 | [diff] [blame] | 140 | LY_PREF_SCHEMA_RESOLVED, /**< value prefixes map to module structures directly */ |
Michal Vasko | c8a230d | 2020-08-14 12:17:10 +0200 | [diff] [blame] | 141 | LY_PREF_XML, /**< value prefixes map to XML namespace prefixes */ |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 142 | LY_PREF_JSON /**< value prefixes map to module names */ |
Michal Vasko | c8a230d | 2020-08-14 12:17:10 +0200 | [diff] [blame] | 143 | } LY_PREFIX_FORMAT; |
| 144 | |
| 145 | /** |
Radek Krejci | 59583bb | 2019-09-11 12:57:55 +0200 | [diff] [blame] | 146 | * @brief List of possible value types stored in ::lyd_node_any. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 147 | */ |
| 148 | typedef enum { |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 149 | LYD_ANYDATA_DATATREE, /**< Value is a pointer to lyd_node structure (first sibling). When provided as input parameter, the pointer |
Radek Krejci | ee4cab2 | 2019-07-17 17:07:47 +0200 | [diff] [blame] | 150 | is directly connected into the anydata node without duplication, caller is supposed to not manipulate |
| 151 | with the data after a successful call (including calling lyd_free() on the provided data) */ |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 152 | LYD_ANYDATA_STRING, /**< Value is a generic string without any knowledge about its format (e.g. anyxml value in JSON encoded |
Radek Krejci | ee4cab2 | 2019-07-17 17:07:47 +0200 | [diff] [blame] | 153 | as string). XML sensitive characters (such as & or \>) are automatically escaped when the anydata |
| 154 | is printed in XML format. */ |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 155 | LYD_ANYDATA_XML, /**< Value is a string containing the serialized XML data. */ |
| 156 | LYD_ANYDATA_JSON, /**< Value is a string containing the data modeled by YANG and encoded as I-JSON. */ |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 157 | LYD_ANYDATA_LYB /**< Value is a memory chunk with the serialized data tree in LYB format. */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 158 | } LYD_ANYDATA_VALUETYPE; |
| 159 | |
| 160 | /** @} */ |
| 161 | |
| 162 | /** |
| 163 | * @brief YANG data representation |
| 164 | */ |
| 165 | struct lyd_value { |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 166 | const char *canonical; /**< Canonical string representation of the value in the dictionary. It is never |
| 167 | NULL and in case of no canonical value, its JSON representation is used instead. */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 168 | union { |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 169 | int8_t boolean; /**< 0 as false, 1 as true */ |
| 170 | int64_t dec64; /**< decimal64: value = dec64 / 10^fraction-digits */ |
Radek Krejci | 8dc4f2d | 2019-07-16 12:24:00 +0200 | [diff] [blame] | 171 | int8_t int8; /**< 8-bit signed integer */ |
| 172 | int16_t int16; /**< 16-bit signed integer */ |
| 173 | int32_t int32; /**< 32-bit signed integer */ |
| 174 | int64_t int64; /**< 64-bit signed integer */ |
| 175 | uint8_t uint8; /**< 8-bit unsigned integer */ |
Michal Vasko | 7c8439f | 2020-08-05 13:25:19 +0200 | [diff] [blame] | 176 | uint16_t uint16; /**< 16-bit unsigned integer */ |
| 177 | uint32_t uint32; /**< 32-bit unsigned integer */ |
| 178 | uint64_t uint64; /**< 64-bit unsigned integer */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 179 | struct lysc_type_bitenum_item *enum_item; /**< pointer to the definition of the enumeration value */ |
Radek Krejci | 849a62a | 2019-05-22 15:29:05 +0200 | [diff] [blame] | 180 | struct lysc_type_bitenum_item **bits_items; /**< list of set pointers to the specification of the set bits ([sized array](@ref sizedarrays)) */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 181 | struct lysc_ident *ident; /**< pointer to the schema definition of the identityref value */ |
Michal Vasko | c8a230d | 2020-08-14 12:17:10 +0200 | [diff] [blame] | 182 | struct ly_path *target; /**< Instance-identifier target path. */ |
| 183 | struct lyd_value_subvalue *subvalue; /** Union value with some metadata. */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 184 | void *ptr; /**< generic data type structure used to store the data */ |
Radek Krejci | 8dc4f2d | 2019-07-16 12:24:00 +0200 | [diff] [blame] | 185 | }; /**< The union is just a list of shorthands to possible values stored by a type's plugin. libyang itself uses the lyd_value::realtype |
| 186 | plugin's callbacks to work with the data. */ |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 187 | |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 188 | const struct lysc_type *realtype; /**< pointer to the real type of the data stored in the value structure. This type can differ from the type |
| 189 | in the schema node of the data node since the type's store plugin can use other types/plugins for |
| 190 | storing data. Speaking about built-in types, this is the case of leafref which stores data as its |
| 191 | target type. In contrast, union type also use its subtype's callbacks, but inside an internal data |
| 192 | lyd_value::subvalue structure, so here is the pointer to the union type. |
| 193 | In general, this type is used to get free callback for this lyd_value structure, so it must reflect |
| 194 | the type used to store data directly in the same lyd_value instance. */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 195 | }; |
| 196 | |
| 197 | /** |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 198 | * @brief Macro for getting the string canonical value from a term node. |
| 199 | * |
| 200 | * @param[in] node Term node with the value. |
| 201 | * @return Canonical value. |
| 202 | */ |
Michal Vasko | b7be7a8 | 2020-08-20 09:09:04 +0200 | [diff] [blame] | 203 | #define LYD_CANON_VALUE(node) ((struct lyd_node_term *)(node))->value.canonical |
Michal Vasko | ba99a3e | 2020-08-18 15:50:05 +0200 | [diff] [blame] | 204 | |
| 205 | /** |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 206 | * @brief Special lyd_value structure for union. |
| 207 | * |
| 208 | * Represents data with multiple types (union). Original value is stored in the main lyd_value:canonical_cache while |
| 209 | * the lyd_value_subvalue::value contains representation according to one of the union's types. |
| 210 | * The lyd_value_subvalue:prefixes provides (possible) mappings from prefixes in the original value to YANG modules. |
| 211 | * These prefixes are necessary to parse original value to the union's subtypes. |
| 212 | */ |
| 213 | struct lyd_value_subvalue { |
| 214 | struct lyd_value value; /**< representation of the value according to the selected union's subtype |
| 215 | (stored as lyd_value::realtype here, in subvalue structure */ |
| 216 | const char *original; /**< Original value in the dictionary. */ |
| 217 | LY_PREFIX_FORMAT format; /**< Prefix format of the value. However, this information is also used to decide |
| 218 | whether a value is valid for the specific format or not on later validations |
| 219 | (instance-identifier in XML looks different than in JSON). */ |
| 220 | void *prefix_data; /**< Format-specific data for prefix resolution (see ::ly_resolve_prefix) */ |
| 221 | uint32_t hints; /**< [Value hints](@ref lydvalhints) from the parser */ |
| 222 | const struct lysc_node *ctx_node; /**< Context schema node. */ |
| 223 | }; |
| 224 | |
| 225 | /** |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 226 | * @brief Metadata structure. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 227 | * |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 228 | * The structure provides information about metadata of a data element. Such attributes must map to |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 229 | * annotations as specified in RFC 7952. The only exception is the filter type (in NETCONF get operations) |
| 230 | * and edit-config's operation attributes. In XML, they are represented as standard XML attributes. In JSON, |
| 231 | * they are represented as JSON elements starting with the '@' character (for more information, see the |
| 232 | * YANG metadata RFC. |
| 233 | * |
| 234 | */ |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 235 | struct lyd_meta { |
| 236 | struct lyd_node *parent; /**< data node where the metadata is placed */ |
| 237 | struct lyd_meta *next; /**< pointer to the next metadata of the same element */ |
| 238 | struct lysc_ext_instance *annotation; /**< pointer to the annotation's definition */ |
| 239 | const char *name; /**< metadata name */ |
| 240 | struct lyd_value value; /**< metadata value representation */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 241 | }; |
| 242 | |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 243 | /** |
| 244 | * @brief Generic prefix and namespace mapping, meaning depends on the format. |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 245 | * |
| 246 | * The union is used as a reference to the data's module and according to the format, it can be used as a key for |
| 247 | * ly_ctx_get_module_implemented_ns() or ly_ctx_get_module_implemented(). While the module reference is always present, |
| 248 | * the id member can be omitted in case it is not present in the source data as a reference to the default namespace. |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 249 | */ |
| 250 | struct ly_prefix { |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 251 | const char *id; /**< identifier used in the qualified name of the item to reference data node namespace */ |
| 252 | union { |
| 253 | const char *module_ns; /**< namespace of the module where the data are supposed to belongs to, used for LYD_XML format. */ |
| 254 | const char *module_name; /**< name of the module where the data are supposed to belongs to, used for LYD_JSON format. */ |
| 255 | }; |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | /** |
| 259 | * @brief Generic attribute structure. |
| 260 | */ |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 261 | struct lyd_attr { |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 262 | struct lyd_node_opaq *parent; /**< data node where the attribute is placed */ |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 263 | struct lyd_attr *next; |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 264 | struct ly_prefix *val_prefs; /**< list of prefixes in the value ([sized array](@ref sizedarrays)) */ |
| 265 | const char *name; |
| 266 | const char *value; |
| 267 | |
Radek Krejci | 5536d28 | 2020-08-04 23:27:44 +0200 | [diff] [blame] | 268 | LYD_FORMAT format; /**< format of the prefixes, only LYD_XML and LYD_JSON values can appear at this place */ |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 269 | uint32_t hints; /**< additional information about from the data source, see the [hints list](@ref lydhints) */ |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 270 | struct ly_prefix prefix; /**< name prefix, it is stored because they are a real pain to generate properly */ |
| 271 | |
| 272 | }; |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 273 | |
Michal Vasko | 1bf0939 | 2020-03-27 12:38:10 +0100 | [diff] [blame] | 274 | #define LYD_NODE_INNER (LYS_CONTAINER|LYS_LIST|LYS_RPC|LYS_ACTION|LYS_NOTIF) /**< Schema nodetype mask for lyd_node_inner */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 275 | #define LYD_NODE_TERM (LYS_LEAF|LYS_LEAFLIST) /**< Schema nodetype mask for lyd_node_term */ |
| 276 | #define LYD_NODE_ANY (LYS_ANYDATA) /**< Schema nodetype mask for lyd_node_any */ |
| 277 | |
| 278 | /** |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 279 | * @defgroup dnodeflags Data node flags |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 280 | * @ingroup datatree |
| 281 | * @{ |
| 282 | * |
| 283 | * Various flags of data nodes. |
| 284 | * |
| 285 | * 1 - container 5 - anydata/anyxml |
| 286 | * 2 - list 6 - rpc/action |
| 287 | * 3 - leaf 7 - notification |
| 288 | * 4 - leaflist |
| 289 | * |
| 290 | * bit name 1 2 3 4 5 6 7 |
| 291 | * ---------------------+-+-+-+-+-+-+-+ |
| 292 | * 1 LYD_DEFAULT |x| |x|x| | | | |
| 293 | * +-+-+-+-+-+-+-+ |
Michal Vasko | 5c4e589 | 2019-11-14 12:31:38 +0100 | [diff] [blame] | 294 | * 2 LYD_WHEN_TRUE |x|x|x|x|x| | | |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 295 | * +-+-+-+-+-+-+-+ |
| 296 | * 3 LYD_NEW |x|x|x|x|x|x|x| |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 297 | * ---------------------+-+-+-+-+-+-+-+ |
| 298 | * |
| 299 | */ |
| 300 | |
Michal Vasko | 5c4e589 | 2019-11-14 12:31:38 +0100 | [diff] [blame] | 301 | #define LYD_DEFAULT 0x01 /**< default (implicit) node */ |
| 302 | #define LYD_WHEN_TRUE 0x02 /**< all when conditions of this node were evaluated to true */ |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 303 | #define LYD_NEW 0x04 /**< node was created after the last validation, is needed for the next validation */ |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 304 | |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 305 | /** @} */ |
| 306 | |
| 307 | /** |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 308 | * @brief Generic structure for a data node. |
| 309 | */ |
| 310 | struct lyd_node { |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 311 | uint32_t hash; /**< hash of this particular node (module name + schema name + key string values if list or |
| 312 | hashes of all nodes of subtree in case of keyless list). Note that while hash can be |
| 313 | used to get know that nodes are not equal, it cannot be used to decide that the |
| 314 | nodes are equal due to possible collisions. */ |
| 315 | uint32_t flags; /**< [data node flags](@ref dnodeflags) */ |
Michal Vasko | ecd62de | 2019-11-13 12:35:11 +0100 | [diff] [blame] | 316 | const struct lysc_node *schema; /**< pointer to the schema definition of this node, note that the target can be not just |
| 317 | ::struct lysc_node but ::struct lysc_action or ::struct lysc_notif as well */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 318 | struct lyd_node_inner *parent; /**< pointer to the parent node, NULL in case of root node */ |
| 319 | struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 320 | struct lyd_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 321 | never NULL. If there is no sibling node, pointer points to the node |
| 322 | itself. In case of the first node, this pointer points to the last |
| 323 | node in the list. */ |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 324 | struct lyd_meta *meta; /**< pointer to the list of metadata of this node */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 325 | |
| 326 | #ifdef LY_ENABLED_LYD_PRIV |
| 327 | void *priv; /**< private user data, not used by libyang */ |
| 328 | #endif |
| 329 | }; |
| 330 | |
| 331 | /** |
Radek Krejci | f3b6fec | 2019-07-24 15:53:11 +0200 | [diff] [blame] | 332 | * @brief Data node structure for the inner data tree nodes - containers, lists, RPCs, actions and Notifications. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 333 | */ |
| 334 | struct lyd_node_inner { |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 335 | uint32_t hash; /**< hash of this particular node (module name + schema name + key string values if list or |
| 336 | hashes of all nodes of subtree in case of keyless list). Note that while hash can be |
| 337 | used to get know that nodes are not equal, it cannot be used to decide that the |
| 338 | nodes are equal due to possible collisions. */ |
| 339 | uint32_t flags; /**< [data node flags](@ref dnodeflags) */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 340 | const struct lysc_node *schema; /**< pointer to the schema definition of this node */ |
| 341 | struct lyd_node_inner *parent; /**< pointer to the parent node, NULL in case of root node */ |
| 342 | struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 343 | struct lyd_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 344 | never NULL. If there is no sibling node, pointer points to the node |
| 345 | itself. In case of the first node, this pointer points to the last |
| 346 | node in the list. */ |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 347 | struct lyd_meta *meta; /**< pointer to the list of metadata of this node */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 348 | |
| 349 | #ifdef LY_ENABLED_LYD_PRIV |
| 350 | void *priv; /**< private user data, not used by libyang */ |
| 351 | #endif |
| 352 | |
| 353 | struct lyd_node *child; /**< pointer to the first child node. */ |
| 354 | struct hash_table *children_ht; /**< hash table with all the direct children (except keys for a list, lists without keys) */ |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 355 | #define LYD_HT_MIN_ITEMS 4 /**< minimal number of children to create lyd_node_inner::children_ht hash table. */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | /** |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 359 | * @brief Data node structure for the terminal data tree nodes - leaves and leaf-lists. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 360 | */ |
| 361 | struct lyd_node_term { |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 362 | uint32_t hash; /**< hash of this particular node (module name + schema name + key string values if list or |
| 363 | hashes of all nodes of subtree in case of keyless list). Note that while hash can be |
| 364 | used to get know that nodes are not equal, it cannot be used to decide that the |
| 365 | nodes are equal due to possible collisions. */ |
| 366 | uint32_t flags; /**< [data node flags](@ref dnodeflags) */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 367 | const struct lysc_node *schema; /**< pointer to the schema definition of this node */ |
| 368 | struct lyd_node_inner *parent; /**< pointer to the parent node, NULL in case of root node */ |
| 369 | struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 370 | struct lyd_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 371 | never NULL. If there is no sibling node, pointer points to the node |
| 372 | itself. In case of the first node, this pointer points to the last |
| 373 | node in the list. */ |
Michal Vasko | 9f96a05 | 2020-03-10 09:41:45 +0100 | [diff] [blame] | 374 | struct lyd_meta *meta; /**< pointer to the list of metadata of this node */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 375 | |
| 376 | #ifdef LY_ENABLED_LYD_PRIV |
| 377 | void *priv; /**< private user data, not used by libyang */ |
| 378 | #endif |
| 379 | |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 380 | struct lyd_value value; /**< node's value representation */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 381 | }; |
| 382 | |
| 383 | /** |
| 384 | * @brief Data node structure for the anydata data tree nodes - anydatas and anyxmls. |
| 385 | */ |
| 386 | struct lyd_node_any { |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 387 | uint32_t hash; /**< hash of this particular node (module name + schema name + key string values if list or |
| 388 | hashes of all nodes of subtree in case of keyless list). Note that while hash can be |
| 389 | used to get know that nodes are not equal, it cannot be used to decide that the |
| 390 | nodes are equal due to possible collisions. */ |
| 391 | uint32_t flags; /**< [data node flags](@ref dnodeflags) */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 392 | const struct lysc_node *schema; /**< pointer to the schema definition of this node */ |
| 393 | struct lyd_node_inner *parent; /**< pointer to the parent node, NULL in case of root node */ |
| 394 | struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 395 | struct lyd_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is |
| 396 | never NULL. If there is no sibling node, pointer points to the node |
| 397 | itself. In case of the first node, this pointer points to the last |
| 398 | node in the list. */ |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 399 | struct lyd_meta *meta; /**< pointer to the list of metadata of this node */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 400 | |
| 401 | #ifdef LY_ENABLED_LYD_PRIV |
| 402 | void *priv; /**< private user data, not used by libyang */ |
| 403 | #endif |
| 404 | |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 405 | union lyd_any_value { |
Radek Krejci | ee4cab2 | 2019-07-17 17:07:47 +0200 | [diff] [blame] | 406 | struct lyd_node *tree; /**< data tree */ |
| 407 | const char *str; /**< Generic string data */ |
| 408 | const char *xml; /**< Serialized XML data */ |
| 409 | const char *json; /**< I-JSON encoded string */ |
| 410 | char *mem; /**< LYD_ANYDATA_LYB memory chunk */ |
| 411 | } value; /**< pointer to the stored value representation of the anydata/anyxml node */ |
| 412 | LYD_ANYDATA_VALUETYPE value_type;/**< type of the data stored as lyd_node_any::value */ |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 413 | }; |
| 414 | |
| 415 | /** |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 416 | * @defgroup lydvalhints Value format hints. Any information about value types encoded in the format |
| 417 | * is hinted this way. |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 418 | * |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 419 | * @{ |
| 420 | */ |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 421 | #define LYD_VALHINT_STRING 0x0001 /**< value is allowed to be a string */ |
| 422 | #define LYD_VALHINT_DECNUM 0x0002 /**< value is allowed to be a decimal number */ |
| 423 | #define LYD_VALHINT_OCTNUM 0x0004 /**< value is allowed to be an octal number */ |
| 424 | #define LYD_VALHINT_HEXNUM 0x0008 /**< value is allowed to be a hexadecimal number */ |
| 425 | #define LYD_VALHINT_NUM64 0x0010 /**< value is allowed to be an int64 or uint64 */ |
| 426 | #define LYD_VALHINT_BOOLEAN 0x0020 /**< value is allowed to be a boolean */ |
| 427 | #define LYD_VALHINT_EMPTY 0x0040 /**< value is allowed to be empty */ |
| 428 | /** |
| 429 | * @} lydvalhints |
| 430 | */ |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 431 | |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 432 | /** |
| 433 | * @defgroup lydnodehints Node type format hints. Any information about node types encoded in the format |
| 434 | * is hinted this way. |
| 435 | * |
| 436 | * @{ |
| 437 | */ |
| 438 | #define LYD_NODEHINT_LIST 0x0080 /**< node is allowed to be a list instance */ |
| 439 | #define LYD_NODEHINT_LEAFLIST 0x0100 /**< node is allowed to be a leaf-list instance */ |
| 440 | #define LYD_NODEHINT_ENVELOPE 0x8000 /**< only found in opaque node hints; node is a special protocol-dependent |
| 441 | RPC/Action/Notification envelope */ |
| 442 | /** |
| 443 | * @} lydnodehints |
| 444 | */ |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 445 | |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 446 | /** |
| 447 | * @defgroup lydhints Value and node type format hints. Any information about value and node types encoded in the format |
| 448 | * is hinted this way. It combines [value hints](@ref lydvalhints) and [node hints](@ref lydnodehints). |
| 449 | * |
| 450 | * @{ |
| 451 | */ |
| 452 | #define LYD_HINT_DATA 0x01F3 /**< special node/value hint to be used for generic data node/value (for cases when |
| 453 | there is no encoding or it does not provide any additional information about |
| 454 | a node/value type); do not combine with specific [value hints](@ref lydvalhints) |
| 455 | or [node hints](@ref lydnodehints). */ |
| 456 | #define LYD_HINT_SCHEMA 0x01FF /**< special node/value hint to be used for generic schema node/value(for cases when |
| 457 | there is no encoding or it does not provide any additional information about |
| 458 | a node/value type); do not combine with specific [value hints](@ref lydvalhints) |
| 459 | or [node hints](@ref lydnodehints). */ |
| 460 | /** |
| 461 | * @} lydhints |
| 462 | */ |
Radek Krejci | 1798aae | 2020-07-14 13:26:06 +0200 | [diff] [blame] | 463 | |
| 464 | /** |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 465 | * @brief Data node structure for unparsed (opaque) nodes. |
| 466 | */ |
| 467 | struct lyd_node_opaq { |
| 468 | uint32_t hash; /**< always 0 */ |
| 469 | uint32_t flags; /**< always 0 */ |
| 470 | const struct lysc_node *schema; /**< always NULL */ |
| 471 | struct lyd_node *parent; /**< pointer to the parent node (NULL in case of root node) */ |
| 472 | struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */ |
| 473 | struct lyd_node *prev; /**< pointer to the previous sibling node (last sibling if there is none) */ |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 474 | struct lyd_attr *attr; /**< pointer to the list of generic attributes of this node */ |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 475 | |
| 476 | #ifdef LY_ENABLED_LYD_PRIV |
| 477 | void *priv; /**< private user data, not used by libyang */ |
| 478 | #endif |
| 479 | |
| 480 | struct lyd_node *child; /**< pointer to the child node (NULL if there are none) */ |
| 481 | const char *name; |
| 482 | LYD_FORMAT format; |
| 483 | struct ly_prefix prefix; /**< name prefix */ |
| 484 | struct ly_prefix *val_prefs; /**< list of prefixes in the value ([sized array](@ref sizedarrays)) */ |
| 485 | const char *value; /**< original value */ |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 486 | uint32_t hints; /**< additional information about from the data source, see the [hints list](@ref lydhints) */ |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 487 | const struct ly_ctx *ctx; /**< libyang context */ |
| 488 | }; |
| 489 | |
| 490 | /** |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 491 | * @brief Get the generic parent pointer of a data node. |
| 492 | * |
| 493 | * @param[in] node Node whose parent pointer to get. |
| 494 | * @return Pointer to the parent node of the @p node. |
| 495 | * @return NULL in case of the top-level node or if the @p node is NULL itself. |
Michal Vasko | 5bfd4be | 2020-06-23 13:26:19 +0200 | [diff] [blame] | 496 | */ |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 497 | struct lyd_node *lyd_parent(const struct lyd_node *node); |
Michal Vasko | 5bfd4be | 2020-06-23 13:26:19 +0200 | [diff] [blame] | 498 | |
| 499 | /** |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 500 | * @brief Get the child pointer of a generic data node. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 501 | * |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 502 | * Decides the node's type and in case it has a children list, returns it. Supports even the opaq nodes (::lyd_node_opaq). |
| 503 | * |
| 504 | * If you need to skip key children, use ::lyd_child_no_keys(). |
| 505 | * |
| 506 | * @param[in] node Node to use. |
| 507 | * @return Pointer to the first child node (if any) of the @p node. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 508 | */ |
Radek Krejci | a1c1e54 | 2020-09-29 16:06:52 +0200 | [diff] [blame] | 509 | struct lyd_node *lyd_child(const struct lyd_node *node); |
| 510 | |
| 511 | /** |
| 512 | * @brief Get the child pointer of a generic data node but skip its keys in case it is ::LYS_LIST. |
| 513 | * |
| 514 | * Decides the node's type and in case it has a children list, returns it. Supports even the opaq nodes (::lyd_node_opaq). |
| 515 | * |
| 516 | * If you need to take key children into account, use ::lyd_child(). |
| 517 | * |
| 518 | * @param[in] node Node to use. |
| 519 | * @return Pointer to the first child node (if any) of the @p node. |
| 520 | */ |
| 521 | struct lyd_node *lyd_child_no_keys(const struct lyd_node *node); |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 522 | |
| 523 | /** |
Michal Vasko | c193ce9 | 2020-03-06 11:04:48 +0100 | [diff] [blame] | 524 | * @brief Get the owner module of the data node. It is the module of the top-level schema node. Generally, |
| 525 | * in case of augments it is the target module, recursively, otherwise it is the module where the data node is defined. |
| 526 | * |
| 527 | * @param[in] node Data node to examine. |
| 528 | * @return Module owner of the node. |
| 529 | */ |
| 530 | const struct lys_module *lyd_owner_module(const struct lyd_node *node); |
| 531 | |
| 532 | /** |
Radek Krejci | 1961125 | 2020-10-04 13:54:53 +0200 | [diff] [blame] | 533 | * @brief Check whether a node value equals to its default one. |
| 534 | * |
| 535 | * @param[in] node Term node to test. |
| 536 | * @return false (no, it is not a default node) or true (yes, it is default) |
| 537 | */ |
| 538 | ly_bool lyd_is_default(const struct lyd_node *node); |
| 539 | |
| 540 | /** |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 541 | * @brief Learn the length of LYB data. |
| 542 | * |
| 543 | * @param[in] data LYB data to examine. |
| 544 | * @return Length of the LYB data chunk, |
| 545 | * @return -1 on error. |
| 546 | */ |
| 547 | int lyd_lyb_data_length(const char *data); |
| 548 | |
| 549 | /** |
Michal Vasko | c000427 | 2020-08-06 08:32:34 +0200 | [diff] [blame] | 550 | * @brief Copy anydata value from one node to another. Target value is freed first. |
| 551 | * |
| 552 | * @param[in,out] trg Target node. |
| 553 | * @param[in] value Source value, may be NULL when the target value is only freed. |
| 554 | * @param[in] value_type Source value type. |
| 555 | * @return LY_ERR value. |
| 556 | */ |
| 557 | LY_ERR lyd_any_copy_value(struct lyd_node *trg, const union lyd_any_value *value, LYD_ANYDATA_VALUETYPE value_type); |
| 558 | |
| 559 | /** |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 560 | * @brief Create a new inner node in the data tree. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 561 | * |
| 562 | * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 563 | * @param[in] module Module of the node being created. If NULL, @p parent module will be used. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 564 | * @param[in] name Schema node name of the new data node. The node can be #LYS_CONTAINER, #LYS_NOTIF, #LYS_RPC, or #LYS_ACTION. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 565 | * @param[out] node Optional created node. |
| 566 | * @return LY_ERR value. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 567 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 568 | LY_ERR lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name, struct lyd_node **node); |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 569 | |
| 570 | /** |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 571 | * @brief Create a new list node in the data tree. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 572 | * |
| 573 | * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 574 | * @param[in] module Module of the node being created. If NULL, @p parent module will be used. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 575 | * @param[in] name Schema node name of the new data node. The node must be #LYS_LIST. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 576 | * @param[out] node Optional created node. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 577 | * @param[in] ... Ordered key values of the new list instance, all must be set. In case of an instance-identifier |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 578 | * or identityref value, the JSON format is expected (module names instead of prefixes). No keys are expected for |
| 579 | * key-less lists. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 580 | * @return LY_ERR value. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 581 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 582 | LY_ERR lyd_new_list(struct lyd_node *parent, const struct lys_module *module, const char *name, struct lyd_node **node, ...); |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 583 | |
| 584 | /** |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 585 | * @brief Create a new list node in the data tree. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 586 | * |
| 587 | * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 588 | * @param[in] module Module of the node being created. If NULL, @p parent module will be used. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 589 | * @param[in] name Schema node name of the new data node. The node must be #LYS_LIST. |
| 590 | * @param[in] keys All key values predicate in the form of "[key1='val1'][key2='val2']...", they do not have to be ordered. |
| 591 | * In case of an instance-identifier or identityref value, the JSON format is expected (module names instead of prefixes). |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 592 | * Use NULL or string of length 0 in case of key-less list. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 593 | * @param[out] node Optional created node. |
| 594 | * @return LY_ERR value. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 595 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 596 | LY_ERR lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 597 | struct lyd_node **node); |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 598 | |
| 599 | /** |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 600 | * @brief Create a new term node in the data tree. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 601 | * |
| 602 | * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 603 | * @param[in] module Module of the node being created. If NULL, @p parent module will be used. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 604 | * @param[in] name Schema node name of the new data node. The node can be #LYS_LEAF or #LYS_LEAFLIST. |
| 605 | * @param[in] val_str String form of the value of the node being created. In case of an instance-identifier or identityref |
| 606 | * value, the JSON format is expected (module names instead of prefixes). |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 607 | * @param[out] node Optional created node. |
| 608 | * @return LY_ERR value. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 609 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 610 | LY_ERR lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 611 | struct lyd_node **node); |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 612 | |
| 613 | /** |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 614 | * @brief Create a new any node in the data tree. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 615 | * |
| 616 | * @param[in] parent Parent node for the node being created. NULL in case of creating a top level element. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 617 | * @param[in] module Module of the node being created. If NULL, @p parent module will be used. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 618 | * @param[in] name Schema node name of the new data node. The node can be #LYS_ANYDATA or #LYS_ANYXML. |
| 619 | * @param[in] value Value to be directly assigned to the node. Expected type is determined by @p value_type. |
| 620 | * @param[in] value_type Type of the provided value in @p value. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 621 | * @param[out] node Optional created node. |
| 622 | * @return LY_ERR value. |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 623 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 624 | LY_ERR lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 625 | LYD_ANYDATA_VALUETYPE value_type, struct lyd_node **node); |
Michal Vasko | 013a818 | 2020-03-03 10:46:53 +0100 | [diff] [blame] | 626 | |
| 627 | /** |
Michal Vasko | d86997b | 2020-05-26 15:19:54 +0200 | [diff] [blame] | 628 | * @brief Create new metadata for a data node. |
| 629 | * |
| 630 | * @param[in] parent Parent node for the metadata being created. |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 631 | * @param[in] module Module of the metadata being created. If NULL, @p name must include module name as the prefix. |
Michal Vasko | d86997b | 2020-05-26 15:19:54 +0200 | [diff] [blame] | 632 | * @param[in] name Annotation name of the new metadata. It can include the annotation module as the prefix. |
| 633 | * If the prefix is specified it is always used but if not specified, @p module must be set. |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 634 | * @param[in] val_str String form of the value of the metadata. In case of an instance-identifier or identityref |
Michal Vasko | d86997b | 2020-05-26 15:19:54 +0200 | [diff] [blame] | 635 | * value, the JSON format is expected (module names instead of prefixes). |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 636 | * @param[out] meta Optional created metadata. |
| 637 | * @return LY_ERR value. |
Michal Vasko | d86997b | 2020-05-26 15:19:54 +0200 | [diff] [blame] | 638 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 639 | LY_ERR lyd_new_meta(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *val_str, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 640 | struct lyd_meta **meta); |
Michal Vasko | d86997b | 2020-05-26 15:19:54 +0200 | [diff] [blame] | 641 | |
| 642 | /** |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 643 | * @brief Create a new opaque node in the data tree. |
| 644 | * |
| 645 | * @param[in] parent Parent node for the node beaing created. NULL in case of creating a top level element. |
| 646 | * @param[in] ctx libyang context. If NULL, @p parent context will be used. |
| 647 | * @param[in] name Node name. |
| 648 | * @param[in] value Node value, may be NULL. |
| 649 | * @param[in] module_name Node module name. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 650 | * @param[out] node Optional created node. |
| 651 | * @return LY_ERR value. |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 652 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 653 | LY_ERR lyd_new_opaq(struct lyd_node *parent, const struct ly_ctx *ctx, const char *name, const char *value, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 654 | const char *module_name, struct lyd_node **node); |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 655 | |
| 656 | /** |
| 657 | * @brief Create new attribute for an opaque data node. |
| 658 | * |
| 659 | * @param[in] parent Parent opaque node for the attribute being created. |
| 660 | * @param[in] module Module name of the attribute being created. There may be none. |
| 661 | * @param[in] name Attribute name. It can include the module name as the prefix. |
| 662 | * @param[in] val_str String value of the attribute. Is stored directly. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 663 | * @param[out] attr Optional created attribute. |
| 664 | * @return LY_ERR value. |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 665 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 666 | LY_ERR lyd_new_attr(struct lyd_node *parent, const char *module_name, const char *name, const char *val_str, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 667 | struct lyd_attr **attr); |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 668 | |
| 669 | /** |
| 670 | * @defgroup pathoptions Data path creation options |
| 671 | * @ingroup datatree |
| 672 | * |
| 673 | * Various options to change lyd_new_path*() behavior. |
| 674 | * |
| 675 | * Default behavior: |
| 676 | * - if the target node already exists (and is not default), an error is returned. |
| 677 | * - the whole path to the target node is created (with any missing parents) if necessary. |
| 678 | * - RPC output schema children are completely ignored in all modules. Input is searched and nodes created normally. |
| 679 | * @{ |
| 680 | */ |
| 681 | |
Radek Krejci | 092e33c | 2020-10-12 15:33:10 +0200 | [diff] [blame] | 682 | #define LYD_NEW_PATH_UPDATE 0x01 /**< If the target node exists, is a leaf, and it is updated with a new value or its |
| 683 | default flag is changed, it is returned. If the target node exists and is not |
| 684 | a leaf or generally no change occurs in the @p parent tree, NULL is returned and |
| 685 | no error set. */ |
| 686 | #define LYD_NEW_PATH_OUTPUT 0x02 /**< Changes the behavior to ignoring RPC/action input schema nodes and using only |
| 687 | output ones. */ |
| 688 | #define LYD_NEW_PATH_OPAQ 0x04 /**< Enables the creation of opaque nodes with some specific rules. If the __last node__ |
| 689 | in the path is not uniquely defined ((leaf-)list without a predicate) or has an |
| 690 | invalid value (leaf/leaf-list), it is created as opaque. */ |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 691 | |
| 692 | /** @} pathoptions */ |
| 693 | |
| 694 | /** |
| 695 | * @brief Create a new node in the data tree based on a path. Cannot be used for anyxml/anydata nodes, |
| 696 | * for those use ::lyd_new_path_any. |
| 697 | * |
| 698 | * If @p path points to a list key and the list instance does not exist, the key value from the predicate is used |
| 699 | * and @p value is ignored. Also, if a leaf-list is being created and both a predicate is defined in @p path |
| 700 | * and @p value is set, the predicate is preferred. |
| 701 | * |
| 702 | * @param[in] parent Data parent to add to/modify, can be NULL. |
| 703 | * @param[in] ctx libyang context, must be set if @p parent is NULL. |
| 704 | * @param[in] path Path to create (TODO ref path). |
| 705 | * @param[in] value Value of the new leaf/leaf-list. For other node types, it is ignored. |
| 706 | * @param[in] options Bitmask of options, see @ref pathoptions. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 707 | * @param[out] node Optional first created node. |
| 708 | * @return LY_ERR value. |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 709 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 710 | LY_ERR lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const char *value, |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 711 | uint32_t options, struct lyd_node **node); |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 712 | |
| 713 | /** |
| 714 | * @brief Create a new node in the data tree based on a path. All node types can be created. |
| 715 | * |
| 716 | * If @p path points to a list key and the list instance does not exist, the key value from the predicate is used |
| 717 | * and @p value is ignored. Also, if a leaf-list is being created and both a predicate is defined in @p path |
| 718 | * and @p value is set, the predicate is preferred. |
| 719 | * |
| 720 | * @param[in] parent Data parent to add to/modify, can be NULL. |
| 721 | * @param[in] ctx libyang context, must be set if @p parent is NULL. |
| 722 | * @param[in] path Path to create (TODO ref path). |
| 723 | * @param[in] value Value of the new leaf/leaf-list/anyxml/anydata. For other node types, it is ignored. |
| 724 | * @param[in] value_type Anyxml/anydata node @p value type. |
| 725 | * @param[in] options Bitmask of options, see @ref pathoptions. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 726 | * @param[out] node Optional first created node. |
| 727 | * @return LY_ERR value. |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 728 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 729 | LY_ERR lyd_new_path_any(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 730 | LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **node); |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 731 | |
| 732 | /** |
| 733 | * @brief Create a new node in the data tree based on a path. All node types can be created. |
| 734 | * |
| 735 | * If @p path points to a list key and the list instance does not exist, the key value from the predicate is used |
| 736 | * and @p value is ignored. Also, if a leaf-list is being created and both a predicate is defined in @p path |
| 737 | * and @p value is set, the predicate is preferred. |
| 738 | * |
| 739 | * @param[in] parent Data parent to add to/modify, can be NULL. |
| 740 | * @param[in] ctx libyang context, must be set if @p parent is NULL. |
| 741 | * @param[in] path Path to create (TODO ref path). |
| 742 | * @param[in] value Value of the new leaf/leaf-list/anyxml/anydata. For other node types, it is ignored. |
| 743 | * @param[in] value_type Anyxml/anydata node @p value type. |
| 744 | * @param[in] options Bitmask of options, see @ref pathoptions. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 745 | * @param[out] new_parent Optional first parent node created. If only one node was created, equals to @p new_node. |
| 746 | * @param[out] new_node Optional last node created. |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 747 | * @return LY_ERR value. |
| 748 | */ |
| 749 | LY_ERR lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path, const void *value, |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 750 | LYD_ANYDATA_VALUETYPE value_type, uint32_t options, struct lyd_node **new_parent, struct lyd_node **new_node); |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 751 | |
| 752 | /** |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 753 | * @defgroup implicitoptions Implicit node creation options |
| 754 | * @ingroup datatree |
| 755 | * |
| 756 | * Various options to change lyd_new_implicit*() behavior. |
| 757 | * |
| 758 | * Default behavior: |
| 759 | * - both configuration and state missing implicit nodes are added. |
| 760 | * - all implicit node types are added (non-presence containers, default leaves, and default leaf-lists). |
| 761 | * @{ |
| 762 | */ |
| 763 | |
Michal Vasko | 44b19a1 | 2020-08-07 09:21:30 +0200 | [diff] [blame] | 764 | #define LYD_IMPLICIT_NO_STATE 0x01 /**< Do not add any implicit state nodes. */ |
| 765 | #define LYD_IMPLICIT_NO_CONFIG 0x02 /**< Do not add any implicit config nodes. */ |
| 766 | #define LYD_IMPLICIT_NO_DEFAULTS 0x04 /**< Do not add any default nodes (leaves/leaf-lists), only non-presence |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 767 | containers. */ |
| 768 | |
| 769 | /** @} implicitoptions */ |
| 770 | |
| 771 | /** |
| 772 | * @brief Add any missing implicit nodes into a data subtree. |
| 773 | * |
| 774 | * @param[in] tree Tree to add implicit nodes into. |
| 775 | * @param[in] implicit_options Options for implicit node creation, see @ref implicitoptions. |
| 776 | * @param[out] diff Optional diff with any created nodes. |
| 777 | * @return LY_ERR value. |
| 778 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 779 | LY_ERR lyd_new_implicit_tree(struct lyd_node *tree, uint32_t implicit_options, struct lyd_node **diff); |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 780 | |
| 781 | /** |
| 782 | * @brief Add any missing implicit nodes. |
| 783 | * |
| 784 | * @param[in,out] tree Tree to add implicit nodes into. |
| 785 | * @param[in] ctx libyang context, must be set only if @p tree is an empty tree. |
| 786 | * @param[in] implicit_options Options for implicit node creation, see @ref implicitoptions. |
| 787 | * @param[out] diff Optional diff with any created nodes. |
| 788 | * @return LY_ERR value. |
| 789 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 790 | LY_ERR lyd_new_implicit_all(struct lyd_node **tree, const struct ly_ctx *ctx, uint32_t implicit_options, struct lyd_node **diff); |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 791 | |
| 792 | /** |
| 793 | * @brief Add any missing implicit nodes of one module. |
| 794 | * |
| 795 | * @param[in,out] tree Tree to add implicit nodes into. |
| 796 | * @param[in] module Module whose implicit nodes to create. |
| 797 | * @param[in] implicit_options Options for implicit node creation, see @ref implicitoptions. |
| 798 | * @param[out] diff Optional diff with any created nodes. |
| 799 | * @return LY_ERR value. |
| 800 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 801 | LY_ERR lyd_new_implicit_module(struct lyd_node **tree, const struct lys_module *module, uint32_t implicit_options, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 802 | struct lyd_node **diff); |
Michal Vasko | a6669ba | 2020-08-06 16:14:26 +0200 | [diff] [blame] | 803 | |
| 804 | /** |
Michal Vasko | 00cbf53 | 2020-06-15 13:58:47 +0200 | [diff] [blame] | 805 | * @brief Change the value of a term (leaf or leaf-list) node. |
| 806 | * |
| 807 | * Node changed this way is always considered explicitly set, meaning its default flag |
| 808 | * is always cleared. |
| 809 | * |
| 810 | * @param[in] term Term node to change. |
| 811 | * @param[in] val_str New value to set, any prefixes are expected in JSON format. |
| 812 | * @return LY_SUCCESS if value was changed, |
| 813 | * @return LY_EEXIST if value was the same and only the default flag was cleared, |
| 814 | * @return LY_ENOT if the values were equal and no change occured, |
| 815 | * @return LY_ERR value on other errors. |
| 816 | */ |
| 817 | LY_ERR lyd_change_term(struct lyd_node *term, const char *val_str); |
| 818 | |
| 819 | /** |
Michal Vasko | 4158635 | 2020-07-13 13:54:25 +0200 | [diff] [blame] | 820 | * @brief Change the value of a metadata instance. |
| 821 | * |
| 822 | * @param[in] ctx libyang context. |
| 823 | * @param[in] meta Metadata to change. |
| 824 | * @param[in] val_str New value to set, any prefixes are expected in JSON format. |
| 825 | * @return LY_SUCCESS if value was changed, |
| 826 | * @return LY_ENOT if the values were equal and no change occured, |
| 827 | * @return LY_ERR value on other errors. |
| 828 | */ |
| 829 | LY_ERR lyd_change_meta(struct lyd_meta *meta, const char *val_str); |
| 830 | |
| 831 | /** |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 832 | * @brief Insert a child into a parent. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 833 | * |
| 834 | * - if the node is part of some other tree, it is automatically unlinked. |
| 835 | * - if the node is the first node of a node list (with no parent), all the subsequent nodes are also inserted. |
| 836 | * |
| 837 | * @param[in] parent Parent node to insert into. |
| 838 | * @param[in] node Node to insert. |
| 839 | * @return LY_SUCCESS on success. |
| 840 | * @return LY_ERR error on error. |
| 841 | */ |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 842 | LY_ERR lyd_insert_child(struct lyd_node *parent, struct lyd_node *node); |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 843 | |
| 844 | /** |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 845 | * @brief Insert a node into siblings. |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 846 | * |
| 847 | * - if the node is part of some other tree, it is automatically unlinked. |
| 848 | * - if the node is the first node of a node list (with no parent), all the subsequent nodes are also inserted. |
| 849 | * |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 850 | * @param[in] sibling Siblings to insert into, can even be NULL. |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 851 | * @param[in] node Node to insert. |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 852 | * @param[out] first Optionally return the first sibling after insertion. Can be the address of @p sibling. |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 853 | * @return LY_SUCCESS on success. |
| 854 | * @return LY_ERR error on error. |
| 855 | */ |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 856 | LY_ERR lyd_insert_sibling(struct lyd_node *sibling, struct lyd_node *node, struct lyd_node **first); |
Michal Vasko | b1b5c26 | 2020-03-05 14:29:47 +0100 | [diff] [blame] | 857 | |
| 858 | /** |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 859 | * @brief Insert a node before another node, can be used only for user-ordered nodes. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 860 | * |
| 861 | * - if the node is part of some other tree, it is automatically unlinked. |
| 862 | * - if the node is the first node of a node list (with no parent), all the subsequent nodes are also inserted. |
| 863 | * |
| 864 | * @param[in] sibling Sibling node to insert before. |
| 865 | * @param[in] node Node to insert. |
| 866 | * @return LY_SUCCESS on success. |
| 867 | * @return LY_ERR error on error. |
| 868 | */ |
| 869 | LY_ERR lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node); |
| 870 | |
| 871 | /** |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 872 | * @brief Insert a node after another node, can be used only for user-ordered nodes. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 873 | * |
| 874 | * - if the node is part of some other tree, it is automatically unlinked. |
| 875 | * - if the node is the first node of a node list (with no parent), all the subsequent nodes are also inserted. |
| 876 | * |
| 877 | * @param[in] sibling Sibling node to insert after. |
| 878 | * @param[in] node Node to insert. |
| 879 | * @return LY_SUCCESS on success. |
| 880 | * @return LY_ERR error on error. |
| 881 | */ |
| 882 | LY_ERR lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node); |
| 883 | |
| 884 | /** |
| 885 | * @brief Unlink the specified data subtree. |
| 886 | * |
| 887 | * @param[in] node Data tree node to be unlinked (together with all the children). |
| 888 | */ |
| 889 | void lyd_unlink_tree(struct lyd_node *node); |
| 890 | |
| 891 | /** |
Radek Krejci | b0849a2 | 2019-07-25 12:31:04 +0200 | [diff] [blame] | 892 | * @brief Free all the nodes (even parents of the node) in the data tree. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 893 | * |
| 894 | * @param[in] node Any of the nodes inside the tree. |
| 895 | */ |
| 896 | void lyd_free_all(struct lyd_node *node); |
| 897 | |
| 898 | /** |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 899 | * @brief Free all the sibling nodes (preceding as well as succeeding). |
Radek Krejci | b0849a2 | 2019-07-25 12:31:04 +0200 | [diff] [blame] | 900 | * |
| 901 | * @param[in] node Any of the sibling nodes to free. |
| 902 | */ |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 903 | void lyd_free_siblings(struct lyd_node *node); |
Radek Krejci | b0849a2 | 2019-07-25 12:31:04 +0200 | [diff] [blame] | 904 | |
| 905 | /** |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 906 | * @brief Free (and unlink) the specified data (sub)tree. |
| 907 | * |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 908 | * @param[in] node Root of the (sub)tree to be freed. |
| 909 | */ |
| 910 | void lyd_free_tree(struct lyd_node *node); |
| 911 | |
| 912 | /** |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 913 | * @brief Free a single metadata instance. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 914 | * |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 915 | * @param[in] meta Metadata to free. |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 916 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 917 | void lyd_free_meta_single(struct lyd_meta *meta); |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 918 | |
| 919 | /** |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 920 | * @brief Free the metadata instance with any following instances. |
| 921 | * |
| 922 | * @param[in] meta Metadata to free. |
| 923 | */ |
| 924 | void lyd_free_meta_siblings(struct lyd_meta *meta); |
| 925 | |
| 926 | /** |
| 927 | * @brief Free a single attribute. |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 928 | * |
| 929 | * @param[in] ctx Context where the attributes were created. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 930 | * @param[in] attr Attribute to free. |
Michal Vasko | 52927e2 | 2020-03-16 17:26:14 +0100 | [diff] [blame] | 931 | */ |
Radek Krejci | 011e4aa | 2020-09-04 15:22:31 +0200 | [diff] [blame] | 932 | void lyd_free_attr_single(const struct ly_ctx *ctx, struct lyd_attr *attr); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 933 | |
| 934 | /** |
| 935 | * @brief Free the attribute with any following attributes. |
| 936 | * |
| 937 | * @param[in] ctx Context where the attributes were created. |
| 938 | * @param[in] attr First attribute to free. |
| 939 | */ |
Radek Krejci | 011e4aa | 2020-09-04 15:22:31 +0200 | [diff] [blame] | 940 | void lyd_free_attr_siblings(const struct ly_ctx *ctx, struct lyd_attr *attr); |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 941 | |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 942 | /** |
| 943 | * @brief Check type restrictions applicable to the particular leaf/leaf-list with the given string @p value. |
| 944 | * |
| 945 | * The given node is not modified in any way - it is just checked if the @p value can be set to the node. |
| 946 | * |
| 947 | * If there is no data node instance and you are fine with checking just the type's restrictions without the |
| 948 | * data tree context (e.g. for the case of require-instance restriction), use lys_value_validate(). |
| 949 | * |
| 950 | * @param[in] ctx libyang context for logging (function does not log errors when @p ctx is NULL) |
| 951 | * @param[in] node Data node for the @p value. |
Michal Vasko | f937cfe | 2020-08-03 16:07:12 +0200 | [diff] [blame] | 952 | * @param[in] value String value to be checked, it is expected to be in JSON format. |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 953 | * @param[in] value_len Length of the given @p value (mandatory). |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 954 | * @param[in] tree Data tree (e.g. when validating RPC/Notification) where the required data instance (leafref target, |
| 955 | * instance-identifier) can be placed. NULL in case the data tree is not yet complete, |
| 956 | * then LY_EINCOMPLETE can be returned. |
Michal Vasko | 3701af5 | 2020-08-03 14:29:38 +0200 | [diff] [blame] | 957 | * @param[out] realtype Optional real type of the value. |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 958 | * @return LY_SUCCESS on success |
| 959 | * @return LY_EINCOMPLETE in case the @p trees is not provided and it was needed to finish the validation (e.g. due to require-instance). |
| 960 | * @return LY_ERR value if an error occurred. |
| 961 | */ |
Michal Vasko | 44685da | 2020-03-17 15:38:06 +0100 | [diff] [blame] | 962 | LY_ERR lyd_value_validate(const struct ly_ctx *ctx, const struct lyd_node_term *node, const char *value, size_t value_len, |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 963 | const struct lyd_node *tree, const struct lysc_type **realtype); |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 964 | |
| 965 | /** |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 966 | * @brief Compare the node's value with the given string value. The string value is first validated according to |
| 967 | * the (current) node's type. |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 968 | * |
| 969 | * @param[in] node Data node to compare. |
| 970 | * @param[in] value String value to be compared. It does not need to be in a canonical form - as part of the process, |
Michal Vasko | f937cfe | 2020-08-03 16:07:12 +0200 | [diff] [blame] | 971 | * it is validated and canonized if possible. But it is expected to be in JSON format. |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 972 | * @param[in] value_len Length of the given @p value (mandatory). |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 973 | * @return LY_SUCCESS on success, |
| 974 | * @return LY_ENOT if the values do not match, |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 975 | * @return LY_ERR value if an error occurred. |
| 976 | */ |
Michal Vasko | feca4fb | 2020-10-05 08:58:40 +0200 | [diff] [blame] | 977 | LY_ERR lyd_value_compare(const struct lyd_node_term *node, const char *value, size_t value_len); |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 978 | |
Radek Krejci | 576b23f | 2019-07-12 14:06:32 +0200 | [diff] [blame] | 979 | /** |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 980 | * @defgroup datacompareoptions Data compare options |
| 981 | * @ingroup datatree |
| 982 | * |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 983 | * Various options to change the lyd_compare() behavior. |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 984 | */ |
| 985 | #define LYD_COMPARE_FULL_RECURSION 0x01 /* lists and containers are the same only in case all they children |
| 986 | (subtree, so direct as well as indirect children) are the same. By default, |
| 987 | containers are the same in case of the same schema node and lists are the same |
| 988 | in case of equal keys (keyless lists do the full recursion comparison all the time). */ |
| 989 | #define LYD_COMPARE_DEFAULTS 0x02 /* By default, implicit and explicit default nodes are considered to be equal. This flag |
| 990 | changes this behavior and implicit (automatically created default node) and explicit |
| 991 | (explicitly created node with the default value) default nodes are considered different. */ |
Michal Vasko | 60ea635 | 2020-06-29 13:39:39 +0200 | [diff] [blame] | 992 | /** @} datacompareoptions */ |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 993 | |
| 994 | /** |
| 995 | * @brief Compare 2 data nodes if they are equivalent. |
| 996 | * |
| 997 | * @param[in] node1 The first node to compare. |
| 998 | * @param[in] node2 The second node to compare. |
Radek Krejci | c5ad965 | 2019-09-11 11:31:51 +0200 | [diff] [blame] | 999 | * @param[in] options Various @ref datacompareoptions. |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 1000 | * @return LY_SUCCESS if the nodes are equivalent. |
| 1001 | * @return LY_ENOT if the nodes are not equivalent. |
| 1002 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1003 | LY_ERR lyd_compare_single(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options); |
Michal Vasko | 8f359bf | 2020-07-28 10:41:15 +0200 | [diff] [blame] | 1004 | |
| 1005 | /** |
| 1006 | * @brief Compare 2 lists of siblings if they are equivalent. |
| 1007 | * |
| 1008 | * @param[in] node1 The first sibling list to compare. |
| 1009 | * @param[in] node2 The second sibling list to compare. |
| 1010 | * @param[in] options Various @ref datacompareoptions. |
| 1011 | * @return LY_SUCCESS if all the siblings are equivalent. |
| 1012 | * @return LY_ENOT if the siblings are not equivalent. |
| 1013 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1014 | LY_ERR lyd_compare_siblings(const struct lyd_node *node1, const struct lyd_node *node2, uint32_t options); |
Radek Krejci | 1f05b6a | 2019-07-18 16:15:06 +0200 | [diff] [blame] | 1015 | |
| 1016 | /** |
Michal Vasko | 2172574 | 2020-06-29 11:49:25 +0200 | [diff] [blame] | 1017 | * @brief Compare 2 metadata. |
| 1018 | * |
| 1019 | * @param[in] meta1 First metadata. |
| 1020 | * @param[in] meta2 Second metadata. |
| 1021 | * @return LY_SUCCESS if the metadata are equivalent. |
| 1022 | * @return LY_ENOT if not. |
| 1023 | */ |
| 1024 | LY_ERR lyd_compare_meta(const struct lyd_meta *meta1, const struct lyd_meta *meta2); |
| 1025 | |
| 1026 | /** |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1027 | * @defgroup dupoptions Data duplication options |
| 1028 | * @ingroup datatree |
| 1029 | * |
| 1030 | * Various options to change lyd_dup() behavior. |
| 1031 | * |
| 1032 | * Default behavior: |
| 1033 | * - only the specified node is duplicated without siblings, parents, or children. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1034 | * - all the metadata of the duplicated nodes are also duplicated. |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1035 | * @{ |
| 1036 | */ |
| 1037 | |
| 1038 | #define LYD_DUP_RECURSIVE 0x01 /**< Duplicate not just the node but also all the children. Note that |
| 1039 | list's keys are always duplicated. */ |
Michal Vasko | a29a576 | 2020-06-23 13:28:49 +0200 | [diff] [blame] | 1040 | #define LYD_DUP_NO_META 0x02 /**< Do not duplicate metadata of any node. */ |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1041 | #define LYD_DUP_WITH_PARENTS 0x04 /**< If a nested node is being duplicated, duplicate also all the parents. |
| 1042 | Keys are also duplicated for lists. Return value does not change! */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1043 | #define LYD_DUP_WITH_FLAGS 0x08 /**< Also copy any data node flags. That will cause the duplicated data to preserve |
Michal Vasko | f6df0a0 | 2020-06-16 13:08:34 +0200 | [diff] [blame] | 1044 | its validation/default node state. */ |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1045 | |
| 1046 | /** @} dupoptions */ |
| 1047 | |
| 1048 | /** |
| 1049 | * @brief Create a copy of the specified data tree \p node. Schema references are kept the same. |
| 1050 | * |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1051 | * @param[in] node Data tree node to be duplicated. |
| 1052 | * @param[in] parent Optional parent node where to connect the duplicated node(s). |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1053 | * If set in combination with LYD_DUP_WITH_PARENTS, the parents chain is duplicated until it comes to and connects with |
| 1054 | * the @p parent. |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1055 | * @param[in] options Bitmask of options flags, see @ref dupoptions. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1056 | * @param[out] dup Optional created copy of the node. Note that in case the parents chain is duplicated for the duplicated |
| 1057 | * node(s) (when LYD_DUP_WITH_PARENTS used), the first duplicated node is still returned. |
| 1058 | * @return LY_ERR value. |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1059 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1060 | LY_ERR lyd_dup_single(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1061 | |
| 1062 | /** |
| 1063 | * @brief Create a copy of the specified data tree \p node with any following siblings. Schema references are kept the same. |
| 1064 | * |
| 1065 | * @param[in] node Data tree node to be duplicated. |
| 1066 | * @param[in] parent Optional parent node where to connect the duplicated node(s). |
| 1067 | * If set in combination with LYD_DUP_WITH_PARENTS, the parents chain is duplicated until it comes to and connects with |
| 1068 | * the @p parent. |
| 1069 | * @param[in] options Bitmask of options flags, see @ref dupoptions. |
| 1070 | * @param[out] dup Optional created copy of the node. Note that in case the parents chain is duplicated for the duplicated |
| 1071 | * node(s) (when LYD_DUP_WITH_PARENTS used), the first duplicated node is still returned. |
| 1072 | * @return LY_ERR value. |
| 1073 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1074 | LY_ERR lyd_dup_siblings(const struct lyd_node *node, struct lyd_node_inner *parent, uint32_t options, struct lyd_node **dup); |
Radek Krejci | 22ebdba | 2019-07-25 13:59:43 +0200 | [diff] [blame] | 1075 | |
| 1076 | /** |
Michal Vasko | 25a3282 | 2020-07-09 15:48:22 +0200 | [diff] [blame] | 1077 | * @brief Create a copy of the metadata. |
| 1078 | * |
| 1079 | * @param[in] meta Metadata to copy. |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1080 | * @param[in] parent Node where to append the new metadata. |
| 1081 | * @param[out] dup Optional created metadata copy. |
| 1082 | * @return LY_ERR value. |
Michal Vasko | 25a3282 | 2020-07-09 15:48:22 +0200 | [diff] [blame] | 1083 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1084 | LY_ERR lyd_dup_meta_single(const struct lyd_meta *meta, struct lyd_node *parent, struct lyd_meta **dup); |
Michal Vasko | 25a3282 | 2020-07-09 15:48:22 +0200 | [diff] [blame] | 1085 | |
| 1086 | /** |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1087 | * @defgroup mergeoptions Data merge options. |
| 1088 | * @ingroup datatree |
Radek Krejci | 576b23f | 2019-07-12 14:06:32 +0200 | [diff] [blame] | 1089 | * |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1090 | * Various options to change lyd_merge() behavior. |
| 1091 | * |
| 1092 | * Default behavior: |
| 1093 | * - source data tree is not modified in any way, |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1094 | * - any default nodes in the source are ignored if there are explicit nodes in the target. |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1095 | * @{ |
| 1096 | */ |
| 1097 | |
| 1098 | #define LYD_MERGE_DESTRUCT 0x01 /**< Spend source data tree in the function, it cannot be used afterwards! */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1099 | #define LYD_MERGE_DEFAULTS 0x02 /**< Default nodes in the source tree replace even explicit nodes in the target. */ |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1100 | |
| 1101 | /** @} mergeoptions */ |
| 1102 | |
| 1103 | /** |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1104 | * @brief Merge the source data subtree into the target data tree. Merge may not be complete until validation |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1105 | * is called on the resulting data tree (data from more cases may be present, default and non-default values). |
| 1106 | * |
| 1107 | * @param[in,out] target Target data tree to merge into, must be a top-level tree. |
| 1108 | * @param[in] source Source data tree to merge, must be a top-level tree. |
| 1109 | * @param[in] options Bitmask of option flags, see @ref mergeoptions. |
| 1110 | * @return LY_SUCCESS on success, |
| 1111 | * @return LY_ERR value on error. |
| 1112 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1113 | LY_ERR lyd_merge_tree(struct lyd_node **target, const struct lyd_node *source, uint16_t options); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1114 | |
| 1115 | /** |
| 1116 | * @brief Merge the source data tree with any following siblings into the target data tree. Merge may not be |
| 1117 | * complete until validation called on the resulting data tree (data from more cases may be present, default |
| 1118 | * and non-default values). |
| 1119 | * |
| 1120 | * @param[in,out] target Target data tree to merge into, must be a top-level tree. |
| 1121 | * @param[in] source Source data tree to merge, must be a top-level tree. |
| 1122 | * @param[in] options Bitmask of option flags, see @ref mergeoptions. |
| 1123 | * @return LY_SUCCESS on success, |
| 1124 | * @return LY_ERR value on error. |
| 1125 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1126 | LY_ERR lyd_merge_siblings(struct lyd_node **target, const struct lyd_node *source, uint16_t options); |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1127 | |
| 1128 | /** |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1129 | * @defgroup diffoptions Data diff options. |
| 1130 | * @ingroup datatree |
| 1131 | * |
| 1132 | * Various options to change lyd_diff() behavior. |
| 1133 | * |
| 1134 | * Default behavior: |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1135 | * - any default nodes are treated as non-existent and ignored. |
| 1136 | * @{ |
| 1137 | */ |
| 1138 | |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1139 | #define LYD_DIFF_DEFAULTS 0x01 /**< Default nodes in the trees are not ignored but treated similarly to explicit |
| 1140 | nodes. Also, leaves and leaf-lists are added into diff even in case only their |
| 1141 | default flag (state) was changed. */ |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1142 | |
| 1143 | /** @} diffoptions */ |
| 1144 | |
| 1145 | /** |
| 1146 | * @brief Learn the differences between 2 data trees. |
| 1147 | * |
| 1148 | * The resulting diff is represented as a data tree with specific metadata from the internal 'yang' |
| 1149 | * module. Most importantly, every node has an effective 'operation' metadata. If there is none |
| 1150 | * defined on the node, it inherits the operation from the nearest parent. Top-level nodes must |
| 1151 | * always have the 'operation' metadata defined. Additional metadata ('orig-default', 'value', |
| 1152 | * 'orig-value', 'key', 'orig-key') are used for storing more information about the value in the first |
| 1153 | * or the second tree. |
| 1154 | * |
| 1155 | * The diff tree is completely independent on the @p first and @p second trees, meaning all |
| 1156 | * the information about the change is stored in the diff and the trees are not needed. |
| 1157 | * |
| 1158 | * !! Caution !! |
| 1159 | * The diff tree should never be validated because it may easily not be valid! For example, |
| 1160 | * when data from one case branch are deleted and data from another branch created - data from both |
| 1161 | * branches are then stored in the diff tree simultaneously. |
| 1162 | * |
| 1163 | * @param[in] first First data tree. |
| 1164 | * @param[in] second Second data tree. |
| 1165 | * @param[in] options Bitmask of options flags, see @ref diffoptions. |
| 1166 | * @param[out] diff Generated diff. |
| 1167 | * @return LY_SUCCESS on success, |
| 1168 | * @return LY_ERR on error. |
| 1169 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1170 | LY_ERR lyd_diff_tree(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, struct lyd_node **diff); |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1171 | |
| 1172 | /** |
| 1173 | * @brief Learn the differences between 2 data trees including all the following siblings. |
| 1174 | * |
| 1175 | * @param[in] first First data tree. |
| 1176 | * @param[in] second Second data tree. |
| 1177 | * @param[in] options Bitmask of options flags, see @ref diffoptions. |
| 1178 | * @param[out] diff Generated diff. |
| 1179 | * @return LY_SUCCESS on success, |
| 1180 | * @return LY_ERR on error. |
| 1181 | */ |
Radek Krejci | 1deb5be | 2020-08-26 16:43:36 +0200 | [diff] [blame] | 1182 | LY_ERR lyd_diff_siblings(const struct lyd_node *first, const struct lyd_node *second, uint16_t options, struct lyd_node **diff); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1183 | |
| 1184 | /** |
| 1185 | * @brief Callback for diff nodes. |
| 1186 | * |
| 1187 | * @param[in] diff_node Diff node. |
| 1188 | * @param[in] data_node Matching node in data. |
| 1189 | * @param[in] cb_data Arbitrary callback data. |
| 1190 | * @return LY_ERR value. |
| 1191 | */ |
| 1192 | typedef LY_ERR (*lyd_diff_cb)(const struct lyd_node *diff_node, struct lyd_node *data_node, void *cb_data); |
| 1193 | |
| 1194 | /** |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1195 | * @brief Apply the whole diff on a data tree but restrict the operation to one module. |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1196 | * |
| 1197 | * @param[in,out] data Data to apply the diff on. |
| 1198 | * @param[in] diff Diff to apply. |
| 1199 | * @param[in] mod Module, whose diff/data only to consider, NULL for all modules. |
| 1200 | * @param[in] diff_cb Optional diff callback that will be called for every changed node. |
| 1201 | * @param[in] cb_data Arbitrary callback data. |
| 1202 | * @return LY_SUCCESS on success, |
| 1203 | * @return LY_ERR on error. |
| 1204 | */ |
| 1205 | LY_ERR lyd_diff_apply_module(struct lyd_node **data, const struct lyd_node *diff, const struct lys_module *mod, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 1206 | lyd_diff_cb diff_cb, void *cb_data); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1207 | |
| 1208 | /** |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1209 | * @brief Apply the whole diff tree on a data tree. |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1210 | * |
| 1211 | * @param[in,out] data Data to apply the diff on. |
| 1212 | * @param[in] diff Diff to apply. |
| 1213 | * @return LY_SUCCESS on success, |
| 1214 | * @return LY_ERR on error. |
| 1215 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1216 | LY_ERR lyd_diff_apply_all(struct lyd_node **data, const struct lyd_node *diff); |
Michal Vasko | e893ddd | 2020-06-23 13:35:20 +0200 | [diff] [blame] | 1217 | |
| 1218 | /** |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1219 | * @brief Merge 2 diffs into each other but restrict the operation to one module. |
| 1220 | * |
| 1221 | * The diffs must be possible to be merged, which is guaranteed only if the source diff was |
| 1222 | * created on data that had the target diff applied on them. In other words, this sequence is legal |
| 1223 | * |
Michal Vasko | 04f8591 | 2020-08-07 12:14:58 +0200 | [diff] [blame] | 1224 | * 1) diff1 from data1 and data2 -> data11 from apply diff1 on data1 -> diff2 from data11 and data3 -> |
| 1225 | * -> data 33 from apply diff2 on data1 |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1226 | * |
| 1227 | * and reusing these diffs |
| 1228 | * |
Michal Vasko | 04f8591 | 2020-08-07 12:14:58 +0200 | [diff] [blame] | 1229 | * 2) diff11 from merge diff1 and diff2 -> data33 from apply diff11 on data1 |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1230 | * |
Michal Vasko | fb737aa | 2020-08-06 13:53:53 +0200 | [diff] [blame] | 1231 | * @param[in,out] diff Target diff to merge into. |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1232 | * @param[in] src_diff Source diff. |
| 1233 | * @param[in] mod Module, whose diff only to consider, NULL for all modules. |
| 1234 | * @param[in] diff_cb Optional diff callback that will be called for every changed node. |
| 1235 | * @param[in] cb_data Arbitrary callback data. |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1236 | * @return LY_SUCCESS on success, |
| 1237 | * @return LY_ERR on error. |
| 1238 | */ |
Michal Vasko | fb737aa | 2020-08-06 13:53:53 +0200 | [diff] [blame] | 1239 | LY_ERR lyd_diff_merge_module(struct lyd_node **diff, const struct lyd_node *src_diff, const struct lys_module *mod, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 1240 | lyd_diff_cb diff_cb, void *cb_data); |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1241 | |
| 1242 | /** |
Michal Vasko | 04f8591 | 2020-08-07 12:14:58 +0200 | [diff] [blame] | 1243 | * @brief Merge 2 diff trees into each other. |
| 1244 | * |
| 1245 | * @param[in,out] diff_first Target diff first sibling to merge into. |
| 1246 | * @param[in] diff_parent Target diff parent to merge into. |
| 1247 | * @param[in] src_sibling Source diff sibling to merge. |
| 1248 | * @param[in] diff_cb Optional diff callback that will be called for every changed node. |
| 1249 | * @param[in] cb_data Arbitrary callback data. |
| 1250 | * @return LY_SUCCESS on success, |
| 1251 | * @return LY_ERR on error. |
| 1252 | */ |
| 1253 | LY_ERR lyd_diff_merge_tree(struct lyd_node **diff_first, struct lyd_node *diff_parent, const struct lyd_node *src_sibling, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 1254 | lyd_diff_cb diff_cb, void *cb_data); |
Michal Vasko | 04f8591 | 2020-08-07 12:14:58 +0200 | [diff] [blame] | 1255 | |
| 1256 | /** |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1257 | * @brief Merge 2 diffs into each other. |
| 1258 | * |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1259 | * @param[in,out] diff Target diff to merge into. |
Michal Vasko | fb737aa | 2020-08-06 13:53:53 +0200 | [diff] [blame] | 1260 | * @param[in] src_diff Source diff. |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1261 | * @return LY_SUCCESS on success, |
| 1262 | * @return LY_ERR on error. |
| 1263 | */ |
Michal Vasko | fb737aa | 2020-08-06 13:53:53 +0200 | [diff] [blame] | 1264 | LY_ERR lyd_diff_merge_all(struct lyd_node **diff, const struct lyd_node *src_diff); |
Michal Vasko | e6323f6 | 2020-07-09 15:49:02 +0200 | [diff] [blame] | 1265 | |
| 1266 | /** |
Michal Vasko | 4231fb6 | 2020-07-13 13:54:47 +0200 | [diff] [blame] | 1267 | * @brief Reverse a diff and make the opposite changes. Meaning change create to delete, delete to create, |
| 1268 | * or move from place A to B to move from B to A and so on. |
| 1269 | * |
| 1270 | * @param[in] src_diff Diff to reverse. |
| 1271 | * @param[out] diff Reversed diff. |
| 1272 | * @return LY_SUCCESS on success. |
| 1273 | * @return LY_ERR on error. |
| 1274 | */ |
Michal Vasko | 3a41dff | 2020-07-15 14:30:28 +0200 | [diff] [blame] | 1275 | LY_ERR lyd_diff_reverse_all(const struct lyd_node *src_diff, struct lyd_node **diff); |
Michal Vasko | 4231fb6 | 2020-07-13 13:54:47 +0200 | [diff] [blame] | 1276 | |
| 1277 | /** |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1278 | * @brief Find the target in data of a compiled ly_path structure (instance-identifier). |
| 1279 | * |
| 1280 | * @param[in] path Compiled path structure. |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 1281 | * @param[in] tree Data tree to be searched. |
Michal Vasko | 4490d31 | 2020-06-16 13:08:55 +0200 | [diff] [blame] | 1282 | * @return Found target node, |
| 1283 | * @return NULL if not found. |
Radek Krejci | 576b23f | 2019-07-12 14:06:32 +0200 | [diff] [blame] | 1284 | */ |
Michal Vasko | 004d315 | 2020-06-11 19:59:22 +0200 | [diff] [blame] | 1285 | const struct lyd_node_term *lyd_target(const struct ly_path *path, const struct lyd_node *tree); |
Radek Krejci | 084289f | 2019-07-09 17:35:30 +0200 | [diff] [blame] | 1286 | |
Michal Vasko | 5ec7cda | 2019-09-11 13:43:08 +0200 | [diff] [blame] | 1287 | /** |
Michal Vasko | 5ec7cda | 2019-09-11 13:43:08 +0200 | [diff] [blame] | 1288 | * @brief Types of the different data paths. |
| 1289 | */ |
| 1290 | typedef enum { |
Michal Vasko | 1465471 | 2020-02-06 08:35:21 +0100 | [diff] [blame] | 1291 | LYD_PATH_LOG, /**< Descriptive path format used in log messages */ |
Michal Vasko | 6973015 | 2020-10-09 16:30:07 +0200 | [diff] [blame] | 1292 | LYD_PATH_LOG_NO_LAST_PRED /**< Similar to ::LYD_PATH_LOG except there is never a predicate on the last node */ |
Michal Vasko | 5ec7cda | 2019-09-11 13:43:08 +0200 | [diff] [blame] | 1293 | } LYD_PATH_TYPE; |
| 1294 | |
| 1295 | /** |
| 1296 | * @brief Generate path of the given node in the requested format. |
| 1297 | * |
| 1298 | * @param[in] node Schema path of this node will be generated. |
| 1299 | * @param[in] pathtype Format of the path to generate. |
| 1300 | * @param[in,out] buffer Prepared buffer of the @p buflen length to store the generated path. |
| 1301 | * If NULL, memory for the complete path is allocated. |
| 1302 | * @param[in] buflen Size of the provided @p buffer. |
| 1303 | * @return NULL in case of memory allocation error, path of the node otherwise. |
| 1304 | * In case the @p buffer is NULL, the returned string is dynamically allocated and caller is responsible to free it. |
| 1305 | */ |
| 1306 | char *lyd_path(const struct lyd_node *node, LYD_PATH_TYPE pathtype, char *buffer, size_t buflen); |
| 1307 | |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 1308 | /** |
Michal Vasko | 25a3282 | 2020-07-09 15:48:22 +0200 | [diff] [blame] | 1309 | * @brief Find a specific metadata. |
| 1310 | * |
| 1311 | * @param[in] first First metadata to consider. |
| 1312 | * @param[in] module Module of the metadata definition, may be NULL if @p name includes a prefix. |
| 1313 | * @param[in] name Name of the metadata to find, may not include a prefix (module name) if @p module is set. |
| 1314 | * @return Found metadata, |
| 1315 | * @return NULL if not found. |
| 1316 | */ |
| 1317 | struct lyd_meta *lyd_find_meta(const struct lyd_meta *first, const struct lys_module *module, const char *name); |
| 1318 | |
| 1319 | /** |
Michal Vasko | da85903 | 2020-07-14 12:20:14 +0200 | [diff] [blame] | 1320 | * @brief Search in the given siblings (NOT recursively) for the first target instance with the same value. |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 1321 | * Uses hashes - should be used whenever possible for best performance. |
| 1322 | * |
| 1323 | * @param[in] siblings Siblings to search in including preceding and succeeding nodes. |
| 1324 | * @param[in] target Target node to find. |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 1325 | * @param[out] match Can be NULL, otherwise the found data node. |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 1326 | * @return LY_SUCCESS on success, @p match set. |
| 1327 | * @return LY_ENOTFOUND if not found, @p match set to NULL. |
| 1328 | * @return LY_ERR value if another error occurred. |
| 1329 | */ |
| 1330 | LY_ERR lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target, struct lyd_node **match); |
| 1331 | |
| 1332 | /** |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 1333 | * @brief Search in the given siblings for the first schema instance. |
| 1334 | * Uses hashes - should be used whenever possible for best performance. |
| 1335 | * |
| 1336 | * @param[in] siblings Siblings to search in including preceding and succeeding nodes. |
| 1337 | * @param[in] schema Schema node of the data node to find. |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 1338 | * @param[in] key_or_value If it is NULL, the first schema node data instance is found. For nodes with many |
| 1339 | * instances, it can be set based on the type of @p schema: |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 1340 | * LYS_LEAFLIST: |
| 1341 | * Searched instance value. |
| 1342 | * LYS_LIST: |
Michal Vasko | 90932a9 | 2020-02-12 14:33:03 +0100 | [diff] [blame] | 1343 | * Searched instance key values in the form of "[key1='val1'][key2='val2']...". |
| 1344 | * The keys do not have to be ordered but all of them must be set. |
| 1345 | * |
| 1346 | * Note that any explicit values (leaf-list or list key values) will be canonized first |
| 1347 | * before comparison. But values that do not have a canonical value are expected to be in the |
| 1348 | * JSON format! |
Michal Vasko | f03ed03 | 2020-03-04 13:31:44 +0100 | [diff] [blame] | 1349 | * @param[in] val_len Optional length of @p key_or_value in case it is not 0-terminated. |
Michal Vasko | 9b368d3 | 2020-02-14 13:53:31 +0100 | [diff] [blame] | 1350 | * @param[out] match Can be NULL, otherwise the found data node. |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 1351 | * @return LY_SUCCESS on success, @p match set. |
| 1352 | * @return LY_ENOTFOUND if not found, @p match set to NULL. |
| 1353 | * @return LY_EINVAL if @p schema is a key-less list. |
| 1354 | * @return LY_ERR value if another error occurred. |
| 1355 | */ |
| 1356 | LY_ERR lyd_find_sibling_val(const struct lyd_node *siblings, const struct lysc_node *schema, const char *key_or_value, |
Radek Krejci | 0f96988 | 2020-08-21 16:56:47 +0200 | [diff] [blame] | 1357 | size_t val_len, struct lyd_node **match); |
Michal Vasko | e444f75 | 2020-02-10 12:20:06 +0100 | [diff] [blame] | 1358 | |
Michal Vasko | ccc0234 | 2020-05-21 10:09:21 +0200 | [diff] [blame] | 1359 | /** |
| 1360 | * @brief Search in the given data for instances of nodes matching the provided XPath. |
| 1361 | * |
Michal Vasko | b104f11 | 2020-07-17 09:54:54 +0200 | [diff] [blame] | 1362 | * The expected format of the expression is ::LYD_JSON, meaning the first node in every path |
Michal Vasko | 61ac2f6 | 2020-05-25 12:39:51 +0200 | [diff] [blame] | 1363 | * must have its module name as prefix or be the special `*` value for all the nodes. |
| 1364 | * |
Michal Vasko | 19a3060 | 2020-05-25 10:40:19 +0200 | [diff] [blame] | 1365 | * If a list instance is being selected with all its key values specified (but not necessarily ordered) |
| 1366 | * in the form `list[key1='val1'][key2='val2'][key3='val3']` or a leaf-list instance in the form |
| 1367 | * `leaf-list[.='val']`, these instances are found using hashes with constant (*O(1)*) complexity |
| 1368 | * (unless they are defined in top-level). Other predicates can still follow the aforementioned ones. |
| 1369 | * |
Michal Vasko | ccc0234 | 2020-05-21 10:09:21 +0200 | [diff] [blame] | 1370 | * @param[in] ctx_node XPath context node. |
| 1371 | * @param[in] xpath Data XPath expression filtering the matching nodes. ::LYD_JSON format is expected. |
| 1372 | * @param[out] set Set of found data nodes. In case the result is a number, a string, or a boolean, |
| 1373 | * the returned set is empty. |
| 1374 | * @return LY_SUCCESS on success, @p set is returned. |
| 1375 | * @return LY_ERR value if an error occurred. |
| 1376 | */ |
| 1377 | LY_ERR lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set); |
| 1378 | |
Radek Krejci | e7b9509 | 2019-05-15 11:03:07 +0200 | [diff] [blame] | 1379 | #ifdef __cplusplus |
| 1380 | } |
| 1381 | #endif |
| 1382 | |
| 1383 | #endif /* LY_TREE_DATA_H_ */ |