ly_set_free(set, NULL);
}
+uint32_t yang_dnode_count(const struct lyd_node *dnode, const char *xpath_fmt,
+ ...)
+{
+ va_list ap;
+ char xpath[XPATH_MAXLEN];
+ struct ly_set *set;
+ uint32_t count;
+
+ va_start(ap, xpath_fmt);
+ vsnprintf(xpath, sizeof(xpath), xpath_fmt, ap);
+ va_end(ap);
+
+ if (lyd_find_xpath(dnode, xpath, &set)) {
+ assert(0);
+ return 0;
+ }
+
+ count = set->count;
+
+ ly_set_free(set, NULL);
+
+ return count;
+}
+
bool yang_dnode_is_default(const struct lyd_node *dnode, const char *xpath)
{
const struct lysc_node *snode;
const struct lyd_node *dnode, const char *xpath_fmt,
...) PRINTFRR(4, 5);
+/*
+ * Count the number of data nodes that satisfy an XPath query.
+ *
+ * dnode
+ * Base libyang data node to operate on.
+ *
+ * xpath_fmt
+ * XPath expression (absolute or relative).
+ *
+ * ...
+ * any parameters for xpath_fmt.
+ */
+uint32_t yang_dnode_count(const struct lyd_node *dnode, const char *xpath_fmt,
+ ...) PRINTFRR(2, 3);
+
/*
* Check if the libyang data node contains a default value. Non-presence
* containers are assumed to always contain a default value.