blob: a2cd10614c930a2871e2726c4c1bea91bb1e7137 [file] [log] [blame]
Michal Vasko2d162e12015-09-24 14:33:29 +02001/**
Radek Krejciaa429e42015-10-09 15:52:37 +02002 * @file tree_data.h
Michal Vasko2d162e12015-09-24 14:33:29 +02003 * @author Radek Krejci <rkrejci@cesnet.cz>
Radek Krejciaa429e42015-10-09 15:52:37 +02004 * @brief libyang representation of data trees.
Michal Vasko2d162e12015-09-24 14:33:29 +02005 *
6 * Copyright (c) 2015 CESNET, z.s.p.o.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of the Company nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 */
21
22#ifndef LY_TREE_DATA_H_
23#define LY_TREE_DATA_H_
24
25#include <stddef.h>
26#include <stdint.h>
27
Mislav Novakovice251a652015-09-29 08:40:12 +020028#include "tree_schema.h"
29
Michal Vasko2d162e12015-09-24 14:33:29 +020030#ifdef __cplusplus
31extern "C" {
32#endif
33
34/**
35 * @addtogroup datatree
36 * @{
37 */
38
39/**
40 * @brief Data input/output formats supported by libyang [parser](@ref parsers) and [printer](@ref printers) functions.
41 */
42typedef enum {
43 LYD_UNKNOWN, /**< unknown format, used as return value in case of error */
44 LYD_XML, /**< XML format of the instance data */
Radek Krejci452fb952015-10-02 16:07:46 +020045 LYD_XML_FORMAT, /**< For input data, it is interchangeable with #LYD_XML, for output it formats XML with indentantion */
Michal Vasko2d162e12015-09-24 14:33:29 +020046 LYD_JSON, /**< JSON format of the instance data */
47} LYD_FORMAT;
48
49/**
Michal Vasko2d162e12015-09-24 14:33:29 +020050 * @brief Attribute structure.
51 *
Radek Krejci5f9e8c92015-10-30 10:01:06 +010052 * The structure provides information about attributes of a data element. Such attributes partially
53 * maps to annotations from draft-ietf-netmod-yang-metadata. In XML, they are represented as standard
54 * XML attrbutes. In JSON, they are represented as JSON elements starting with the '@' character
55 * (for more information, see the yang metadata draft.
56 *
Michal Vasko2d162e12015-09-24 14:33:29 +020057 */
58struct lyd_attr {
Radek Krejci5f9e8c92015-10-30 10:01:06 +010059 struct lyd_attr *next; /**< pointer to the next attribute of the same element */
60 struct lys_module *module; /**< pointer to the attribute's module.
61 TODO when annotations will be supported, point to the annotation definition
62 and validate that the attribute is really defined there. Currently, we just
63 believe that it is defined in the module it says */
Michal Vasko2d162e12015-09-24 14:33:29 +020064 const char *name; /**< attribute name */
65 const char *value; /**< attribute value */
66};
67
68/**
69 * @brief node's value representation
70 */
71typedef union lyd_value_u {
72 const char *binary; /**< base64 encoded, NULL terminated string */
Michal Vasko8ea2b7f2015-09-29 14:30:53 +020073 struct lys_type_bit **bit; /**< bitmap of pointers to the schema definition of the bit value that are set,
74 its size is always the number of defined bits in the schema */
Radek Krejci489773c2015-12-17 13:20:03 +010075 int8_t bln; /**< 0 as false, 1 as true */
Michal Vasko2d162e12015-09-24 14:33:29 +020076 int64_t dec64; /**< decimal64: value = dec64 / 10^fraction-digits */
77 struct lys_type_enum *enm; /**< pointer to the schema definition of the enumeration value */
Michal Vasko8ea2b7f2015-09-29 14:30:53 +020078 struct lys_ident *ident; /**< pointer to the schema definition of the identityref value */
Michal Vasko2d162e12015-09-24 14:33:29 +020079 struct lyd_node *instance; /**< instance-identifier, pointer to the referenced data tree node */
80 int8_t int8; /**< 8-bit signed integer */
81 int16_t int16; /**< 16-bit signed integer */
82 int32_t int32; /**< 32-bit signed integer */
83 int64_t int64; /**< 64-bit signed integer */
84 struct lyd_node *leafref; /**< pointer to the referenced leaf/leaflist instance in data tree */
85 const char *string; /**< string */
86 uint8_t uint8; /**< 8-bit unsigned integer */
87 uint16_t uint16; /**< 16-bit signed integer */
88 uint32_t uint32; /**< 32-bit signed integer */
89 uint64_t uint64; /**< 64-bit signed integer */
90} lyd_val;
91
92/**
Radek Krejcica7efb72016-01-18 13:06:01 +010093 * @defgroup validityflags Validity flags
94 * @ingroup datatree
95 *
96 * Validity flags for data nodes.
97 *
98 * @{
99 */
100#define LYD_VAL_OK 0x00 /**< node is successfully validated including whole subtree */
101#define LYD_VAL_UNIQUE 0x01 /**< Unique value(s) changed, applicable only to ::lys_node_list data nodes */
102#define LYD_VAL_NOT 0xff /**< node was not validated yet */
103/**
104 * @}
105 */
106
107/**
Michal Vasko2d162e12015-09-24 14:33:29 +0200108 * @brief Generic structure for a data node, directly applicable to the data nodes defined as #LYS_CONTAINER, #LYS_LIST
109 * and #LYS_CHOICE.
110 *
111 * Completely fits to containers and choices and is compatible (can be used interchangeably except the #child member)
112 * with all other lyd_node_* structures. All data nodes are provides as ::lyd_node structure by default.
113 * According to the schema's ::lys_node#nodetype member, the specific object is supposed to be cast to
Radek Krejcica7efb72016-01-18 13:06:01 +0100114 * ::lyd_node_leaf_list or ::lyd_node_anyxml structures. This structure fits only to #LYS_CONTAINER, #LYS_LIST and
115 * #LYS_CHOICE values.
Michal Vasko2d162e12015-09-24 14:33:29 +0200116 *
117 * To traverse through all the child elements or attributes, use #LY_TREE_FOR or #LY_TREE_FOR_SAFE macro.
118 */
119struct lyd_node {
120 struct lys_node *schema; /**< pointer to the schema definition of this node */
Radek Krejcica7efb72016-01-18 13:06:01 +0100121 uint8_t validity; /**< [validity flags](@ref validityflags) */
Michal Vasko2d162e12015-09-24 14:33:29 +0200122
123 struct lyd_attr *attr; /**< pointer to the list of attributes of this node */
124 struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
125 struct lyd_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
126 never NULL. If there is no sibling node, pointer points to the node
127 itself. In case of the first node, this pointer points to the last
128 node in the list. */
129 struct lyd_node *parent; /**< pointer to the parent node, NULL in case of root node */
130 struct lyd_node *child; /**< pointer to the first child node \note Since other lyd_node_*
Radek Krejciee360892015-10-06 11:23:14 +0200131 structures represent end nodes, this member
Michal Vasko2d162e12015-09-24 14:33:29 +0200132 is replaced in those structures. Therefore, be careful with accessing
133 this member without having information about the node type from the schema's
134 ::lys_node#nodetype member. */
135};
136
137/**
Michal Vasko4c183312015-09-25 10:41:47 +0200138 * @brief Structure for data nodes defined as #LYS_LEAF or #LYS_LEAFLIST.
Michal Vasko2d162e12015-09-24 14:33:29 +0200139 *
Michal Vasko4c183312015-09-25 10:41:47 +0200140 * Extension for ::lyd_node structure. It replaces the ::lyd_node#child member by
141 * three new members (#value, #value_str and #value_type) to provide
142 * information about the value. The first five members (#schema, #attr, #next,
Michal Vasko2d162e12015-09-24 14:33:29 +0200143 * #prev and #parent) are compatible with the ::lyd_node's members.
144 *
145 * To traverse through all the child elements or attributes, use #LY_TREE_FOR or #LY_TREE_FOR_SAFE macro.
146 */
Michal Vasko4c183312015-09-25 10:41:47 +0200147struct lyd_node_leaf_list {
Michal Vasko2d162e12015-09-24 14:33:29 +0200148 struct lys_node *schema; /**< pointer to the schema definition of this node which is ::lys_node_leaflist
149 structure */
Radek Krejcica7efb72016-01-18 13:06:01 +0100150 uint8_t validity; /**< [validity flags](@ref validityflags) */
Michal Vasko2d162e12015-09-24 14:33:29 +0200151
152 struct lyd_attr *attr; /**< pointer to the list of attributes of this node */
153 struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
154 struct lyd_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
155 never NULL. If there is no sibling node, pointer points to the node
156 itself. In case of the first node, this pointer points to the last
157 node in the list. */
158 struct lyd_node *parent; /**< pointer to the parent node, NULL in case of root node */
159
160 /* struct lyd_node *child; should be here, but is not */
161
162 /* leaflist's specific members */
Michal Vasko2d162e12015-09-24 14:33:29 +0200163 const char *value_str; /**< string representation of value (for comparison, printing,...) */
Radek Krejci23238922015-10-27 17:13:34 +0100164 lyd_val value; /**< node's value representation */
Michal Vasko2d162e12015-09-24 14:33:29 +0200165 LY_DATA_TYPE value_type; /**< type of the value in the node, mainly for union to avoid repeating of type detection */
166};
167
168/**
169 * @brief Structure for data nodes defined as #LYS_ANYXML.
170 *
171 * Extension for ::lyd_node structure - replaces the ::lyd_node#child member by new #value member. The first five
172 * members (#schema, #attr, #next, #prev and #parent) are compatible with the ::lyd_node's members.
173 *
174 * To traverse through all the child elements or attributes, use #LY_TREE_FOR or #LY_TREE_FOR_SAFE macro.
175 */
176struct lyd_node_anyxml {
177 struct lys_node *schema; /**< pointer to the schema definition of this node which is ::lys_node_anyxml
178 structure */
Radek Krejcica7efb72016-01-18 13:06:01 +0100179 uint8_t validity; /**< [validity flags](@ref validityflags) */
Michal Vasko2d162e12015-09-24 14:33:29 +0200180
181 struct lyd_attr *attr; /**< pointer to the list of attributes of this node */
182 struct lyd_node *next; /**< pointer to the next sibling node (NULL if there is no one) */
183 struct lyd_node *prev; /**< pointer to the previous sibling node \note Note that this pointer is
184 never NULL. If there is no sibling node, pointer points to the node
185 itself. In case of the first node, this pointer points to the last
186 node in the list. */
187 struct lyd_node *parent; /**< pointer to the parent node, NULL in case of root node */
188
189 /* struct lyd_node *child; should be here, but is not */
190
191 /* anyxml's specific members */
192 struct lyxml_elem *value; /**< anyxml name is the root element of value! */
193};
194
195/**
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200196 * @brief Create a new container node in a data tree.
197 *
198 * @param[in] parent Parent node for the node being created. NULL in case of creating top level element.
Radek Krejciee360892015-10-06 11:23:14 +0200199 * @param[in] module Module with the node being created.
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200200 * @param[in] name Schema node name of the new data node. The node can be #LYS_CONTAINER, #LYS_LIST,
Michal Vaskoa45cf2b2015-10-23 09:45:36 +0200201 * #LYS_NOTIF, or #LYS_RPC.
Michal Vasko1dca6882015-10-22 14:29:42 +0200202 * @return New node, NULL on error.
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200203 */
Michal Vasko1e62a092015-12-01 12:27:20 +0100204struct lyd_node *lyd_new(struct lyd_node *parent, const struct lys_module *module, const char *name);
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200205
206/**
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200207 * @brief Create a new leaf or leaflist node in a data tree with a string value that is converted to
208 * the actual value.
209 *
210 * @param[in] parent Parent node for the node being created. NULL in case of creating top level element.
Radek Krejciee360892015-10-06 11:23:14 +0200211 * @param[in] module Module with the node being created.
212 * @param[in] name Schema node name of the new data node.
Michal Vasko3e671b52015-10-23 16:23:15 +0200213 * @param[in] val_str String form of the value of the node being created. In case the type is #LY_TYPE_INST
214 * or #LY_TYPE_IDENT, JSON node-id format is expected (nodes are prefixed with module names, not XML namespaces).
Michal Vasko1dca6882015-10-22 14:29:42 +0200215 * @return New node, NULL on error.
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200216 */
Michal Vasko1e62a092015-12-01 12:27:20 +0100217struct lyd_node *lyd_new_leaf(struct lyd_node *parent, const struct lys_module *module, const char *name,
Michal Vasko3e671b52015-10-23 16:23:15 +0200218 const char *val_str);
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200219
220/**
Radek Krejcib9b4d002016-01-18 13:08:51 +0100221 * @brief Change value of a leaf node.
222 *
223 * Despite the prototype allows to provide a leaflist node as \p leaf parameter, only leafs are accepted.
224 *
225 * @param[in] leaf A leaf node to change.
226 * @param[in] val_str String form of the new value to be set to the \p leaf. In case the type is #LY_TYPE_INST
227 * or #LY_TYPE_IDENT, JSON node-id format is expected (nodes are prefixed with module names, not XML namespaces).
228 * @return 0 on success, non-zero on error.
229 */
230int lyd_change_leaf(struct lyd_node_leaf_list *leaf, const char *val_str);
231
232/**
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200233 * @brief Create a new anyxml node in a data tree.
Michal Vasko2d162e12015-09-24 14:33:29 +0200234 *
Michal Vasko2d162e12015-09-24 14:33:29 +0200235 * @param[in] parent Parent node for the node being created. NULL in case of creating top level element.
Radek Krejciee360892015-10-06 11:23:14 +0200236 * @param[in] module Module with the node being created.
237 * @param[in] name Schema node name of the new data node.
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200238 * @param[in] val_xml Value of the node being created. Must be a well-formed XML.
Michal Vasko1dca6882015-10-22 14:29:42 +0200239 * @return New node, NULL on error.
Michal Vasko2d162e12015-09-24 14:33:29 +0200240 */
Michal Vasko1e62a092015-12-01 12:27:20 +0100241struct lyd_node *lyd_new_anyxml(struct lyd_node *parent, const struct lys_module *module, const char *name,
Michal Vasko8ea2b7f2015-09-29 14:30:53 +0200242 const char *val_xml);
Michal Vasko2d162e12015-09-24 14:33:29 +0200243
244/**
Michal Vasko50c0a872016-01-13 14:34:11 +0100245 * @brief Create a new container node in a data tree, whose schema parent is #LYS_OUTPUT.
Michal Vasko0df122f2015-12-14 13:38:21 +0100246 *
Michal Vasko50c0a872016-01-13 14:34:11 +0100247 * @param[in] schema Schema node of the container.
Michal Vasko0df122f2015-12-14 13:38:21 +0100248 * @return New node, NULL on error.
249 */
Michal Vasko50c0a872016-01-13 14:34:11 +0100250struct lyd_node *lyd_output_new(const struct lys_node *schema);
251
252/**
253 * @brief Create a new leaf or leaflist node in a data tree, whose schema parent is #LYS_OUTPUT.
254 *
255 * @param[in] schema Schema node of the leaf.
256 * @param[in] val_str String form of the value of the node being created. In case the type is #LY_TYPE_INST
257 * or #LY_TYPE_IDENT, JSON node-id format is expected (nodes are prefixed with module names, not XML namespaces).
258 * @return New node, NULL on error.
259 */
260struct lyd_node *lyd_output_new_leaf(const struct lys_node *schema, const char *val_str);
261
262/**
263 * @brief Create a new anyxml node in a data tree, whose schema parent is #LYS_OUTPUT.
264 *
265 * @param[in] schema Schema node of the leaf.
266 * @param[in] val_xml Value of the node being created. Must be a well-formed XML.
267 * @return New node, NULL on error.
268 */
269struct lyd_node *lyd_output_new_anyxml(const struct lys_node *schema, const char *val_xml);
Michal Vasko0df122f2015-12-14 13:38:21 +0100270
271/**
Michal Vaskoc0797f82015-10-14 15:51:25 +0200272 * @brief Create a copy of the specified data tree \p node. Namespaces are copied as needed,
273 * schema references are kept the same.
Michal Vasko2d162e12015-09-24 14:33:29 +0200274 *
275 * @param[in] node Data tree node to be duplicated.
276 * @param[in] recursive 1 if all children are supposed to be also duplicated.
277 * @return Created copy of the provided data \p node.
278 */
Michal Vasko1e62a092015-12-01 12:27:20 +0100279struct lyd_node *lyd_dup(const struct lyd_node *node, int recursive);
Michal Vasko2d162e12015-09-24 14:33:29 +0200280
281/**
282 * @brief Insert the \p node element as child to the \p parent element. The \p node is inserted as a last child of the
283 * \p parent.
284 *
285 * If the node is part of some other tree, it is automatically unlinked.
286 * If the node is the first node of a node list (with no parent), all
287 * the subsequent nodes are also inserted.
288 *
289 * @param[in] parent Parent node for the \p node being inserted.
290 * @param[in] node The node being inserted.
Michal Vasko24337392015-10-16 09:58:16 +0200291 * @return 0 on success, nonzero in case of error, e.g. when the node is being inserted to an inappropriate place
Michal Vasko2d162e12015-09-24 14:33:29 +0200292 * in the data tree.
293 */
Michal Vasko24337392015-10-16 09:58:16 +0200294int lyd_insert(struct lyd_node *parent, struct lyd_node *node);
Michal Vasko2d162e12015-09-24 14:33:29 +0200295
296/**
Michal Vasko3f7dba12015-10-15 13:09:27 +0200297 * @brief Insert the \p node element after the \p sibling element. If \p node and \p siblings are already
Radek Krejcica7efb72016-01-18 13:06:01 +0100298 * siblings (just moving \p node position), skip validation.
Michal Vasko2d162e12015-09-24 14:33:29 +0200299 *
Michal Vasko2d162e12015-09-24 14:33:29 +0200300 * @param[in] sibling The data tree node before which the \p node will be inserted.
301 * @param[in] node The data tree node to be inserted.
Michal Vasko24337392015-10-16 09:58:16 +0200302 * @return 0 on success, nonzero in case of error, e.g. when the node is being inserted to an inappropriate place
Michal Vasko2d162e12015-09-24 14:33:29 +0200303 * in the data tree.
304 */
Michal Vasko24337392015-10-16 09:58:16 +0200305int lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node);
Michal Vasko2d162e12015-09-24 14:33:29 +0200306
307/**
308 * @brief Insert the \p node element after the \p sibling element.
309 *
Michal Vasko3f7dba12015-10-15 13:09:27 +0200310 * @param[in] sibling The data tree node before which the \p node will be inserted. If \p node and \p siblings
Radek Krejcica7efb72016-01-18 13:06:01 +0100311 * are already siblings (just moving \p node position), skip validation.
Michal Vasko2d162e12015-09-24 14:33:29 +0200312 * @param[in] node The data tree node to be inserted.
Michal Vasko24337392015-10-16 09:58:16 +0200313 * @return 0 on success, nonzero in case of error, e.g. when the node is being inserted to an inappropriate place
Michal Vasko2d162e12015-09-24 14:33:29 +0200314 * in the data tree.
315 */
Michal Vasko24337392015-10-16 09:58:16 +0200316int lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node);
317
318/**
Radek Krejcic5b6b912016-01-18 16:35:35 +0100319 * @brief Search in the given data for instances of the provided schema node.
320 *
321 * The \p data is used to find the data root and function then searches in the whole tree and all sibling trees.
322 *
323 * @param[in] data A node in the data tree to search.
324 * @param[in] schema Schema node of the data nodes caller want to find.
Radek Krejcidc154432016-01-21 11:10:59 +0100325 * @return Set of found data nodes (use ::ly_set#dset). If no data node is found, the returned set is empty.
Radek Krejcic5b6b912016-01-18 16:35:35 +0100326 * In case of error, NULL is returned.
327 */
Radek Krejcidc154432016-01-21 11:10:59 +0100328struct ly_set *lyd_get_node(const struct lyd_node *data, const struct lys_node *schema);
Radek Krejcic5b6b912016-01-18 16:35:35 +0100329
330/**
Michal Vasko24337392015-10-16 09:58:16 +0200331 * @brief Validate \p node data subtree.
332 *
Radek Krejci15c733d2016-01-27 16:31:17 +0100333 * @param[in] node Data tree to be validated.
Michal Vasko24337392015-10-16 09:58:16 +0200334 * @param[in] options Options for the inserting data to the target data tree options, see @ref parseroptions.
Radek Krejci15c733d2016-01-27 16:31:17 +0100335 * @return 0 on success (if options include #LYD_OPT_FILTER, some nodes could still have been deleted as an
336 * optimization, which can have a bad consequences when the \p node stores a subtree instead of a tree with
337 * a top-level node(s)), nonzero in case of an error.
Michal Vasko24337392015-10-16 09:58:16 +0200338 */
339int lyd_validate(struct lyd_node *node, int options);
Michal Vasko2d162e12015-09-24 14:33:29 +0200340
341/**
Michal Vasko55f60be2015-10-14 13:12:58 +0200342 * @brief Unlink the specified data subtree. All referenced namespaces are copied.
Michal Vasko2d162e12015-09-24 14:33:29 +0200343 *
344 * Note, that the node's connection with the schema tree is kept. Therefore, in case of
345 * reconnecting the node to a data tree using lyd_paste() it is necessary to paste it
346 * to the appropriate place in the data tree following the schema.
347 *
348 * @param[in] node Data tree node to be unlinked (together with all children).
349 * @return 0 for success, nonzero for error
350 */
351int lyd_unlink(struct lyd_node *node);
352
353/**
354 * @brief Free (and unlink) the specified data (sub)tree.
355 *
356 * @param[in] node Root of the (sub)tree to be freed.
357 */
358void lyd_free(struct lyd_node *node);
359
360/**
Radek Krejci81468402016-01-07 13:52:40 +0100361 * @brief Free (and unlink) the specified data (sub)tree and all its siblings (preceding as well as following).
362 *
363 * @param[in] node One of the siblings root element of the (sub)trees to be freed.
364 */
365void lyd_free_withsiblings(struct lyd_node *node);
366
367/**
Radek Krejci134610e2015-10-20 17:15:34 +0200368 * @brief Insert attribute into the data node.
369 *
370 * @param[in] parent Data node where to place the attribute
Radek Krejci5f9e8c92015-10-30 10:01:06 +0100371 * @param[in] name Attribute name including the prefix (prefix:name). Prefix must be the name of one of the
372 * schema in the \p parent's context.
Radek Krejci134610e2015-10-20 17:15:34 +0200373 * @param[in] value Attribute value
374 * @return pointer to the created attribute (which is already connected in \p parent) or NULL on error.
375 */
376struct lyd_attr *lyd_insert_attr(struct lyd_node *parent, const char *name, const char *value);
377
378/**
Radek Krejci88f29302015-10-30 15:42:33 +0100379 * @brief Destroy data attribute
380 *
381 * If the attribute to destroy is a member of a node attribute list, it is necessary to
382 * provide the node itself as \p parent to keep the list consistent.
383 *
384 * @param[in] ctx Context where the attribute was created (usually it is the context of the \p parent)
385 * @param[in] parent Parent node where the attribute is placed
386 * @param[in] attr Attribute to destroy
387 * @param[in] recursive Zero to destroy only the attribute, non-zero to destroy also all the subsequent attributes
388 * in the list.
389 */
390void lyd_free_attr(struct ly_ctx *ctx, struct lyd_node *parent, struct lyd_attr *attr, int recursive);
391
392/**
Michal Vasko2d162e12015-09-24 14:33:29 +0200393 * @brief Opaque internal structure, do not access it from outside.
394 */
395struct lyxml_elem;
396
397/**
398 * @brief Serialize anyxml content for further processing.
399 *
Michal Vasko2d162e12015-09-24 14:33:29 +0200400 * @param[in] anyxml Anyxml content from ::lyd_node_anyxml#value to serialize ax XML string
Michal Vaskoff4c2832015-10-15 13:30:50 +0200401 * @return Serialized content of the anyxml or NULL in case of error. Need to be freed after
402 * done using.
Michal Vasko2d162e12015-09-24 14:33:29 +0200403 */
Michal Vasko1e62a092015-12-01 12:27:20 +0100404char *lyxml_serialize(const struct lyxml_elem *anyxml);
Michal Vasko2d162e12015-09-24 14:33:29 +0200405
Michal Vasko2d162e12015-09-24 14:33:29 +0200406/**@} */
407
408#ifdef __cplusplus
409}
410#endif
411
412#endif /* LY_TREE_DATA_H_ */