summaryrefslogtreecommitdiffstats
path: root/src/tree_data_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tree_data_internal.h')
-rw-r--r--src/tree_data_internal.h56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index fd0792d..cfb93f1 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -4,7 +4,7 @@
* @author Michal Vasko <mvasko@cesnet.cz>
* @brief internal functions for YANG schema trees.
*
- * Copyright (c) 2015 - 2022 CESNET, z.s.p.o.
+ * Copyright (c) 2015 - 2023 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
@@ -34,31 +34,30 @@ struct lysc_module;
#define LY_LYB_SUFFIX_LEN 4
/**
- * @brief Internal structure for remembering "used" instances of lists with duplicate instances allowed.
+ * @brief Internal item structure for remembering "used" instances of duplicate node instances.
*/
struct lyd_dup_inst {
- struct ly_set *inst_set;
+ struct ly_set *set;
uint32_t used;
};
/**
- * @brief Update a found inst using a duplicate instance cache. Needs to be called for every "used"
+ * @brief Update a found inst using a duplicate instance cache hash table. Needs to be called for every "used"
* (that should not be considered next time) instance.
*
* @param[in,out] inst Found instance, is updated so that the same instance is not returned twice.
* @param[in] siblings Siblings where @p inst was found.
- * @param[in,out] dup_inst_cache Duplicate instance cache.
+ * @param[in] dup_inst_ht Duplicate instance cache hash table.
* @return LY_ERR value.
*/
-LY_ERR lyd_dup_inst_next(struct lyd_node **inst, const struct lyd_node *siblings,
- struct lyd_dup_inst **dup_inst_cache);
+LY_ERR lyd_dup_inst_next(struct lyd_node **inst, const struct lyd_node *siblings, struct ly_ht **dup_inst_ht);
/**
* @brief Free duplicate instance cache.
*
- * @param[in] dup_inst Duplicate instance cache to free.
+ * @param[in] dup_inst Duplicate instance cache hash table to free.
*/
-void lyd_dup_inst_free(struct lyd_dup_inst *dup_inst);
+void lyd_dup_inst_free(struct ly_ht *dup_inst_ht);
/**
* @brief Just like ::lys_getnext() but iterates over all data instances of the schema nodes.
@@ -118,14 +117,6 @@ const struct lys_module *lyd_mod_next_module(struct lyd_node *tree, const struct
const struct lys_module *lyd_data_next_module(struct lyd_node **next, struct lyd_node **first);
/**
- * @brief Get schema node of a data node. Useful especially for opaque nodes.
- *
- * @param[in] node Data node to use.
- * @return Schema node represented by data @p node, NULL if there is none.
- */
-const struct lysc_node *lyd_node_schema(const struct lyd_node *node);
-
-/**
* @brief Set dflt flag for a NP container if applicable, recursively for parents.
*
* @param[in] node Node whose criteria for the dflt flag has changed.
@@ -233,6 +224,7 @@ const char *ly_format2str(LY_VALUE_FORMAT format);
* @param[in] schema Schema node of the new data node.
* @param[in] value String value to be parsed.
* @param[in] value_len Length of @p value, must be set correctly.
+ * @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
@@ -243,8 +235,9 @@ const char *ly_format2str(LY_VALUE_FORMAT format);
* @return LY_EINCOMPLETE in case data tree is needed to finish the validation.
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool *dynamic,
- LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, ly_bool *incomplete, struct lyd_node **node);
+LY_ERR lyd_create_term(const struct lysc_node *schema, const char *value, size_t value_len, ly_bool is_utf8,
+ ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, ly_bool *incomplete,
+ struct lyd_node **node);
/**
* @brief Create a term (leaf/leaf-list) node from a parsed value by duplicating it.
@@ -280,11 +273,13 @@ LY_ERR lyd_create_inner(const struct lysc_node *schema, struct lyd_node **node);
*
* @param[in] schema Schema node of the new data node.
* @param[in] predicates Compiled key list predicates.
+ * @param[in] vars Array of defined variables to use in predicates, may be NULL.
* @param[out] node Created node.
* @return LY_SUCCESS on success.
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates, struct lyd_node **node);
+LY_ERR lyd_create_list(const struct lysc_node *schema, const struct ly_path_predicate *predicates,
+ const struct lyxp_var *vars, struct lyd_node **node);
/**
* @brief Create a list with all its keys (cannot be used for key-less list).
@@ -403,6 +398,13 @@ void lyd_insert_before_node(struct lyd_node *sibling, struct lyd_node *node);
void lyd_insert_node(struct lyd_node *parent, struct lyd_node **first_sibling, struct lyd_node *node, ly_bool last);
/**
+ * @brief Unlink the specified data subtree.
+ *
+ * @param[in] node Data tree node to be unlinked (together with all the children).
+ */
+void lyd_unlink(struct lyd_node *node);
+
+/**
* @brief Insert a metadata (last) into a parent
*
* @param[in] parent Parent of the metadata.
@@ -421,6 +423,7 @@ void lyd_insert_meta(struct lyd_node *parent, struct lyd_meta *meta, ly_bool cle
* @param[in] name_len Length of @p name, must be set correctly.
* @param[in] value String value to be parsed.
* @param[in] value_len Length of @p value, must be set correctly.
+ * @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
@@ -433,7 +436,7 @@ void lyd_insert_meta(struct lyd_node *parent, struct lyd_meta *meta, ly_bool cle
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_meta(struct lyd_node *parent, struct lyd_meta **meta, const struct lys_module *mod, const char *name,
- size_t name_len, const char *value, size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format,
+ size_t name_len, const char *value, size_t value_len, ly_bool is_utf8, ly_bool *dynamic, LY_VALUE_FORMAT format,
void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node, ly_bool clear_dflt, ly_bool *incomplete);
/**
@@ -477,6 +480,7 @@ LY_ERR lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const st
* @param[in] type Type of the value.
* @param[in] value Value to be parsed, must not be NULL.
* @param[in] value_len Length of the give @p value, must be set correctly.
+ * @param[in] is_utf8 Whether @p value is a valid UTF-8 string, if applicable.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] format Input format of @p value.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
@@ -487,7 +491,7 @@ LY_ERR lyd_create_attr(struct lyd_node *parent, struct lyd_attr **attr, const st
* @return LY_ERR value on error.
*/
LY_ERR lyd_value_store(const struct ly_ctx *ctx, struct lyd_value *val, const struct lysc_type *type, const void *value,
- size_t value_len, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
+ size_t value_len, ly_bool is_utf8, ly_bool *dynamic, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
const struct lysc_node *ctx_node, ly_bool *incomplete);
/**
@@ -505,8 +509,7 @@ LY_ERR lyd_value_validate_incomplete(const struct ly_ctx *ctx, const struct lysc
const struct lyd_node *ctx_node, const struct lyd_node *tree);
/**
- * @brief Check type restrictions applicable to the particular leaf/leaf-list with the given string @p value coming
- * from a schema.
+ * @brief Check type restrictions applicable to the particular leaf/leaf-list with the given string @p value.
*
* This function check just the type's restriction, if you want to check also the data tree context (e.g. in case of
* require-instance restriction), use ::lyd_value_validate().
@@ -517,11 +520,12 @@ LY_ERR lyd_value_validate_incomplete(const struct ly_ctx *ctx, const struct lysc
* @param[in] value_len Length of the given @p value (mandatory).
* @param[in] format Value prefix format.
* @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
+ * @param[in] hints Value encoding hints.
* @return LY_SUCCESS on success
* @return LY_ERR value if an error occurred.
*/
-LY_ERR lys_value_validate(const struct ly_ctx *ctx, const struct lysc_node *node, const char *value, size_t value_len,
- LY_VALUE_FORMAT format, void *prefix_data);
+LY_ERR ly_value_validate(const struct ly_ctx *ctx, const struct lysc_node *node, const char *value, size_t value_len,
+ LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints);
/**
* @defgroup datahash Data nodes hash manipulation