blob: d6225dc587b45c49c2a889212603250e4f55297e [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"
Radek Krejciaca74032019-06-04 08:53:06 +020019#include "plugins_types.h"
Radek Krejcie7b95092019-05-15 11:03:07 +020020
21/**
22 * @brief Get address of a node's child pointer if any.
23 *
24 * Decides the node's type and in case it has a children list, returns its address.
25 * @param[in] node Node to check.
26 * @return Address of the node's child member if any, NULL otherwise.
27 */
28struct lyd_node **lyd_node_children_p(struct lyd_node *node);
29
30/**
31 * @brief Check validity of data parser options.
32 *
33 * @param ctx libyang context
34 * @param options Data parser options to check
35 * @param func name of the function where called
36 * @return LY_SUCCESS when options are ok
37 * @return LY_EINVAL when multiple data types bits are set, or incompatible options are used together.
38 */
39LY_ERR lyd_parse_check_options(struct ly_ctx *ctx, int options, const char *func);
40
41/**
Radek Krejci5819f7c2019-05-31 14:53:29 +020042 * @brief Validate, canonize and store the given @p value into the node according to the node's type's rules.
Radek Krejcie7b95092019-05-15 11:03:07 +020043 *
Radek Krejci5819f7c2019-05-31 14:53:29 +020044 * @param[in] node Data node for with the @p value.
45 * @param[in] value String value to be parsed.
46 * @param[in] value_len Length of the give @p value (mandatory).
47 * @param[in] dynamic Flag if @p value is a dynamically allocated memory and should be directly consumed/freed inside the function.
Radek Krejciaca74032019-06-04 08:53:06 +020048 * @param[in] get_prefix Parser-specific getter to resolve prefixes used in the value strings.
49 * @param[in] parser Parser's data for @p get_prefix
Radek Krejci5819f7c2019-05-31 14:53:29 +020050 * @return LY_ERR value.
Radek Krejcie7b95092019-05-15 11:03:07 +020051 */
Radek Krejciaca74032019-06-04 08:53:06 +020052LY_ERR lyd_value_parse(struct lyd_node_term *node, const char *value, size_t value_len, int dynamic, ly_type_resolve_prefix get_prefix, void *parser);
Radek Krejcie7b95092019-05-15 11:03:07 +020053
54/**
55 * @brief Parse XML string as YANG data tree.
56 *
57 * @param[in] ctx libyang context
58 * @param[in] data Pointer to the XML string representation of the YANG data to parse.
59 * @param[in] options @ref dataparseroptions
60 * @param[out] result Resulting list of the parsed data trees. Note that NULL can be a valid result.
61 * @reutn LY_ERR value.
62 */
63LY_ERR lyd_parse_xml(struct ly_ctx *ctx, const char *data, int options, struct lyd_node **result);
64
65/**
66 * @defgroup datahash Data nodes hash manipulation
67 * @ingroup datatree
68 */
69
70/**
71 * @brief Maintain node's parent's children hash table when unlinking the node.
72 *
73 * When completely freeing data tree, it is expected to free the parent's children hash table first, at once.
74 *
75 * @param[in] node The data node being unlinked from its parent.
76 */
77void lyd_unlink_hash(struct lyd_node *node);
78
79/** @} datahash */
80
81#endif /* LY_TREE_DATA_INTERNAL_H_ */