libyang REFACTOR prefix format always decides the callback (#1169)
So the callback is no longer needed as a parameter.
Also, union no longer uses its own prefix mappings
but instead uses the original format and copies any
required prefix data.
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 5b7d5c6..290f40a 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -95,16 +95,15 @@
* @param[in] value_len Length of @p value, must be set correctly.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] value_hint [Hint options](@ref lydvalueparseopts) from the parser regarding the value type.
- * @param[in] get_prefix Parser-specific getter to resolve prefixes used in the @p value string.
- * @param[in] prefix_data User data for @p get_prefix.
* @param[in] format Input format of @p value.
+ * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
* @param[out] node Created node.
* @return LY_SUCCESS on success.
* @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, int *dynamic, int value_hint,
- ly_resolve_prefix_clb get_prefix, void *prefix_data, LYD_FORMAT format, struct lyd_node **node);
+ LY_PREFIX_FORMAT format, void *prefix_data, struct lyd_node **node);
/**
* @brief Create a term (leaf/leaf-list) node from a parsed value by duplicating it.
@@ -182,8 +181,8 @@
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_create_opaq(const struct ly_ctx *ctx, const char *name, size_t name_len, const char *value, size_t value_len,
- int *dynamic, int value_hint, LYD_FORMAT format, struct ly_prefix *val_prefs, const char *prefix, size_t pref_len,
- const char *module_key, size_t module_key_len, struct lyd_node **node);
+ int *dynamic, int value_hint, LYD_FORMAT format, struct ly_prefix *val_prefs, const char *prefix,
+ size_t pref_len, const char *module_key, size_t module_key_len, struct lyd_node **node);
/**
* @brief Check the existence and create any non-existing implicit siblings, recursively for the created nodes.
@@ -241,9 +240,8 @@
* @param[in] value_len Length of @p value, must be set correctly.
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] value_hint [Value hint](@ref lydvalueparseopts) from the parser regarding the value type.
- * @param[in] resolve_prefix Parser-specific getter to resolve prefixes used in the @p value string.
- * @param[in] prefix_data User data for @p get_prefix.
* @param[in] format Input format of @p value.
+ * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
* @param[in] ctx_snode Context node for value resolution in schema.
* @return LY_SUCCESS on success.
* @return LY_EINCOMPLETE in case data tree is needed to finish the validation.
@@ -251,7 +249,7 @@
*/
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, int *dynamic, int value_hint,
- ly_resolve_prefix_clb resolve_prefix, void *prefix_data, LYD_FORMAT format, const struct lysc_node *ctx_snode);
+ LY_PREFIX_FORMAT format, void *prefix_data, const struct lysc_node *ctx_snode);
/**
* @brief Insert an attribute (last) into a parent
@@ -308,9 +306,8 @@
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] second Flag for the second call after returning LY_EINCOMPLETE
* @param[in] value_hint [Value hint](@ref lydvalueparseopts) from the parser.
- * @param[in] get_prefix Parser-specific getter to resolve prefixes used in the @p value string.
- * @param[in] parser Parser's data for @p get_prefix
* @param[in] format Input format of @p value.
+ * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
* @param[in] tree Data tree (e.g. when validating RPC/Notification) where the required
* data instance (leafref target, instance-identifier) can be placed. NULL in case the data tree are not yet complete,
* then LY_EINCOMPLETE can be returned.
@@ -319,11 +316,11 @@
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_value_parse(struct lyd_node_term *node, const char *value, size_t value_len, int *dynamic, int second, int value_hint,
- ly_resolve_prefix_clb get_prefix, void *parser, LYD_FORMAT format, const struct lyd_node *tree);
+ LY_PREFIX_FORMAT format, void *prefix_data, const struct lyd_node *tree);
/* similar to lyd_value_parse except can be used just to store the value, hence does also not support a second call */
LY_ERR lyd_value_store(struct lyd_value *val, const struct lysc_node *schema, const char *value, size_t value_len,
- int *dynamic, ly_resolve_prefix_clb get_prefix, void *parser, LYD_FORMAT format);
+ int *dynamic, LY_PREFIX_FORMAT format, void *prefix_data);
/**
* @brief Validate, canonize and store the given @p value into the metadata according to the annotation type's rules.
@@ -335,9 +332,8 @@
* @param[in,out] dynamic Flag if @p value is dynamically allocated, is adjusted when @p value is consumed.
* @param[in] second Flag for the second call after returning LY_EINCOMPLETE
* @param[in] value_hint [Value hint](@ref lydvalueparseopts) from the parser.
- * @param[in] get_prefix Parser-specific getter to resolve prefixes used in the @p value string.
- * @param[in] parser Parser's data for @p get_prefix
* @param[in] format Input format of the data.
+ * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
* @param[in] ctx_snode Context node for value resolution in schema.
* @param[in] tree Data tree (e.g. when validating RPC/Notification) where the required
* data instance (leafref target, instance-identifier) can be placed. NULL in case the data tree are not yet complete,
@@ -347,12 +343,12 @@
* @return LY_ERR value if an error occurred.
*/
LY_ERR lyd_value_parse_meta(const struct ly_ctx *ctx, struct lyd_meta *meta, const char *value, size_t value_len,
- int *dynamic, int second, int value_hint, ly_resolve_prefix_clb get_prefix, void *parser,
- LYD_FORMAT format, const struct lysc_node *ctx_snode, const struct lyd_node *tree);
+ int *dynamic, int second, int value_hint, LY_PREFIX_FORMAT format, void *prefix_data,
+ const struct lysc_node *ctx_snode, const struct lyd_node *tree);
/* generic function lys_value_validate */
LY_ERR _lys_value_validate(const struct ly_ctx *ctx, const struct lysc_node *node, const char *value, size_t value_len,
- ly_clb_resolve_prefix resolve_prefix, void *prefix_data, LYD_FORMAT format);
+ LY_PREFIX_FORMAT format, void *prefix_data);
/**
* @brief Parse XML string as YANG data tree.