data tree CHANGE to clarify purpose, rename data path types
Clarify how the paths generated by lyd_path() can be used.
Fixes #1317
diff --git a/doc/transition.dox b/doc/transition.dox
index 26acd46..bf15c8c 100644
--- a/doc/transition.dox
+++ b/doc/transition.dox
@@ -87,6 +87,7 @@
* - | ::lys_find_xpath() | New function reflecting updated @ref howtoXPath\.
* lys_xpath_atomize() | ::lys_find_xpath_atoms() | Rename to unify with the new API, extends ::lys_find_xpath().
* - | ::lys_find_expr_atoms() | Extension of ::lys_find_xpath().
+ * %lyd_path() | ::lyd_path() | Same purpose, just extended functionality.
* lyd_find_path() | ::lyd_find_xpath() | Rename to unify with the new API.
* - | ::lyxp_get_expr() | Added functionality due to the changed representation of XPath expressions.
* ly_path_data2schema() | - | Removed since the schema path is not available in API.
diff --git a/src/log.c b/src/log.c
index 5208c94..8dde303 100644
--- a/src/log.c
+++ b/src/log.c
@@ -429,7 +429,7 @@
LY_CHECK_ERR_RET(!(*path), LOGMEM(ctx), LY_EMEM);
break;
case LY_VLOG_LYD:
- *path = lyd_path(elem, LYD_PATH_LOG, NULL, 0);
+ *path = lyd_path(elem, LYD_PATH_STD, NULL, 0);
LY_CHECK_ERR_RET(!(*path), LOGMEM(ctx), LY_EMEM);
break;
default:
diff --git a/src/tree_data.c b/src/tree_data.c
index e50849b..e466505 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -3134,8 +3134,8 @@
}
switch (pathtype) {
- case LYD_PATH_LOG:
- case LYD_PATH_LOG_NO_LAST_PRED:
+ case LYD_PATH_STD:
+ case LYD_PATH_STD_NO_LAST_PRED:
depth = 1;
for (iter = node; iter->parent; iter = (const struct lyd_node *)iter->parent) {
++depth;
@@ -3165,7 +3165,7 @@
iter->schema ? iter->schema->name : ((struct lyd_node_opaq *)iter)->name.name);
/* do not always print the last (first) predicate */
- if (iter->schema && ((depth > 1) || (pathtype == LYD_PATH_LOG))) {
+ if (iter->schema && ((depth > 1) || (pathtype == LYD_PATH_STD))) {
switch (iter->schema->nodetype) {
case LYS_LIST:
if (iter->schema->flags & LYS_KEYLESS) {
diff --git a/src/tree_data.h b/src/tree_data.h
index 92b449d..ce2fe7b 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -1589,14 +1589,16 @@
* @brief Types of the different data paths.
*/
typedef enum {
- LYD_PATH_LOG, /**< Descriptive path format used in log messages */
- LYD_PATH_LOG_NO_LAST_PRED /**< Similar to ::LYD_PATH_LOG except there is never a predicate on the last node */
+ LYD_PATH_STD, /**< Generic data path used for logging, node searching (::lyd_find_xpath(), ::lys_find_path()) as well as
+ creating new nodes (::lyd_new_path(), ::lyd_new_path2()). */
+ LYD_PATH_STD_NO_LAST_PRED /**< Similar to ::LYD_PATH_STD except there is never a predicate on the last node. While it
+ can be used to search for nodes, do not use it to create new data nodes (lists). */
} LYD_PATH_TYPE;
/**
* @brief Generate path of the given node in the requested format.
*
- * @param[in] node Schema path of this node will be generated.
+ * @param[in] node Data path of this node will be generated.
* @param[in] pathtype Format of the path to generate.
* @param[in,out] buffer Prepared buffer of the @p buflen length to store the generated path.
* If NULL, memory for the complete path is allocated.
diff --git a/src/validation.c b/src/validation.c
index d823ee1..0bc5ac4 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -854,8 +854,8 @@
}
if (v && (v == LY_ARRAY_COUNT(slist->uniques[u]))) {
/* all unique leafs are the same in this set, create this nice error */
- path1 = lyd_path(first, LYD_PATH_LOG, NULL, 0);
- path2 = lyd_path(second, LYD_PATH_LOG, NULL, 0);
+ path1 = lyd_path(first, LYD_PATH_STD, NULL, 0);
+ path2 = lyd_path(second, LYD_PATH_STD, NULL, 0);
/* use buffer to rebuild the unique string */
#define UNIQ_BUF_SIZE 1024
diff --git a/src/xpath.c b/src/xpath.c
index bd80770..fdba8cd 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -4599,7 +4599,7 @@
LY_ARRAY_NEW_RET(set->ctx, patterns, pattern, LY_EMEM);
*pattern = malloc(sizeof **pattern);
- path = lyd_path(set->cur_node, LYD_PATH_LOG, NULL, 0);
+ path = lyd_path(set->cur_node, LYD_PATH_STD, NULL, 0);
rc = lys_compile_type_pattern_check(set->ctx, path, args[1]->val.str, &(*pattern)->code);
free(path);
if (rc != LY_SUCCESS) {