libyang  1.0.184
YANG data modeling language library
Tree nodes set
Collaboration diagram for Tree nodes set:

Data Structures

union  ly_set_set
 set array of ly_set It is kept in union to keep ly_set generic for data as well as schema trees More...
 
struct  ly_set
 Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects. Caller is supposed to not mix the type of objects added to the set and according to its knowledge about the set content, it is supposed to access the set via the sset, dset or set members of the structure. More...
 

Macros

#define LY_SET_OPT_USEASLIST   0x01
 Option for ly_set_add() to allow duplicities in the ly_set structure so the set is not used as a set, but as a list of (container for) items. More...
 

Functions

struct ly_setly_set_new (void)
 Create and initiate new ly_set structure. More...
 
struct ly_setly_set_dup (const struct ly_set *set)
 Duplicate the existing set. More...
 
int ly_set_add (struct ly_set *set, void *node, int options)
 Add a lyd_node or lys_node object into the set. More...
 
int ly_set_merge (struct ly_set *trg, struct ly_set *src, int options)
 Add all objects from src to trg. More...
 
int ly_set_contains (const struct ly_set *set, void *node)
 Get know if the set contains the specified object. More...
 
int ly_set_clean (struct ly_set *set)
 Remove all objects from the set, but keep the set container for further use. More...
 
int ly_set_rm (struct ly_set *set, void *node)
 Remove a lyd_node or lys_node object from the set. More...
 
int ly_set_rm_index (struct ly_set *set, unsigned int index)
 Remove a lyd_node or lys_node object from the set index. More...
 
void ly_set_free (struct ly_set *set)
 Free the ly_set data. Frees only the set structure content, not the referred data. More...
 

Detailed Description

Structure and functions to hold and manipulate with sets of nodes from schema or data trees.


Data Structure Documentation

◆ ly_set_set

union ly_set_set

set array of ly_set It is kept in union to keep ly_set generic for data as well as schema trees

Definition at line 1691 of file libyang.h.

Data Fields
struct lys_node ** s

array of pointers to a lys_node objects

struct lyd_node ** d

array of pointers to a lyd_node objects

void ** g

dummy array for generic work

◆ ly_set

struct ly_set

Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects. Caller is supposed to not mix the type of objects added to the set and according to its knowledge about the set content, it is supposed to access the set via the sset, dset or set members of the structure.

Until ly_set_rm() or ly_set_rm_index() is used, the set keeps the order of the inserted items as they were added into the set, so the first added item is on array index 0.

To free the structure, use ly_set_free() function, to manipulate with the structure, use other ly_set_* functions.

Definition at line 1708 of file libyang.h.

Data Fields
unsigned int size

allocated size of the set array

unsigned int number

number of elements in (used size of) the set array

union ly_set_set set

set array - union to keep ly_set generic for data as well as schema trees

Macro Definition Documentation

◆ LY_SET_OPT_USEASLIST

#define LY_SET_OPT_USEASLIST   0x01

Option for ly_set_add() to allow duplicities in the ly_set structure so the set is not used as a set, but as a list of (container for) items.

Definition at line 1718 of file libyang.h.

Function Documentation

◆ ly_set_new()

struct ly_set* ly_set_new ( void  )

Create and initiate new ly_set structure.

Returns
Created ly_set structure or NULL in case of error.

◆ ly_set_dup()

struct ly_set* ly_set_dup ( const struct ly_set set)

Duplicate the existing set.

Parameters
[in]setOriginal set to duplicate
Returns
Duplication of the original set.

◆ ly_set_add()

int ly_set_add ( struct ly_set set,
void *  node,
int  options 
)

Add a lyd_node or lys_node object into the set.

Since it is a set, the function checks for duplicity and if the node is already in the set, the index of the previously added node is returned.

Parameters
[in]setSet where the node will be added.
[in]nodeThe lyd_node or lys_node object to be added into the set;
[in]optionsOptions to change behavior of the function. Accepted options are:
Returns
-1 on failure, index of the node in the set on success

◆ ly_set_merge()

int ly_set_merge ( struct ly_set trg,
struct ly_set src,
int  options 
)

Add all objects from src to trg.

Since it is a set, the function checks for duplicities. After success, src is completely freed.

Parameters
[in]trgTarget (result) set.
[in]srcSource set.
[in]optionsOptions to change behavior of the function. Accepted options are:
Returns
-1 on failure, number of objects added into trg on success.

◆ ly_set_contains()

int ly_set_contains ( const struct ly_set set,
void *  node 
)

Get know if the set contains the specified object.

Parameters
[in]setSet to explore.
[in]nodeObject to be found in the set.
Returns
Index of the object in the set or -1 if the object is not present in the set.

◆ ly_set_clean()

int ly_set_clean ( struct ly_set set)

Remove all objects from the set, but keep the set container for further use.

Parameters
[in]setSet to clean.
Returns
0 on success

◆ ly_set_rm()

int ly_set_rm ( struct ly_set set,
void *  node 
)

Remove a lyd_node or lys_node object from the set.

Note that after removing a node from a set, indexes of other nodes in the set can change (the last object is placed instead of the removed object).

Parameters
[in]setSet from which the node will be removed.
[in]nodeThe lyd_node or lys_node object to be removed from the set;
Returns
0 on success

◆ ly_set_rm_index()

int ly_set_rm_index ( struct ly_set set,
unsigned int  index 
)

Remove a lyd_node or lys_node object from the set index.

Note that after removing a node from a set, indexes of other nodes in the set can change (the last object is placed instead of the removed object).

Parameters
[in]setSet from which a node will be removed.
[in]indexIndex of the lyd_node or lys_node object in the set to be removed from the set;
Returns
0 on success

◆ ly_set_free()

void ly_set_free ( struct ly_set set)

Free the ly_set data. Frees only the set structure content, not the referred data.

Parameters
[in]setThe set to be freed.