data tree FEATURE helpers for opaque nodes
diff --git a/src/tree_data.c b/src/tree_data.c
index e633297..d2c1107 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -3603,6 +3603,23 @@
}
API LY_ERR
+lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match)
+{
+ LY_CHECK_ARG_RET(NULL, name, LY_EINVAL);
+
+ for ( ; first; first = first->next) {
+ if (!first->schema && !strcmp(LYD_NAME(first), name)) {
+ break;
+ }
+ }
+
+ if (match) {
+ *match = (struct lyd_node *)first;
+ }
+ return first ? LY_SUCCESS : LY_ENOTFOUND;
+}
+
+API LY_ERR
lyd_find_xpath(const struct lyd_node *ctx_node, const char *xpath, struct ly_set **set)
{
LY_ERR ret = LY_SUCCESS;
diff --git a/src/tree_data.h b/src/tree_data.h
index cf236ec..0da9335 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -94,6 +94,7 @@
* - ::lyd_find_path()
* - ::lyd_find_sibling_val()
* - ::lyd_find_sibling_first()
+ * - ::lyd_find_sibling_opaq_next()
* - ::lyd_find_meta()
*
* - ::lyd_path()
@@ -677,6 +678,14 @@
};
/**
+ * @brief Get the name (associated with) of a data node. Works for opaque nodes as well.
+ *
+ * @param[in] node Node to examine.
+ * @return Data node name.
+ */
+#define LYD_NAME(node) ((node)->schema ? (node)->schema->name : ((struct lyd_node_opaq *)node)->name.name)
+
+/**
* @ingroup datatree
* @defgroup lydvalhints Value format hints.
* @{
@@ -1790,6 +1799,18 @@
size_t val_len, struct lyd_node **match);
/**
+ * @brief Search the given siblings for an opaque node with a specific name.
+ *
+ * @param[in] first First sibling to consider.
+ * @param[in] name Opaque node name to find.
+ * @param[out] match Can be NULL, otherwise the found data node.
+ * @return LY_SUCCESS on success, @p match set.
+ * @return LY_ENOTFOUND if not found, @p match set to NULL.
+ * @return LY_ERR value is an error occurred.
+ */
+LY_ERR lyd_find_sibling_opaq_next(const struct lyd_node *first, const char *name, struct lyd_node **match);
+
+/**
* @brief Search in the given data for instances of nodes matching the provided XPath.
*
* If a list instance is being selected with all its key values specified (but not necessarily ordered)