libyang  0.16.105
YANG data modeling language library
Libyang.cpp
Go to the documentation of this file.
1 
15 #include <iostream>
16 #include <memory>
17 #include <stdexcept>
18 #include <vector>
19 
20 #include "Xml.hpp"
21 #include "Internal.hpp"
22 #include "Libyang.hpp"
23 #include "Tree_Data.hpp"
24 #include "Tree_Schema.hpp"
25 
26 extern "C" {
27 #include "libyang.h"
28 #include "tree_data.h"
29 #include "tree_schema.h"
30 #include "context.h"
31 }
32 
33 namespace libyang {
34 
35 Context::Context(ly_ctx *ctx, S_Deleter deleter):
36  ctx(ctx),
37  deleter(deleter)
38 {};
39 Context::Context(const char *search_dir, int options) {
40  ctx = ly_ctx_new(search_dir, options);
41  if (!ctx) {
42  check_libyang_error(nullptr);
43  }
44  deleter = std::make_shared<Deleter>(ctx);
45 }
46 Context::Context(const char *search_dir, const char *path, LYD_FORMAT format, int options) {
47  ctx = ly_ctx_new_ylpath(search_dir, path, format, options);
48  if (!ctx) {
49  check_libyang_error(nullptr);
50  }
51  deleter = std::make_shared<Deleter>(ctx);
52 }
53 Context::Context(const char *search_dir, LYD_FORMAT format, const char *data, int options) {
54  ctx = ly_ctx_new_ylmem(search_dir, data, format, options);
55  if (!ctx) {
56  check_libyang_error(nullptr);
57  }
58  deleter = std::make_shared<Deleter>(ctx);
59 }
61 int Context::set_searchdir(const char *search_dir) {
62  int ret = ly_ctx_set_searchdir(ctx, search_dir);
63  if (ret) {
64  check_libyang_error(ctx);
65  }
66  return ret;
67 }
68 S_Data_Node Context::info() {
69  struct lyd_node *new_node = ly_ctx_info(ctx);
70  if (!new_node) {
71  check_libyang_error(ctx);
72  return nullptr;
73  }
74 
75  S_Deleter new_deleter = std::make_shared<Deleter>(new_node, deleter);
76  return std::make_shared<Data_Node>(new_node, new_deleter);
77 }
78 S_Module Context::get_module(const char *name, const char *revision, int implemented) {
79  const struct lys_module *module = ly_ctx_get_module(ctx, name, revision, implemented);
80  return module ? std::make_shared<Module>((lys_module *) module, deleter) : nullptr;
81 }
82 S_Module Context::get_module_older(S_Module module) {
83  const struct lys_module *new_module = ly_ctx_get_module_older(ctx, module->module);
84  return new_module ? std::make_shared<Module>((lys_module *) new_module, deleter) : nullptr;
85 }
86 S_Module Context::load_module(const char *name, const char *revision) {
87  const struct lys_module *module = ly_ctx_load_module(ctx, name, revision);
88  if (!module) {
89  check_libyang_error(ctx);
90  }
91  return module ? std::make_shared<Module>((lys_module *) module, deleter) : nullptr;
92 }
93 S_Module Context::get_module_by_ns(const char *ns, const char *revision, int implemented) {
94  const struct lys_module *module = ly_ctx_get_module_by_ns(ctx, ns, revision, implemented);
95  return module ? std::make_shared<Module>((lys_module *) module, deleter) : nullptr;
96 }
97 std::vector<S_Module> Context::get_module_iter() {
98  const struct lys_module *mod = nullptr;
99  uint32_t i = 0;
100 
101  std::vector<S_Module> s_vector;
102 
103  while ((mod = ly_ctx_get_module_iter(ctx, &i))) {
104  if (mod == nullptr) {
105  break;
106  }
107  s_vector.push_back(std::make_shared<Module>((lys_module *) mod, deleter));
108  }
109 
110  return s_vector;
111 }
112 std::vector<S_Module> Context::get_disabled_module_iter() {
113  const struct lys_module *mod = nullptr;
114  uint32_t i = 0;
115 
116  std::vector<S_Module> s_vector;
117 
118  while ((mod = ly_ctx_get_disabled_module_iter(ctx, &i))) {
119  if (mod == nullptr) {
120  break;
121  }
122  s_vector.push_back(std::make_shared<Module>((lys_module *) mod, deleter));
123  }
124 
125  return s_vector;
126 }
128  return ly_ctx_clean(ctx, nullptr);
129 }
130 std::vector<std::string> Context::get_searchdirs() {
131  std::vector<std::string> s_vector;
132  const char * const *data = ly_ctx_get_searchdirs(ctx);
133  if (!data) {
134  return s_vector;
135  }
136 
137  int size = 0;
138  while (true) {
139  if (data[size] == nullptr) {
140  break;
141  }
142  s_vector.push_back(std::string(data[size]));
143  size++;
144  }
145 
146  return s_vector;
147 };
148 S_Submodule Context::get_submodule(const char *module, const char *revision, const char *submodule, const char *sub_revision) {
149  const struct lys_submodule *tmp_submodule = nullptr;
150 
151  tmp_submodule = ly_ctx_get_submodule(ctx, module, revision, submodule, sub_revision);
152 
153  return tmp_submodule ? std::make_shared<Submodule>((struct lys_submodule *) tmp_submodule, deleter) : nullptr;
154 }
155 S_Submodule Context::get_submodule2(S_Module main_module, const char *submodule) {
156  const struct lys_submodule *tmp_submodule = nullptr;
157 
158  tmp_submodule = ly_ctx_get_submodule2(main_module->module, submodule);
159 
160  return tmp_submodule ? std::make_shared<Submodule>((struct lys_submodule *) tmp_submodule, deleter) : nullptr;
161 }
162 S_Schema_Node Context::get_node(S_Schema_Node start, const char *data_path, int output) {
163  const struct lys_node *node = nullptr;
164 
165  node = ly_ctx_get_node(ctx, start->node, data_path, output);
166 
167  return node ? std::make_shared<Schema_Node>((struct lys_node *) node, deleter) : nullptr;
168 }
169 S_Set Context::find_path(const char *schema_path) {
170  struct ly_set *set = ly_ctx_find_path(ctx, schema_path);
171  if (!set) {
172  return nullptr;
173  }
174 
175  S_Deleter new_deleter = std::make_shared<Deleter>(set, deleter);
176  return std::make_shared<Set>(set, new_deleter);
177 }
178 std::vector<S_Schema_Node> Context::data_instantiables(int options) {
179  std::vector<S_Schema_Node> s_vector;
180  struct lys_node *iter = NULL;
181  int i;
182 
183  for (i = 0; i < ctx->models.used; i++) {
184  while ((iter = (struct lys_node *)lys_getnext(iter, NULL, ctx->models.list[i], options))) {
185  s_vector.push_back(std::make_shared<Schema_Node>(iter, deleter));
186  }
187  }
188 
189  return s_vector;
190 }
191 S_Data_Node Context::parse_data_mem(const char *data, LYD_FORMAT format, int options) {
192  struct lyd_node *new_node = nullptr;
193 
194  new_node = lyd_parse_mem(ctx, data, format, options, NULL);
195  if (!new_node) {
196  check_libyang_error(ctx);
197  return nullptr;
198  }
199 
200  S_Deleter new_deleter = std::make_shared<Deleter>(new_node, deleter);
201  return std::make_shared<Data_Node>(new_node, new_deleter);
202 }
203 S_Data_Node Context::parse_data_fd(int fd, LYD_FORMAT format, int options) {
204  struct lyd_node *new_node = nullptr;
205 
206  new_node = lyd_parse_fd(ctx, fd, format, options, NULL);
207  if (!new_node) {
208  check_libyang_error(ctx);
209  return nullptr;
210  }
211 
212  S_Deleter new_deleter = std::make_shared<Deleter>(new_node, deleter);
213  return std::make_shared<Data_Node>(new_node, new_deleter);
214 }
215 
216 S_Module Context::parse_module_mem(const char *data, LYS_INFORMAT format) {
217  struct lys_module *module = nullptr;
218 
219  module = (struct lys_module *) lys_parse_mem(ctx, data, format);
220  if (!module) {
221  check_libyang_error(ctx);
222  return nullptr;
223  }
224 
225  S_Deleter new_deleter = std::make_shared<Deleter>(module, deleter);
226  return std::make_shared<Module>(module, new_deleter);
227 }
228 S_Module Context::parse_module_fd(int fd, LYS_INFORMAT format) {
229  struct lys_module *module = nullptr;
230 
231  module = (struct lys_module *) lys_parse_fd(ctx, fd, format);
232  if (!module) {
233  check_libyang_error(ctx);
234  return nullptr;
235  }
236 
237  S_Deleter new_deleter = std::make_shared<Deleter>(module, deleter);
238  return std::make_shared<Module>(module, new_deleter);
239 }
240 S_Module Context::parse_module_path(const char *path, LYS_INFORMAT format) {
241  struct lys_module *module = nullptr;
242 
243  module = (struct lys_module *) lys_parse_path(ctx, path, format);
244  if (!module) {
245  check_libyang_error(ctx);
246  return nullptr;
247  }
248 
249  S_Deleter new_deleter = std::make_shared<Deleter>(module, deleter);
250  return std::make_shared<Module>(module, new_deleter);
251 }
252 S_Data_Node Context::parse_data_path(const char *path, LYD_FORMAT format, int options) {
253  struct lyd_node *new_node = nullptr;
254 
255  new_node = lyd_parse_path(ctx, path, format, options, NULL);
256  if (!new_node) {
257  check_libyang_error(ctx);
258  return nullptr;
259  }
260 
261  S_Deleter new_deleter = std::make_shared<Deleter>(new_node, deleter);
262  return std::make_shared<Data_Node>(new_node, new_deleter);
263 }
264 S_Data_Node Context::parse_data_xml(S_Xml_Elem elem, int options) {
265  struct lyd_node *new_node = nullptr;
266 
267  new_node = lyd_parse_xml(ctx, &elem->elem, options, NULL);
268  if (!new_node) {
269  check_libyang_error(ctx);
270  return nullptr;
271  }
272 
273  S_Deleter new_deleter = std::make_shared<Deleter>(new_node, deleter);
274  return std::make_shared<Data_Node>(new_node, new_deleter);
275 }
276 
278 {
279  if (mod_missing_cb.empty()) {
281  }
282  mod_missing_cb.emplace_back(std::move(callback), std::move(deleter));
283 }
284 
285 const char* Context::cpp_mod_missing_cb(const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev, void *user_data, LYS_INFORMAT *format, void (**free_module_data)(void*, void*))
286 {
287  Context *ctx = static_cast<Context*>(user_data);
288  for (const auto &x : ctx->mod_missing_cb) {
289  const auto &cb = x.first;
290  auto ret = cb(mod_name, mod_rev, submod_name, sub_rev);
291  if (ret.data) {
292  *format = ret.format;
293  if (x.second) {
294  ctx->mod_missing_deleter.push_back(&x.second);
295  *free_module_data = Context::cpp_mod_missing_deleter;
296  }
297  return ret.data;
298  }
299  if (ly_errno != LY_SUCCESS) {
300  // The C API docs say that we should not try any more callbacks
301  return nullptr;
302  }
303  }
304  return nullptr;
305 }
306 
307 void Context::cpp_mod_missing_deleter(void *data, void *user_data)
308 {
309  Context *ctx = static_cast<Context*>(user_data);
310  (*ctx->mod_missing_deleter.back())(data);
311  ctx->mod_missing_deleter.pop_back();
312 }
313 
314 
315 Error::Error(struct ly_err_item *eitem):
316  eitem(eitem)
317 {};
318 
319 std::vector<S_Error> get_ly_errors(S_Context context)
320 {
321  std::vector<S_Error> s_vector;
322  if (!context) {
323  return s_vector;
324  }
325 
326  struct ly_err_item *first_eitem = ly_err_first(context->ctx);
327  if (!first_eitem) {
328  return s_vector;
329  }
330 
331  struct ly_err_item *eitem = first_eitem;
332  while (eitem) {
333  s_vector.push_back(std::make_shared<Error>(eitem));
334  eitem = eitem->next;
335  }
336 
337  return s_vector;
338 }
339 
340 int set_log_options(int options)
341 {
342  return ly_log_options(options);
343 }
344 
346 {
347  return ly_verb(level);
348 }
349 
351  struct ly_set *set_new = ly_set_new();
352  if (!set_new) {
353  check_libyang_error(nullptr);
354  }
355 
356  set = set_new;
357  deleter = std::make_shared<Deleter>(set_new);
358 }
359 Set::Set(struct ly_set *set, S_Deleter deleter):
360  set(set),
361  deleter(deleter)
362 {};
364 std::vector<S_Data_Node> Set::data() {
365  std::vector<S_Data_Node> s_vector;
366 
367  unsigned int i;
368  for (i = 0; i < set->number; i++){
369  s_vector.push_back(std::make_shared<Data_Node>(set->set.d[i], deleter));
370  }
371 
372  return s_vector;
373 };
374 std::vector<S_Schema_Node> Set::schema() {
375  std::vector<S_Schema_Node> s_vector;
376 
377  unsigned int i;
378  for (i = 0; i < set->number; i++){
379  s_vector.push_back(std::make_shared<Schema_Node>(set->set.s[i], deleter));
380  }
381 
382  return s_vector;
383 };
384 S_Set Set::dup() {
385  ly_set *new_set = ly_set_dup(set);
386  if (!new_set) {
387  return nullptr;
388  }
389 
390  auto deleter = std::make_shared<Deleter>(new_set);
391  return std::make_shared<Set>(new_set, deleter);
392 }
393 int Set::add(S_Data_Node node, int options) {
394  return ly_set_add(set, (void *) node->node, options);
395 }
396 int Set::add(S_Schema_Node node, int options) {
397  return ly_set_add(set, (void *) node->node, options);
398 }
399 int Set::contains(S_Data_Node node) {
400  return ly_set_contains(set, (void *) node->node);
401 }
402 int Set::contains(S_Schema_Node node) {
403  return ly_set_contains(set, (void *) node->node);
404 }
405 int Set::clean() {
406  return ly_set_clean(set);
407 }
408 int Set::rm(S_Data_Node node) {
409  return ly_set_rm(set, (void *) node->node);
410 }
411 int Set::rm(S_Schema_Node node) {
412  return ly_set_rm(set, (void *) node->node);
413 }
414 int Set::rm_index(unsigned int index) {
415  return ly_set_rm_index(set, index);
416 }
417 
418 /* API for wrapping struct ly_ctx from libnetconf2 python bindings */
419 S_Context create_new_Context(struct ly_ctx *new_ctx) {
420  return new_ctx ? std::make_shared<Context>(new_ctx, nullptr) : nullptr;
421 }
422 
423 }
struct lyd_node * lyd_parse_fd(struct ly_ctx *ctx, int fd, LYD_FORMAT format, int options,...)
Read (and validate) data from the given file descriptor.
const struct lys_module * lys_parse_mem(struct ly_ctx *ctx, const char *data, LYS_INFORMAT format)
Load a schema into the specified context.
Common structure representing single YANG data statement describing.
Definition: tree_schema.h:1229
const struct lys_node * lys_getnext(const struct lys_node *last, const struct lys_node *parent, const struct lys_module *module, int options)
Get next schema tree (sibling) node element that can be instantiated in a data tree. Returned node can be from an augment.
LY_LOG_LEVEL set_log_verbosity(LY_LOG_LEVEL level)
Definition: Libyang.cpp:345
S_Module get_module_by_ns(const char *ns, const char *revision=nullptr, int implemented=0)
Definition: Libyang.cpp:93
Error(struct ly_err_item *eitem)
Definition: Libyang.cpp:315
std::vector< const mod_missing_deleter_t * > mod_missing_deleter
Definition: Libyang.hpp:140
uint8_t implemented
Definition: tree_schema.h:693
const char *const * ly_ctx_get_searchdirs(const struct ly_ctx *ctx)
Get the NULL-terminated list of the search paths in libyang context.
Submodule schema node structure that can be included into a YANG module.
Definition: tree_schema.h:737
int ly_log_options(int opts)
Set additional logger options. Default is LY_LOLOG | LY_LOSTORE_LAST.
struct lys_node ** s
Definition: libyang.h:1700
S_Module load_module(const char *name, const char *revision=nullptr)
Definition: Libyang.cpp:86
S_Set find_path(const char *schema_path)
Definition: Libyang.cpp:169
Class implementation for libyang C header xml.h.
int ly_set_rm_index(struct ly_set *set, unsigned int index)
Remove a lyd_node or lys_node object from the set index.
union ly_set_set set
Definition: libyang.h:1719
struct lys_node * data
Definition: tree_schema.h:726
libyang representation of data model trees.
std::vector< S_Module > get_disabled_module_iter()
Definition: Libyang.cpp:112
LY_LOG_LEVEL ly_verb(LY_LOG_LEVEL level)
Set logger verbosity level.
int ly_ctx_set_searchdir(struct ly_ctx *ctx, const char *search_dir)
Add the search path into libyang context.
struct ly_ctx * ly_ctx_new_ylmem(const char *search_dir, const char *data, LYD_FORMAT format, int options)
Create libyang context according to the content of the given yang-library data.
const struct lys_module * ly_ctx_get_module_iter(const struct ly_ctx *ctx, uint32_t *idx)
Iterate over all (enabled) modules in a context.
struct lyd_node * lyd_parse_xml(struct ly_ctx *ctx, struct lyxml_elem **root, int options,...)
Parse (and validate) XML tree.
std::vector< std::pair< mod_missing_cb_t, mod_missing_deleter_t > > mod_missing_cb
Definition: Libyang.hpp:139
const struct lys_module * ly_ctx_get_disabled_module_iter(const struct ly_ctx *ctx, uint32_t *idx)
Iterate over the disabled modules in a context.
S_Data_Node parse_data_xml(S_Xml_Elem elem, int options=0)
Definition: Libyang.cpp:264
class for wrapping ly_ctx.
Definition: Libyang.hpp:43
S_Data_Node parse_data_path(const char *path, LYD_FORMAT format, int options=0)
Definition: Libyang.cpp:252
static void cpp_mod_missing_deleter(void *data, void *user_data)
Definition: Libyang.cpp:307
S_Data_Node parse_data_fd(int fd, LYD_FORMAT format, int options=0)
Definition: Libyang.cpp:203
struct ly_set * ly_ctx_find_path(struct ly_ctx *ctx, const char *path)
Get schema node according to the given schema path (see XPath Addressing).
const struct lys_module * ly_ctx_get_module_by_ns(const struct ly_ctx *ctx, const char *ns, const char *revision, int implemented)
Get pointer to the schema tree of the module of the specified namespace.
S_Module parse_module_path(const char *path, LYS_INFORMAT format)
Definition: Libyang.cpp:240
libyang representation of data trees.
LY_LOG_LEVEL level
Definition: libyang.h:2158
S_Submodule get_submodule2(S_Module main_module, const char *submodule=nullptr)
Definition: Libyang.cpp:155
int clean()
Definition: Libyang.cpp:405
The main libyang public header.
Class implementation for libyang C header tree_schema.h.
const struct lys_module * ly_ctx_get_module(const struct ly_ctx *ctx, const char *name, const char *revision, int implemented)
Get pointer to the schema tree of the module of the specified name.
LYD_FORMAT
Data input/output formats supported by libyang parser and printer functions.
Definition: tree_data.h:40
void add_missing_module_callback(const mod_missing_cb_t &callback, const mod_missing_deleter_t &deleter=mod_missing_deleter_t())
Add a missing include or import module callback.
Definition: Libyang.cpp:277
S_Data_Node parse_data_mem(const char *data, LYD_FORMAT format, int options=0)
Definition: Libyang.cpp:191
struct ly_set * ly_set_dup(const struct ly_set *set)
Duplicate the existing set.
Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects...
Definition: libyang.h:1716
const struct lys_submodule * ly_ctx_get_submodule(const struct ly_ctx *ctx, const char *module, const char *revision, const char *submodule, const char *sub_revision)
Get submodule of a main module.
struct lyd_node * lyd_parse_path(struct ly_ctx *ctx, const char *path, LYD_FORMAT format, int options,...)
Read (and validate) data from the given file path.
std::vector< std::string > get_searchdirs()
Definition: Libyang.cpp:130
int ly_set_rm(struct ly_set *set, void *node)
Remove a lyd_node or lys_node object from the set.
S_Module get_module(const char *name, const char *revision=nullptr, int implemented=0)
Definition: Libyang.cpp:78
Libyang full error structure.
Definition: libyang.h:2157
std::function< mod_missing_cb_return(const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev)> mod_missing_cb_t
Definition: Libyang.hpp:108
int add(S_Data_Node node, int options=0)
Definition: Libyang.cpp:393
std::vector< S_Schema_Node > schema()
Definition: Libyang.cpp:374
std::vector< S_Error > get_ly_errors(S_Context context)
Definition: Libyang.cpp:319
struct ly_err_item * ly_err_first(const struct ly_ctx *ctx)
Get the first (thread, context-specific) generated error structure.
int contains(S_Data_Node node)
Definition: Libyang.cpp:399
LYS_INFORMAT
Schema input formats accepted by libyang parser functions.
Definition: tree_schema.h:195
const struct lys_module * lys_parse_fd(struct ly_ctx *ctx, int fd, LYS_INFORMAT format)
Read a schema from file descriptor into the specified context.
void ly_ctx_set_module_imp_clb(struct ly_ctx *ctx, ly_module_imp_clb clb, void *user_data)
Set missing include or import module callback. It is meant to be used when the models are not locally...
std::function< void(void *)> mod_missing_deleter_t
Definition: Libyang.hpp:109
int ly_set_clean(struct ly_set *set)
Remove all objects from the set, but keep the set container for further use.
int set_log_options(int options)
Definition: Libyang.cpp:340
const char * ns
Definition: tree_schema.h:727
struct ly_err_item * next
Definition: libyang.h:2164
std::vector< S_Schema_Node > data_instantiables(int options)
Definition: Libyang.cpp:178
Context(struct ly_ctx *ctx, S_Deleter deleter)
Definition: Libyang.cpp:35
Main schema node structure representing YANG module.
Definition: tree_schema.h:674
const struct lys_module * lys_parse_path(struct ly_ctx *ctx, const char *path, LYS_INFORMAT format)
Load a schema into the specified context from a file.
int ly_set_contains(const struct ly_set *set, void *node)
Get know if the set contains the specified object.
S_Module get_module_older(S_Module module)
Definition: Libyang.cpp:82
LY_LOG_LEVEL
Verbosity levels of the libyang logger.
Definition: libyang.h:1880
const struct lys_node * ly_ctx_get_node(struct ly_ctx *ctx, const struct lys_node *start, const char *data_path, int output)
Get schema node according to the given data path (JSON format, see XPath Addressing).
Class implementation for libyang C header libyang.h.
struct ly_ctx * ly_ctx_new_ylpath(const char *search_dir, const char *path, LYD_FORMAT format, int options)
Create libyang context according to the content of the given yang-library data.
#define ly_errno
libyang specific (thread-safe) errno (see LY_ERR for the list of possible values and their meaning)...
Definition: libyang.h:2103
S_Module parse_module_mem(const char *data, LYS_INFORMAT format)
Definition: Libyang.cpp:216
std::vector< S_Data_Node > data()
Definition: Libyang.cpp:364
S_Module parse_module_fd(int fd, LYS_INFORMAT format)
Definition: Libyang.cpp:228
std::vector< S_Module > get_module_iter()
Definition: Libyang.cpp:97
const struct lys_module * ly_ctx_get_module_older(const struct ly_ctx *ctx, const struct lys_module *module)
Get pointer to the older schema tree to the specified one in the provided context.
int rm(S_Data_Node node)
Definition: Libyang.cpp:408
Class implementation for libyang C header tree_data.h.
Generic structure for a data node, directly applicable to the data nodes defined as LYS_CONTAINER...
Definition: tree_data.h:186
struct lyd_node ** d
Definition: libyang.h:1701
struct lyd_node * lyd_parse_mem(struct ly_ctx *ctx, const char *data, LYD_FORMAT format, int options,...)
Parse (and validate) data from memory.
int ly_set_add(struct ly_set *set, void *node, int options)
Add a lyd_node or lys_node object into the set.
const char * name
Definition: tree_schema.h:676
S_Set dup()
Definition: Libyang.cpp:384
struct ly_set * ly_set_new(void)
Create and initiate new ly_set structure.
const struct lys_module * ly_ctx_load_module(struct ly_ctx *ctx, const char *name, const char *revision)
Try to find the model in the searchpath of ctx and load it into it. If custom missing module callback...
int set_searchdir(const char *search_dir)
Definition: Libyang.cpp:61
S_Schema_Node get_node(S_Schema_Node start, const char *data_path, int output=0)
Definition: Libyang.cpp:162
S_Data_Node info()
Definition: Libyang.cpp:68
S_Submodule get_submodule(const char *module, const char *revision=nullptr, const char *submodule=nullptr, const char *sub_revision=nullptr)
Definition: Libyang.cpp:148
struct ly_ctx * ctx
Definition: tree_schema.h:675
const struct lys_submodule * ly_ctx_get_submodule2(const struct lys_module *main_module, const char *submodule)
Get submodule of a main module.
S_Context create_new_Context(struct ly_ctx *ctx)
Definition: Libyang.cpp:419
struct ly_ctx * ly_ctx_new(const char *search_dir, int options)
Create libyang context.
int rm_index(unsigned int index)
Definition: Libyang.cpp:414
void ly_ctx_clean(struct ly_ctx *ctx, void(*private_destructor)(const struct lys_node *node, void *priv))
Remove all the modules from the context except the internal modules. Also the addition data in dictio...
libyang context handler.
static const char * cpp_mod_missing_cb(const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev, void *user_data, LYS_INFORMAT *format, void(**free_module_data)(void *model_data, void *user_data))
Definition: Libyang.cpp:285
struct lyd_node * ly_ctx_info(struct ly_ctx *ctx)
Get data of an internal ietf-yang-library module.