@@ -758,7 +758,7 @@ lyd_new_term_bin(struct lyd_node *parent, const struct lys_module *module, const
758758
759759LIBYANG_API_DEF LY_ERR
760760lyd_new_any (struct lyd_node * parent , const struct lys_module * module , const char * name , const struct lyd_node * child ,
761- const char * value , uint32_t options , struct lyd_node * * node )
761+ const char * value , uint32_t hints , uint32_t options , struct lyd_node * * node )
762762{
763763 LY_ERR r ;
764764 struct lyd_node * ret = NULL ;
@@ -782,7 +782,7 @@ lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char
782782 }
783783 LY_CHECK_ERR_RET (r , LOGERR (ctx , LY_EINVAL , "Any node \"%s\" not found." , name ), LY_ENOTFOUND );
784784
785- LY_CHECK_RET (lyd_create_any (schema , child , value , 0 , use_value , 1 , & ret ));
785+ LY_CHECK_RET (lyd_create_any (schema , child , value , hints , use_value , 1 , & ret ));
786786 if (ext ) {
787787 ret -> flags |= LYD_EXT ;
788788 }
@@ -1292,6 +1292,7 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
12921292 struct lyd_node_any * any1 , * any2 ;
12931293 const char * value ;
12941294 struct lyd_node * child , * iter ;
1295+ uint32_t hints ;
12951296
12961297 assert ((node1 -> schema -> nodetype & LYD_NODE_ANY ) && (node2 -> schema -> nodetype & LYD_NODE_ANY ));
12971298
@@ -1301,20 +1302,23 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
13011302 /* backup any1 */
13021303 child = any1 -> child ;
13031304 value = any1 -> value ;
1305+ hints = any1 -> hints ;
13041306
13051307 /* set any1 */
13061308 any1 -> child = any2 -> child ;
13071309 LY_LIST_FOR (any1 -> child , iter ) {
13081310 iter -> parent = & any1 -> node ;
13091311 }
13101312 any1 -> value = any2 -> value ;
1313+ any1 -> hints = any2 -> hints ;
13111314
13121315 /* set any2 */
13131316 any2 -> child = child ;
13141317 LY_LIST_FOR (any2 -> child , iter ) {
13151318 iter -> parent = & any2 -> node ;
13161319 }
13171320 any2 -> value = value ;
1321+ any2 -> hints = hints ;
13181322}
13191323
13201324/**
@@ -1323,6 +1327,7 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
13231327 * @param[in] node Node to update.
13241328 * @param[in] value New value to set.
13251329 * @param[in] value_size_bits Size of @p value in bits.
1330+ * @param[in] any_hints Hints for @p value when updating an anyxml/anydata node.
13261331 * @param[in] options New path options.
13271332 * @param[in] format Format of @p value.
13281333 * @param[in] any_use_value Whether to spend @p value when updating an anydata/anyxml node or not.
@@ -1331,7 +1336,7 @@ lyd_anydata_switch_value(struct lyd_node *node1, struct lyd_node *node2)
13311336 * @return LY_ERR value.
13321337 */
13331338static LY_ERR
1334- lyd_new_path_update (struct lyd_node * node , const void * value , uint32_t value_size_bits , uint32_t options ,
1339+ lyd_new_path_update (struct lyd_node * node , const void * value , uint32_t value_size_bits , uint32_t any_hints , uint32_t options ,
13351340 LY_VALUE_FORMAT format , ly_bool any_use_value , struct lyd_node * * new_parent , struct lyd_node * * new_node )
13361341{
13371342 LY_ERR ret = LY_SUCCESS ;
@@ -1381,7 +1386,7 @@ lyd_new_path_update(struct lyd_node *node, const void *value, uint32_t value_siz
13811386 child = NULL ;
13821387 val_str = value ;
13831388 }
1384- LY_CHECK_RET (lyd_create_any (node -> schema , child , val_str , 0 , any_use_value , 1 , & new_any ));
1389+ LY_CHECK_RET (lyd_create_any (node -> schema , child , val_str , any_hints , any_use_value , 1 , & new_any ));
13851390
13861391 /* compare with the existing one */
13871392 if (lyd_compare_single (node , new_any , 0 )) {
@@ -1492,7 +1497,7 @@ lyd_new_path_check_find_lypath(struct ly_path *path, const char *str_path, const
14921497
14931498LY_ERR
14941499lyd_new_path_create (struct lyd_node * parent , const struct ly_ctx * ctx , struct ly_path * p , const char * path ,
1495- const void * value , uint32_t value_size_bits , uint32_t options , struct lyd_node * * new_parent ,
1500+ const void * value , uint32_t value_size_bits , uint32_t any_hints , uint32_t options , struct lyd_node * * new_parent ,
14961501 struct lyd_node * * new_node )
14971502{
14981503 LY_ERR ret = LY_SUCCESS , r ;
@@ -1531,7 +1536,8 @@ lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly
15311536 }
15321537
15331538 /* update the existing node */
1534- ret = lyd_new_path_update (node , value , value_size_bits , options , format , any_use_value , & nparent , & nnode );
1539+ ret = lyd_new_path_update (node , value , value_size_bits , any_hints , options , format , any_use_value ,
1540+ & nparent , & nnode );
15351541 goto cleanup ;
15361542 } /* else we were not searching for the whole path */
15371543 } else if (r == LY_EINCOMPLETE ) {
@@ -1676,10 +1682,10 @@ lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly
16761682 case LYS_ANYXML :
16771683 if (path_idx < LY_ARRAY_COUNT (p ) - 1 ) {
16781684 /* creating descendants of the node directly, use no value now */
1679- LY_CHECK_GOTO (ret = lyd_create_any (schema , NULL , NULL , 0 , 1 , 0 , & node ), cleanup );
1685+ LY_CHECK_GOTO (ret = lyd_create_any (schema , NULL , NULL , any_hints , 1 , 0 , & node ), cleanup );
16801686 } else {
16811687 LY_CHECK_GOTO (ret = lyd_create_any (schema , (options & LYD_NEW_PATH_ANY_DATATREE ) ? value : NULL ,
1682- (options & LYD_NEW_PATH_ANY_DATATREE ) ? NULL : value , 0 , any_use_value , 1 , & node ), cleanup );
1688+ (options & LYD_NEW_PATH_ANY_DATATREE ) ? NULL : value , any_hints , any_use_value , 1 , & node ), cleanup );
16831689 }
16841690 break ;
16851691 default :
@@ -1746,14 +1752,16 @@ lyd_new_path_create(struct lyd_node *parent, const struct ly_ctx *ctx, struct ly
17461752 * anyxml/anydata node, the expected type depends on @p options. For other node types, it should be NULL.
17471753 * @param[in] value_size_bits Size of @p value in bits, must be set correctly. Ignored when
17481754 * creating anyxml/anydata nodes.
1755+ * @param[in] any_hints Hints for @p value when creating an anyxml/anydata node.
17491756 * @param[in] options Bitmask of options, see @ref pathoptions.
17501757 * @param[out] new_parent Optional first parent node created. If only one node was created, equals to @p new_node.
17511758 * @param[out] new_node Optional last node created.
17521759 * @return LY_ERR value.
17531760 */
17541761static LY_ERR
17551762lyd_new_path_ (struct lyd_node * parent , const struct ly_ctx * ctx , const char * path , const void * value ,
1756- uint32_t value_size_bits , uint32_t options , struct lyd_node * * new_parent , struct lyd_node * * new_node )
1763+ uint32_t value_size_bits , uint32_t any_hints , uint32_t options , struct lyd_node * * new_parent ,
1764+ struct lyd_node * * new_node )
17571765{
17581766 LY_ERR ret = LY_SUCCESS ;
17591767 struct lyxp_expr * exp = NULL ;
@@ -1775,7 +1783,7 @@ lyd_new_path_(struct lyd_node *parent, const struct ly_ctx *ctx, const char *pat
17751783 LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT , LY_PATH_TARGET_MANY , 0 , LY_VALUE_JSON , NULL , & p ), cleanup );
17761784
17771785 /* create nodes */
1778- LY_CHECK_GOTO (ret = lyd_new_path_create (parent , ctx , p , path , value , value_size_bits , options , new_parent ,
1786+ LY_CHECK_GOTO (ret = lyd_new_path_create (parent , ctx , p , path , value , value_size_bits , any_hints , options , new_parent ,
17791787 new_node ), cleanup );
17801788
17811789cleanup :
@@ -1791,12 +1799,13 @@ lyd_new_path(struct lyd_node *parent, const struct ly_ctx *ctx, const char *path
17911799 LY_CHECK_ARG_RET (ctx , parent || ctx , path , (path [0 ] == '/' ) || parent , !(options & LYD_NEW_VAL_BIN ), LY_EINVAL );
17921800 LY_CHECK_CTX_EQUAL_RET (__func__ , parent ? LYD_CTX (parent ) : NULL , ctx , LY_EINVAL );
17931801
1794- return lyd_new_path_ (parent , ctx , path , value , value ? strlen (value ) * 8 : 0 , options , node , NULL );
1802+ return lyd_new_path_ (parent , ctx , path , value , value ? strlen (value ) * 8 : 0 , 0 , options , node , NULL );
17951803}
17961804
17971805LIBYANG_API_DEF LY_ERR
17981806lyd_new_path2 (struct lyd_node * parent , const struct ly_ctx * ctx , const char * path , const void * value ,
1799- uint32_t value_size_bits , uint32_t options , struct lyd_node * * new_parent , struct lyd_node * * new_node )
1807+ uint32_t value_size_bits , uint32_t any_hints , uint32_t options , struct lyd_node * * new_parent ,
1808+ struct lyd_node * * new_node )
18001809{
18011810 LY_CHECK_ARG_RET (ctx , parent || ctx , path , (path [0 ] == '/' ) || parent ,
18021811 !(options & LYD_NEW_VAL_BIN ) || !(options & LYD_NEW_VAL_CANON ), LY_EINVAL );
@@ -1806,7 +1815,7 @@ lyd_new_path2(struct lyd_node *parent, const struct ly_ctx *ctx, const char *pat
18061815 value_size_bits = strlen (value ) * 8 ;
18071816 }
18081817
1809- return lyd_new_path_ (parent , ctx , path , value , value_size_bits , options , new_parent , new_node );
1818+ return lyd_new_path_ (parent , ctx , path , value , value_size_bits , any_hints , options , new_parent , new_node );
18101819}
18111820
18121821LY_ERR
0 commit comments