libyang  2.0.112
libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
set.h
Go to the documentation of this file.
1 
15 #ifndef LY_SET_H_
16 #define LY_SET_H_
17 
18 #include <stdint.h>
19 
20 #include "log.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
46 struct ly_set {
47  uint32_t size;
48  uint32_t count;
49  union {
50  struct lyd_node **dnodes;
51  struct lysc_node **snodes;
52  void **objs;
53  };
54 };
55 
64 LY_ERR ly_set_new(struct ly_set **set_p);
65 
78 LY_ERR ly_set_dup(const struct ly_set *set, void *(*duplicator)(void *obj), struct ly_set **newset_p);
79 
93 LY_ERR ly_set_add(struct ly_set *set, void *object, ly_bool list, uint32_t *index_p);
94 
110 LY_ERR ly_set_merge(struct ly_set *trg, const struct ly_set *src, ly_bool list, void *(*duplicator)(void *obj));
111 
120 ly_bool ly_set_contains(const struct ly_set *set, void *object, uint32_t *index_p);
121 
128 void ly_set_clean(struct ly_set *set, void (*destructor)(void *obj));
129 
141 LY_ERR ly_set_rm(struct ly_set *set, void *object, void (*destructor)(void *obj));
142 
154 LY_ERR ly_set_rm_index(struct ly_set *set, uint32_t index, void (*destructor)(void *obj));
155 
163 void ly_set_free(struct ly_set *set, void (*destructor)(void *obj));
164 
172 void ly_set_erase(struct ly_set *set, void (*destructor)(void *obj));
173 
176 #ifdef __cplusplus
177 }
178 #endif
179 
180 #endif /* LY_SET_H_ */
Compiled YANG data node.
Definition: tree_schema.h:1666
LY_ERR ly_set_add(struct ly_set *set, void *object, ly_bool list, uint32_t *index_p)
Add an object into the set.
uint32_t size
Definition: set.h:47
LY_ERR ly_set_new(struct ly_set **set_p)
Create and initiate new ly_set structure.
Generic structure for a data node.
Definition: tree_data.h:759
uint8_t ly_bool
Type to indicate boolean value.
Definition: log.h:25
uint32_t count
Definition: set.h:48
LY_ERR ly_set_rm(struct ly_set *set, void *object, void(*destructor)(void *obj))
Remove an object from the set.
ly_bool ly_set_contains(const struct ly_set *set, void *object, uint32_t *index_p)
Learn whether the set contains the specified object.
void ly_set_erase(struct ly_set *set, void(*destructor)(void *obj))
Alternative to the ly_set_free() for static ly_set objects - in contrast to ly_set_free() it does not...
Structure to hold a set of (not necessary somehow connected) objects. Usually used for lyd_node...
Definition: set.h:46
void ly_set_free(struct ly_set *set, void(*destructor)(void *obj))
Free the ly_set data. If the destructor is not provided, it frees only the set structure content...
LY_ERR ly_set_dup(const struct ly_set *set, void *(*duplicator)(void *obj), struct ly_set **newset_p)
Duplicate the existing set.
LY_ERR ly_set_rm_index(struct ly_set *set, uint32_t index, void(*destructor)(void *obj))
Remove an object on the specific set index.
LY_ERR
libyang&#39;s error codes returned by the libyang functions.
Definition: log.h:245
Logger manipulation routines and error definitions.
void ly_set_clean(struct ly_set *set, void(*destructor)(void *obj))
Remove all objects from the set, but keep the set container for further use.
LY_ERR ly_set_merge(struct ly_set *trg, const struct ly_set *src, ly_bool list, void *(*duplicator)(void *obj))
Add all objects from src to trg.