summaryrefslogtreecommitdiff
path: root/lib/yang.h
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2024-01-06 09:45:29 +0000
committerChristian Hopps <chopps@labn.net>2024-01-07 15:17:30 +0000
commitcf67a7e26577b0dda276324b40a602ae084e504e (patch)
tree7019c29239c15d507736b2330ead23774d636481 /lib/yang.h
parent00138ffb47acc58a49e93a9b291a4b9e0c92096e (diff)
lib: mgmtd: implement full XPath 1.0 predicate functionality
Allow user to specify full YANG compatible XPath 1.0 predicates. This allows for trimming results of generic queries using functions and other non-key predicates from XPath 1.0 Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/yang.h')
-rw-r--r--lib/yang.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/yang.h b/lib/yang.h
index 3ce584b347..75dcab2d2a 100644
--- a/lib/yang.h
+++ b/lib/yang.h
@@ -724,6 +724,35 @@ extern LY_ERR yang_lyd_new_list(struct lyd_node_inner *parent,
const struct lysc_node *snode,
const struct yang_list_keys *keys,
struct lyd_node_inner **node);
+/**
+ * yang_resolve_snodes() - Resolve an XPath to matching schema nodes.
+ * @ly_ctx: libyang context to operate on.
+ * @xpath: the path or XPath to resolve.
+ * @snodes: [OUT] pointer for resulting dynamic array (darr) of schema node
+ * pointers.
+ * @simple: [OUT] indicates if @xpath was resolvable simply or not. Non-simple
+ * means that the @xpath is not a simple path and utilizes XPath 1.0
+ * functionality beyond simple key predicates.
+ *
+ * This function can be used to find the schema node (or nodes) that correspond
+ * to a given @xpath. If the @xpath includes non-key predicates (e.g., using
+ * functions) then @simple will be set to false, and @snodes may contain more
+ * than a single schema node.
+ *
+ * Return: a libyang error or LY_SUCCESS.
+ */
+extern LY_ERR yang_resolve_snode_xpath(struct ly_ctx *ly_ctx, const char *xpath,
+ struct lysc_node ***snodes, bool *simple);
+
+/**
+ * yang_trim_tree() - trim the data tree to the given xpath
+ * @root: the data tree
+ * @xpath: the xpath to trim @root to.
+ *
+ * Return: enum nb_error..
+ */
+extern int yang_trim_tree(struct lyd_node *root, const char *xpath);
+
#ifdef __cplusplus
}
#endif