summaryrefslogtreecommitdiffstats
path: root/src/xpath.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/xpath.h')
-rw-r--r--src/xpath.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/xpath.h b/src/xpath.h
index 3e61bb0..17bda6c 100644
--- a/src/xpath.h
+++ b/src/xpath.h
@@ -291,13 +291,15 @@ struct lyxp_set {
/* this is valid only for type LYXP_SET_NODE_SET and LYXP_SET_SCNODE_SET */
uint32_t used; /**< Number of nodes in the set. */
uint32_t size; /**< Allocated size for the set. */
- struct hash_table *ht; /**< Hash table for quick determination of whether a node is in the set. */
+ struct ly_ht *ht; /**< Hash table for quick determination of whether a node is in the set. */
/* XPath context information, this is valid only for type LYXP_SET_NODE_SET */
uint32_t ctx_pos; /**< Position of the current examined node in the set. */
uint32_t ctx_size; /**< Position of the last node at the time the node was examined. */
ly_bool non_child_axis; /**< Whether any node change was performed on a non-child axis. */
+ ly_bool not_found; /**< Set if a node is not found and it is considered an error. */
+
/* general context */
struct ly_ctx *ctx; /**< General context for logging. */
@@ -327,6 +329,8 @@ const char *lyxp_token2str(enum lyxp_token tok);
* @brief Evaluate an XPath expression on data. Be careful when using this function, the result can often
* be confusing without thorough understanding of XPath evaluation rules defined in RFC 7950.
*
+ * Traverses (valid) opaque nodes in the evaluation.
+ *
* @param[in] ctx libyang context to use.
* @param[in] exp Parsed XPath expression to be evaluated.
* @param[in] cur_mod Current module for the expression (where it was "instantiated").
@@ -381,6 +385,7 @@ LY_ERR lyxp_atomize(const struct ly_ctx *ctx, const struct lyxp_expr *exp, const
warning is printed. */
#define LYXP_ACCESS_TREE_ALL 0x80 /**< Explicit accessible tree of all the nodes. */
#define LYXP_ACCESS_TREE_CONFIG 0x0100 /**< Explicit accessible tree of only configuration data. */
+#define LYXP_SCNODE_SCHEMAMOUNT LYS_FIND_SCHEMAMOUNT /**< Nodes from mounted modules are also accessible. */
/**
* @brief Cast XPath set to another type.
@@ -421,6 +426,20 @@ ly_bool lyxp_set_scnode_contains(struct lyxp_set *set, const struct lysc_node *n
void lyxp_set_scnode_merge(struct lyxp_set *set1, struct lyxp_set *set2);
/**
+ * @brief Insert schema node into set.
+ *
+ * @param[in] set Set to insert into.
+ * @param[in] node Node to insert.
+ * @param[in] node_type Node type of @p node.
+ * @param[in] axis Axis that @p node was reached on.
+ * @param[out] index_p Optional pointer to store the index of the inserted @p node.
+ * @return LY_SUCCESS on success.
+ * @return LY_EMEM on memory allocation failure.
+ */
+LY_ERR lyxp_set_scnode_insert_node(struct lyxp_set *set, const struct lysc_node *node, enum lyxp_node_type node_type,
+ enum lyxp_axis axis, uint32_t *index_p);
+
+/**
* @brief Parse an XPath expression into a structure of tokens.
* Logs directly.
*
@@ -496,15 +515,17 @@ LY_ERR lyxp_next_token2(const struct ly_ctx *ctx, const struct lyxp_expr *exp, u
enum lyxp_token want_tok1, enum lyxp_token want_tok2);
/**
- * @brief Find variable named @name in @p vars.
+ * @brief Find variable named @p name in @p vars.
*
+ * @param[in] ctx Context for logging, not logged if NULL.
* @param[in] vars [Sized array](@ref sizedarrays) of XPath variables.
* @param[in] name Name of the variable being searched.
* @param[in] name_len Name length can be set to 0 if @p name is terminated by null byte.
* @param[out] var Variable that was found. The parameter is optional.
* @return LY_SUCCESS if the variable was found, otherwise LY_ENOTFOUND.
*/
-LY_ERR lyxp_vars_find(struct lyxp_var *vars, const char *name, size_t name_len, struct lyxp_var **var);
+LY_ERR lyxp_vars_find(const struct ly_ctx *ctx, const struct lyxp_var *vars, const char *name, size_t name_len,
+ struct lyxp_var **var);
/**
* @brief Frees a parsed XPath expression. @p expr should not be used afterwards.