data tree CHANGE rename pathoptions
Clarify the options names by renaming them from LYD_NEWOPT_* to
LYD_NEW_PATH_* to better fit with functions where the options are used.
diff --git a/src/tree_data.c b/src/tree_data.c
index 0558f37..281f77a 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -1210,12 +1210,12 @@
/* compile path */
LY_CHECK_GOTO(ret = ly_path_compile(ctx, NULL, parent ? parent->schema : NULL, exp, LY_PATH_LREF_FALSE,
- options & LYD_NEWOPT_OUTPUT ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT,
+ options & LYD_NEW_PATH_OUTPUT ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT,
LY_PATH_TARGET_MANY, LY_PREF_JSON, NULL, &p), cleanup);
schema = p[LY_ARRAY_COUNT(p) - 1].node;
if ((schema->nodetype == LYS_LIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE) &&
- !(options & LYD_NEWOPT_OPAQ)) {
+ !(options & LYD_NEW_PATH_OPAQ)) {
LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Predicate missing for %s \"%s\" in path.",
lys_nodetype2str(schema->nodetype), schema->name);
ret = LY_EINVAL;
@@ -1230,7 +1230,7 @@
}
r = LY_SUCCESS;
- if (options & LYD_NEWOPT_OPAQ) {
+ if (options & LYD_NEW_PATH_OPAQ) {
r = lys_value_validate(NULL, schema, value, strlen(value));
}
if (!r) {
@@ -1245,7 +1245,7 @@
ret = ly_path_eval_partial(p, parent, &path_idx, &node);
if (ret == LY_SUCCESS) {
/* the node exists, are we supposed to update it or is it just a default? */
- if (!(options & LYD_NEWOPT_UPDATE) && !(node->flags & LYD_DEFAULT)) {
+ if (!(options & LYD_NEW_PATH_UPDATE) && !(node->flags & LYD_DEFAULT)) {
LOGERR(ctx, LY_EEXIST, "Path \"%s\" already exists", path);
ret = LY_EEXIST;
goto cleanup;
@@ -1276,7 +1276,7 @@
switch (schema->nodetype) {
case LYS_LIST:
if (!(schema->flags & LYS_KEYLESS)) {
- if ((options & LYD_NEWOPT_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
+ if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
/* creating opaque list without keys */
LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, NULL, LYD_JSON,
LYD_NODEHINT_LIST, NULL, NULL, 0, schema->module->name, strlen(schema->module->name), &node),
@@ -1295,7 +1295,7 @@
LY_CHECK_GOTO(ret = lyd_create_inner(schema, &node), cleanup);
break;
case LYS_LEAFLIST:
- if ((options & LYD_NEWOPT_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
+ if ((options & LYD_NEW_PATH_OPAQ) && (p[path_idx].pred_type == LY_PATH_PREDTYPE_NONE)) {
/* creating opaque leaf-list without value */
LY_CHECK_GOTO(ret = lyd_create_opaq(ctx, schema->name, strlen(schema->name), NULL, 0, NULL, LYD_JSON,
LYD_NODEHINT_LEAFLIST, NULL, NULL, 0, schema->module->name, strlen(schema->module->name), &node),
@@ -1312,7 +1312,7 @@
}
r = LY_SUCCESS;
- if (options & LYD_NEWOPT_OPAQ) {
+ if (options & LYD_NEW_PATH_OPAQ) {
r = lys_value_validate(NULL, schema, value, strlen(value));
}
if (!r) {
diff --git a/src/tree_data.h b/src/tree_data.h
index 1380bf0..a7512f2 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -678,15 +678,15 @@
* @{
*/
-#define LYD_NEWOPT_UPDATE 0x01 /**< If the target node exists, is a leaf, and it is updated with a new value or its
- default flag is changed, it is returned. If the target node exists and is not
- a leaf or generally no change occurs in the @p parent tree, NULL is returned and
- no error set. */
-#define LYD_NEWOPT_OUTPUT 0x02 /**< Changes the behavior to ignoring RPC/action input schema nodes and using only
- output ones. */
-#define LYD_NEWOPT_OPAQ 0x04 /**< Enables the creation of opaque nodes with some specific rules. If the __last node__
- in the path is not uniquely defined ((leaf-)list without a predicate) or has an
- invalid value (leaf/leaf-list), it is created as opaque. */
+#define LYD_NEW_PATH_UPDATE 0x01 /**< If the target node exists, is a leaf, and it is updated with a new value or its
+ default flag is changed, it is returned. If the target node exists and is not
+ a leaf or generally no change occurs in the @p parent tree, NULL is returned and
+ no error set. */
+#define LYD_NEW_PATH_OUTPUT 0x02 /**< Changes the behavior to ignoring RPC/action input schema nodes and using only
+ output ones. */
+#define LYD_NEW_PATH_OPAQ 0x04 /**< Enables the creation of opaque nodes with some specific rules. If the __last node__
+ in the path is not uniquely defined ((leaf-)list without a predicate) or has an
+ invalid value (leaf/leaf-list), it is created as opaque. */
/** @} pathoptions */
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index f300873..0d2fb28 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -249,7 +249,7 @@
assert_int_equal(ret, LY_EINVAL);
logbuf_assert("Predicate missing for list \"l1\" in path.");
- ret = lyd_new_path2(NULL, ctx, "/a:l1", NULL, 0, LYD_NEWOPT_OPAQ, NULL, &root);
+ ret = lyd_new_path2(NULL, ctx, "/a:l1", NULL, 0, LYD_NEW_PATH_OPAQ, NULL, &root);
assert_int_equal(ret, LY_SUCCESS);
assert_non_null(root);
assert_null(root->schema);
@@ -260,7 +260,7 @@
assert_int_equal(ret, LY_EVALID);
logbuf_assert("Invalid empty uint16 value. /a:foo");
- ret = lyd_new_path2(NULL, ctx, "/a:foo", NULL, 0, LYD_NEWOPT_OPAQ, NULL, &root);
+ ret = lyd_new_path2(NULL, ctx, "/a:foo", NULL, 0, LYD_NEW_PATH_OPAQ, NULL, &root);
assert_int_equal(ret, LY_SUCCESS);
assert_non_null(root);
assert_null(root->schema);
@@ -277,11 +277,11 @@
ret = lyd_new_path2(root, NULL, "/a:l2[1]/c/x", "val", 0, 0, NULL, &node);
assert_int_equal(ret, LY_EEXIST);
- ret = lyd_new_path2(root, NULL, "/a:l2[1]/c/x", "val", 0, LYD_NEWOPT_UPDATE, NULL, &node);
+ ret = lyd_new_path2(root, NULL, "/a:l2[1]/c/x", "val", 0, LYD_NEW_PATH_UPDATE, NULL, &node);
assert_int_equal(ret, LY_SUCCESS);
assert_null(node);
- ret = lyd_new_path2(root, NULL, "/a:l2[1]/c/x", "val2", 0, LYD_NEWOPT_UPDATE, NULL, &node);
+ ret = lyd_new_path2(root, NULL, "/a:l2[1]/c/x", "val2", 0, LYD_NEW_PATH_UPDATE, NULL, &node);
assert_int_equal(ret, LY_SUCCESS);
assert_non_null(node);
assert_string_equal(node->schema->name, "x");