Skip to main content

lyd_new_path

Function lyd_new_path 

Source
pub unsafe extern "C" fn lyd_new_path(
    parent: *mut lyd_node,
    ctx: *const ly_ctx,
    path: *const c_char,
    value: *const c_char,
    options: u32,
    node: *mut *mut lyd_node,
) -> Type
Expand description

@brief Create a new node in the data tree based on a path. If creating anyxml/anydata nodes, ::lyd_new_path2 should be used instead, this function expects the value as string.

If @p path points to a list key, the key value from the predicate is used and @p value is ignored. Also, if a leaf-list is being created and both a predicate is defined in @p path and @p value is set, the predicate is preferred.

For key-less lists, positional predicates must be used (indices starting from 1). For non-configuration leaf-lists (or lists) either positional predicate can be used or leaf-list (or key) predicate, when an instance is always created at the end. If no predicate is used for these nodes, they are always created.

For anydata nodes, it is possible to directly create its descendants if the @p path continues after the node.

@param[in] parent Data parent to add to/modify, can be NULL. Note that in case a first top-level sibling is used, it may no longer be first if @p path is absolute and starts with a non-existing top-level node inserted before @p parent. Use ::lyd_first_sibling() to adjust @p parent in these cases. @param[in] ctx libyang context, must be set if @p parent is NULL. @param[in] path [Path](@ref howtoXPath) to create. @param[in] value String value of the new leaf/leaf-list in JSON format. For other node types it should be NULL. @param[in] options Bitmask of options, see @ref newvaloptions. @param[out] node Optional first created node. @return LY_SUCCESS on success. @return LY_EEXIST if the final node to create exists (unless ::LYD_NEW_PATH_UPDATE is used). @return LY_EINVAL on invalid arguments including invalid @p path. @return LY_EVALID on invalid @p value. @return LY_ERR on other errors.