blob: ba0729e74a1ccb1ef000d47f61880ddeffb81e33 [file] [log] [blame]
Radek Krejcie7b95092019-05-15 11:03:07 +02001/**
2 * @file tree_data_internal.h
3 * @author Radek Krejci <rkrejci@cesnet.cz>
4 * @brief internal functions for YANG schema 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_INTERNAL_H_
16#define LY_TREE_DATA_INTERNAL_H_
17
18#include "tree_data.h"
19
20/**
21 * @brief Get address of a node's child pointer if any.
22 *
23 * Decides the node's type and in case it has a children list, returns its address.
24 * @param[in] node Node to check.
25 * @return Address of the node's child member if any, NULL otherwise.
26 */
27struct lyd_node **lyd_node_children_p(struct lyd_node *node);
28
29/**
30 * @brief Check validity of data parser options.
31 *
32 * @param ctx libyang context
33 * @param options Data parser options to check
34 * @param func name of the function where called
35 * @return LY_SUCCESS when options are ok
36 * @return LY_EINVAL when multiple data types bits are set, or incompatible options are used together.
37 */
38LY_ERR lyd_parse_check_options(struct ly_ctx *ctx, int options, const char *func);
39
40/**
41 * @brief Validate the given value according to the type's rules.
42 *
43 * According to the given options, the value can be also canonized or stored into the node's value structure.
44 *
45 * @param[in] options [Type validation options ](@ref plugintypevalidateopts).
46 */
47LY_ERR lyd_value_validate(struct lyd_node_term *node, const char *value, size_t value_len, int options);
48
49/**
50 * @brief Parse XML string as YANG data tree.
51 *
52 * @param[in] ctx libyang context
53 * @param[in] data Pointer to the XML string representation of the YANG data to parse.
54 * @param[in] options @ref dataparseroptions
55 * @param[out] result Resulting list of the parsed data trees. Note that NULL can be a valid result.
56 * @reutn LY_ERR value.
57 */
58LY_ERR lyd_parse_xml(struct ly_ctx *ctx, const char *data, int options, struct lyd_node **result);
59
60/**
61 * @defgroup datahash Data nodes hash manipulation
62 * @ingroup datatree
63 */
64
65/**
66 * @brief Maintain node's parent's children hash table when unlinking the node.
67 *
68 * When completely freeing data tree, it is expected to free the parent's children hash table first, at once.
69 *
70 * @param[in] node The data node being unlinked from its parent.
71 */
72void lyd_unlink_hash(struct lyd_node *node);
73
74/** @} datahash */
75
76#endif /* LY_TREE_DATA_INTERNAL_H_ */