libyang  1.0.101
YANG data modeling language library
Tree_Schema.cpp
Go to the documentation of this file.
1 
15 #include <iostream>
16 #include <memory>
17 #include <stdexcept>
18 #include <vector>
19 
20 #include "Internal.hpp"
21 #include "Libyang.hpp"
22 #include "Tree_Schema.hpp"
23 
24 extern "C" {
25 #include "libyang.h"
26 #include "tree_schema.h"
27 }
28 
29 namespace libyang {
30 
31 Module::Module(struct lys_module *module, S_Deleter deleter):
32  module(module),
33  deleter(deleter)
34 {};
36 S_Revision Module::rev() LY_NEW(module, rev, Revision);
37 std::vector<S_Deviation> Module::deviation() LY_NEW_LIST(module, deviation, deviation_size, Deviation);
38 Submodule::Submodule(struct lys_submodule *submodule, S_Deleter deleter):
39  submodule(submodule),
40  deleter(deleter)
41 {};
42 std::vector<S_Schema_Node> Module::data_instantiables(int options) {
43  std::vector<S_Schema_Node> s_vector;
44  struct lys_node *iter = NULL;
45 
46  while ((iter = (struct lys_node *)lys_getnext(iter, NULL, module, options))) {
47  s_vector.push_back(std::make_shared<Schema_Node>(iter, deleter));
48  }
49 
50  return s_vector;
51 }
52 std::string Module::print_mem(LYS_OUTFORMAT format, int options) {
53  char *strp = nullptr;
54  int rc = 0;
55 
56  rc = lys_print_mem(&strp, module, format, NULL, 0, options);
57  if (rc) {
58  check_libyang_error(module->ctx);
59  return nullptr;
60  }
61 
62  std::string s_strp = strp;
63  free(strp);
64  return s_strp;
65 }
66 std::string Module::print_mem(LYS_OUTFORMAT format, const char *target, int options) {
67  char *strp = nullptr;
68  int rc = 0;
69 
70  rc = lys_print_mem(&strp, module, format, target, 0, options);
71  if (rc) {
72  check_libyang_error(module->ctx);
73  return nullptr;
74  }
75 
76  std::string s_strp = strp;
77  free(strp);
78  return s_strp;
79 }
80 int Module::feature_enable(const char *feature) {
81  return lys_features_enable(module, feature);
82 }
83 int Module::feature_disable(const char *feature) {
84  return lys_features_disable(module, feature);
85 }
86 int Module::feature_state(const char *feature) {
87  return lys_features_state(module, feature);
88 }
90 S_Revision Submodule::rev() LY_NEW(submodule, rev, Revision);
91 std::vector<S_Deviation> Submodule::deviation() LY_NEW_LIST(submodule, deviation, deviation_size, Deviation);
92 
93 Type_Info_Binary::Type_Info_Binary(struct lys_type_info_binary *info_binary, S_Deleter deleter):
94  info_binary(info_binary),
95  deleter(deleter)
96 {};
98 S_Restr Type_Info_Binary::length() {return info_binary->length ? std::make_shared<Restr>(info_binary->length, deleter) : nullptr;};
99 
100 Type_Bit::Type_Bit(struct lys_type_bit *info_bit, S_Deleter deleter):
101  info_bit(info_bit),
102  deleter(deleter)
103 {};
105 std::vector<S_Ext_Instance> Type_Bit::ext() LY_NEW_P_LIST(info_bit, ext, ext_size, Ext_Instance);
106 std::vector<S_Iffeature> Type_Bit::iffeature() LY_NEW_LIST(info_bit, iffeature, iffeature_size, Iffeature);
107 
108 Type_Info_Bits::Type_Info_Bits(struct lys_type_info_bits *info_bits, S_Deleter deleter):
109  info_bits(info_bits),
110  deleter(deleter)
111 {};
113 std::vector<S_Type_Bit> Type_Info_Bits::bit() LY_NEW_LIST(info_bits, bit, count, Type_Bit);
114 
115 Type_Info_Dec64::Type_Info_Dec64(struct lys_type_info_dec64 *info_dec64, S_Deleter deleter):
116  info_dec64(info_dec64),
117  deleter(deleter)
118 {};
120 S_Restr Type_Info_Dec64::range() {return info_dec64->range ? std::make_shared<Restr>(info_dec64->range, deleter) : nullptr;};
121 
122 Type_Enum::Type_Enum(struct lys_type_enum *info_enum, S_Deleter deleter):
123  info_enum(info_enum),
124  deleter(deleter)
125 {};
127 std::vector<S_Ext_Instance> Type_Enum::ext() LY_NEW_P_LIST(info_enum, ext, ext_size, Ext_Instance);
128 std::vector<S_Iffeature> Type_Enum::iffeature() LY_NEW_LIST(info_enum, iffeature, iffeature_size, Iffeature);
129 
130 Type_Info_Enums::Type_Info_Enums(struct lys_type_info_enums *info_enums, S_Deleter deleter):
131  info_enums(info_enums),
132  deleter(deleter)
133 {};
135 std::vector<S_Type_Enum> Type_Info_Enums::enm() LY_NEW_LIST(info_enums, enm, count, Type_Enum);
136 
137 Type_Info_Ident::Type_Info_Ident(struct lys_type_info_ident *info_ident, S_Deleter deleter):
138  info_ident(info_ident),
139  deleter(deleter)
140 {};
142 std::vector<S_Ident> Type_Info_Ident::ref() LY_NEW_P_LIST(info_ident, ref, count, Ident);
143 
144 Type_Info_Inst::Type_Info_Inst(struct lys_type_info_inst *info_inst, S_Deleter deleter):
145  info_inst(info_inst),
146  deleter(deleter)
147 {};
149 
150 Type_Info_Num::Type_Info_Num(struct lys_type_info_num *info_num, S_Deleter deleter):
151  info_num(info_num),
152  deleter(deleter)
153 {};
155 S_Restr Type_Info_Num::range() {return info_num->range ? std::make_shared<Restr>(info_num->range, deleter) : nullptr;};
156 
157 Type_Info_Lref::Type_Info_Lref(lys_type_info_lref *info_lref, S_Deleter deleter):
158  info_lref(info_lref),
159  deleter(deleter)
160 {};
162 S_Schema_Node_Leaf Type_Info_Lref::target() {return info_lref->target ? std::make_shared<Schema_Node_Leaf>((struct lys_node *)info_lref->target, deleter) : nullptr;};
163 
164 Type_Info_Str::Type_Info_Str(lys_type_info_str *info_str, S_Deleter deleter):
165  info_str(info_str),
166  deleter(deleter)
167 {};
169 S_Restr Type_Info_Str::length() {return info_str->length ? std::make_shared<Restr>(info_str->length, deleter) : nullptr;};
170 S_Restr Type_Info_Str::patterns() {return info_str->patterns ? std::make_shared<Restr>(info_str->patterns, deleter) : nullptr;};
171 
173  info_union(info_union),
174  deleter(deleter)
175 {};
177 std::vector<S_Type> Type_Info_Union::types() LY_NEW_LIST(info_union, types, count, Type);
178 
179 Type_Info::Type_Info(union lys_type_info info, LY_DATA_TYPE *type, uint8_t flags, S_Deleter deleter):
180  info(info),
181  type(*type),
182  flags(flags),
183  deleter(deleter)
184 {};
186 S_Type_Info_Binary Type_Info::binary() {return LY_TYPE_BINARY == type ? std::make_shared<Type_Info_Binary>(&info.binary, deleter) : nullptr;};
187 S_Type_Info_Bits Type_Info::bits() {return LY_TYPE_BITS == type ? std::make_shared<Type_Info_Bits>(&info.bits, deleter) : nullptr;};
188 S_Type_Info_Dec64 Type_Info::dec64() {return LY_TYPE_DEC64 == type ? std::make_shared<Type_Info_Dec64>(&info.dec64, deleter) : nullptr;};
189 S_Type_Info_Enums Type_Info::enums() {return LY_TYPE_ENUM == type ? std::make_shared<Type_Info_Enums>(&info.enums, deleter) : nullptr;};
190 S_Type_Info_Ident Type_Info::ident() {return LY_TYPE_IDENT == type ? std::make_shared<Type_Info_Ident>(&info.ident, deleter) : nullptr;};
191 S_Type_Info_Inst Type_Info::inst() {return LY_TYPE_INST == type ? std::make_shared<Type_Info_Inst>(&info.inst, deleter) : nullptr;};
192 S_Type_Info_Num Type_Info::num() {
193  if (type >= LY_TYPE_INT8 && type <= LY_TYPE_UINT64) {
194  return std::make_shared<Type_Info_Num>(&info.num, deleter);
195  } else {
196  return nullptr;
197  }
198 };
199 S_Type_Info_Lref Type_Info::lref() {return LY_TYPE_LEAFREF == type ? std::make_shared<Type_Info_Lref>(&info.lref, deleter) : nullptr;};
200 S_Type_Info_Str Type_Info::str() {return LY_TYPE_STRING == type ? std::make_shared<Type_Info_Str>(&info.str, deleter) : nullptr;};
201 S_Type_Info_Union Type_Info::uni() {return LY_TYPE_UNION == type ? std::make_shared<Type_Info_Union>(&info.uni, deleter) : nullptr;};
202 
203 Type::Type(struct lys_type *type, S_Deleter deleter):
204  type(type),
205  deleter(deleter)
206 {};
208 std::vector<S_Ext_Instance> Type::ext() LY_NEW_P_LIST(type, ext, ext_size, Ext_Instance);
209 S_Tpdf Type::der() {return type->der ? std::make_shared<Tpdf>(type->der, deleter) : nullptr;};
210 S_Tpdf Type::parent() {return type->parent ? std::make_shared<Tpdf>(type->parent, deleter) : nullptr;};
211 S_Type_Info Type::info() {return std::make_shared<Type_Info>(type->info, &type->base, type->value_flags, deleter);};
212 
213 Iffeature::Iffeature(struct lys_iffeature *iffeature, S_Deleter deleter):
215  deleter(deleter)
216 {};
218 std::vector<S_Ext_Instance> Iffeature::ext() LY_NEW_P_LIST(iffeature, ext, ext_size, Ext_Instance);
219 int Iffeature::value() {
221 }
222 
223 Ext_Instance::Ext_Instance(lys_ext_instance *ext_instance, S_Deleter deleter):
224  ext_instance(ext_instance),
225  deleter(deleter)
226 {};
228 std::vector<S_Ext_Instance> Ext_Instance::ext() LY_NEW_P_LIST(ext_instance, ext, ext_size, Ext_Instance);
229 
230 Revision::Revision(lys_revision *revision, S_Deleter deleter):
231  revision(revision),
232  deleter(deleter)
233 {};
235 
236 Schema_Node::Schema_Node(struct lys_node *node, S_Deleter deleter):
237  node(node),
238  deleter(deleter)
239 {};
241 std::vector<S_Ext_Instance> Schema_Node::ext() LY_NEW_P_LIST(node, ext, ext_size, Ext_Instance);
242 S_Module Schema_Node::module() LY_NEW(node, module, Module);
243 S_Schema_Node Schema_Node::parent() LY_NEW(node, parent, Schema_Node);
244 S_Schema_Node Schema_Node::child() LY_NEW(node, child, Schema_Node);
245 S_Schema_Node Schema_Node::next() LY_NEW(node, next, Schema_Node);
246 S_Schema_Node Schema_Node::prev() LY_NEW(node, prev, Schema_Node);
247 std::string Schema_Node::path(int options) {
248  char *path = nullptr;
249 
250  path = lys_path(node, options);
251  if (!path) {
252  return nullptr;
253  }
254 
255  std::string s_path = path;
256  free(path);
257  return s_path;
258 }
259 std::vector<S_Schema_Node> Schema_Node::child_instantiables(int options) {
260  std::vector<S_Schema_Node> s_vector;
261  struct lys_node *iter = NULL;
262 
263  while ((iter = (struct lys_node *)lys_getnext(iter, node, node->module, options))) {
264  s_vector.push_back(std::make_shared<Schema_Node>(iter, deleter));
265  }
266 
267  return s_vector;
268 }
269 S_Set Schema_Node::find_path(const char *path) {
270  struct ly_set *set = lys_find_path(node->module, node, path);
271  if (!set) {
272  check_libyang_error(node->module->ctx);
273  return nullptr;
274  }
275 
276  S_Deleter new_deleter = std::make_shared<Deleter>(set, deleter);
277  return std::make_shared<Set>(set, new_deleter);
278 }
279 
280 S_Set Schema_Node::xpath_atomize(enum lyxp_node_type ctx_node_type, const char *expr, int options) {
281  struct ly_set *set = lys_xpath_atomize(node, ctx_node_type, expr, options);
282  if (!set) {
283  check_libyang_error(node->module->ctx);
284  return nullptr;
285  }
286 
287  return std::make_shared<Set>(set, deleter);
288 }
289 S_Set Schema_Node::xpath_atomize(int options) {
290  struct ly_set *set = lys_node_xpath_atomize(node, options);
291  if (!set) {
292  check_libyang_error(node->module->ctx);
293  return nullptr;
294  }
295 
296  return std::make_shared<Set>(set, deleter);
297 }
298 std::vector<S_Schema_Node> Schema_Node::tree_for() {
299  std::vector<S_Schema_Node> s_vector;
300 
301  struct lys_node *elem = nullptr;
302  LY_TREE_FOR(node, elem) {
303  s_vector.push_back(std::make_shared<Schema_Node>(elem, deleter));
304  }
305 
306  return s_vector;
307 }
308 std::vector<S_Schema_Node> Schema_Node::tree_dfs() {
309  std::vector<S_Schema_Node> s_vector;
310 
311  struct lys_node *elem = nullptr, *next = nullptr;
312  LY_TREE_DFS_BEGIN(node, next, elem) {
313  s_vector.push_back(std::make_shared<Schema_Node>(elem, deleter));
314  LY_TREE_DFS_END(node, next, elem)
315  }
316 
317  return s_vector;
318 }
319 
321 S_When Schema_Node_Container::when() LY_NEW_CASTED(lys_node_container, node, when, When);
322 S_Restr Schema_Node_Container::must() {
323  struct lys_node_container *node_container = (struct lys_node_container *)node;
324  return node_container->must ? std::make_shared<Restr>(node_container->must, deleter) : nullptr;
325 };
327  struct lys_node_container *node_container = (struct lys_node_container *)node;
328  return node_container->tpdf ? std::make_shared<Tpdf>(node_container->tpdf, deleter) : nullptr;
329 };
330 
332 S_When Schema_Node_Choice::when() LY_NEW_CASTED(lys_node_choice, node, when, When);
333 S_Schema_Node Schema_Node_Choice::dflt() {
334  struct lys_node_choice *node_choice = (struct lys_node_choice *)node;
335  return node_choice->dflt ? std::make_shared<Schema_Node>(node_choice->dflt, deleter) : nullptr;
336 };
337 
339 S_Set Schema_Node_Leaf::backlinks() LY_NEW_CASTED(lys_node_leaf, node, backlinks, Set);
340 S_When Schema_Node_Leaf::when() LY_NEW_CASTED(lys_node_leaf, node, when, When);
341 S_Type Schema_Node_Leaf::type() {return std::make_shared<Type>(&((struct lys_node_leaf *)node)->type, deleter);}
342 S_Schema_Node_List Schema_Node_Leaf::is_key() {
343  uint8_t pos;
344 
345  auto list = lys_is_key((struct lys_node_leaf *)node, &pos);
346  return list ? std::make_shared<Schema_Node_List>((struct lys_node *) list, deleter) : nullptr;
347 }
348 
350 S_Set Schema_Node_Leaflist::backlinks() LY_NEW_CASTED(lys_node_leaflist, node, backlinks, Set);
351 S_When Schema_Node_Leaflist::when() LY_NEW_CASTED(lys_node_leaflist, node, when, When);
352 std::vector<std::string> Schema_Node_Leaflist::dflt() {
353  struct lys_node_leaflist *node_leaflist = (struct lys_node_leaflist *)node;
354  LY_NEW_STRING_LIST(node_leaflist, dflt, dflt_size);
355 }
356 std::vector<S_Restr> Schema_Node_Leaflist::must() LY_NEW_LIST_CASTED(lys_node_leaflist, node, must, must_size, Restr);
357 S_Type Schema_Node_Leaflist::type() {return std::make_shared<Type>(&((struct lys_node_leaflist *)node)->type, deleter);}
358 
360 S_When Schema_Node_List::when() LY_NEW_CASTED(lys_node_list, node, when, When);
361 std::vector<S_Restr> Schema_Node_List::must() LY_NEW_LIST_CASTED(lys_node_list, node, must, must_size, Restr);
362 std::vector<S_Tpdf> Schema_Node_List::tpdf() LY_NEW_LIST_CASTED(lys_node_list, node, tpdf, tpdf_size, Tpdf);
363 std::vector<S_Schema_Node_Leaf> Schema_Node_List::keys() {
364  auto list = (struct lys_node_list *) node;
365 
366  std::vector<S_Schema_Node_Leaf> s_vector;
367 
368  for (uint8_t i = 0; i < list->keys_size; i++) {
369  s_vector.push_back(std::make_shared<Schema_Node_Leaf>((struct lys_node *) list->keys[i], deleter));
370  }
371 
372  return s_vector;
373 }
374 std::vector<S_Unique> Schema_Node_List::unique() LY_NEW_LIST_CASTED(lys_node_list, node, unique, unique_size, Unique);
375 
377 S_When Schema_Node_Anydata::when() LY_NEW_CASTED(lys_node_anydata, node, when, When);
378 std::vector<S_Restr> Schema_Node_Anydata::must() LY_NEW_LIST_CASTED(lys_node_anydata, node, must, must_size, Restr);
379 
381 S_When Schema_Node_Uses::when() LY_NEW_CASTED(lys_node_uses, node, when, When);
382 std::vector<S_Refine> Schema_Node_Uses::refine() LY_NEW_LIST_CASTED(lys_node_uses, node, refine, refine_size, Refine);
383 std::vector<S_Schema_Node_Augment> Schema_Node_Uses::augment() {
384  auto uses = (struct lys_node_uses *) node;
385 
386  std::vector<S_Schema_Node_Augment> s_vector;
387 
388  for (uint8_t i = 0; i < uses->augment_size; i++) {
389  s_vector.push_back(std::make_shared<Schema_Node_Augment>((struct lys_node *) &uses->augment[i], deleter));
390  }
391 
392  return s_vector;
393 }
394 S_Schema_Node_Grp Schema_Node_Uses::grp() {
395  auto uses = (struct lys_node_uses *) node;
396  return uses->grp ? std::make_shared<Schema_Node_Grp>(node, deleter) : nullptr;
397 };
398 
400 std::vector<S_Tpdf> Schema_Node_Grp::tpdf() LY_NEW_LIST_CASTED(lys_node_grp, node, tpdf, tpdf_size, Tpdf);
401 
403 S_When Schema_Node_Case::when() LY_NEW_CASTED(lys_node_case, node, when, When);
404 
406 std::vector<S_Tpdf> Schema_Node_Inout::tpdf() LY_NEW_LIST_CASTED(lys_node_inout, node, tpdf, tpdf_size, Tpdf);
407 std::vector<S_Restr> Schema_Node_Inout::must() LY_NEW_LIST_CASTED(lys_node_inout, node, must, must_size, Restr);
408 
410 std::vector<S_Tpdf> Schema_Node_Notif::tpdf() LY_NEW_LIST_CASTED(lys_node_notif, node, tpdf, tpdf_size, Tpdf);
411 std::vector<S_Restr> Schema_Node_Notif::must() LY_NEW_LIST_CASTED(lys_node_notif, node, must, must_size, Restr);
412 
414 std::vector<S_Tpdf> Schema_Node_Rpc_Action::tpdf() LY_NEW_LIST_CASTED(lys_node_rpc_action, node, tpdf, tpdf_size, Tpdf);
415 
417 S_When Schema_Node_Augment::when() LY_NEW_CASTED(lys_node_augment, node, when, When);
418 
419 When::When(struct lys_when *when, S_Deleter deleter):
420  when(when),
421  deleter(deleter)
422 {};
424 std::vector<S_Ext_Instance> When::ext() LY_NEW_P_LIST(when, ext, ext_size, Ext_Instance);
425 
426 Substmt::Substmt(struct lyext_substmt *substmt, S_Deleter deleter):
427  substmt(substmt),
428  deleter(deleter)
429 {};
431 
432 Ext::Ext(struct lys_ext *ext, S_Deleter deleter):
433  ext(ext),
434  deleter(deleter)
435 {};
437 std::vector<S_Ext_Instance> Ext::ext_instance() LY_NEW_P_LIST(ext, ext, ext_size, Ext_Instance);
438 S_Module Ext::module() LY_NEW(ext, module, Module);
439 
440 Refine_Mod_List::Refine_Mod_List(struct lys_refine_mod_list *list, S_Deleter deleter):
441  list(list),
442  deleter(deleter)
443 {};
445 
446 Refine_Mod::Refine_Mod(union lys_refine_mod mod, uint16_t target_type, S_Deleter deleter):
447  mod(mod),
448  target_type(target_type),
449  deleter(deleter)
450 {};
452 //TODO check which type's to accept
453 S_Refine_Mod_List Refine_Mod::list() {return target_type != LYS_CONTAINER ? std::make_shared<Refine_Mod_List>(&mod.list, deleter) : nullptr;};
454 
455 Refine::Refine(struct lys_refine *refine, S_Deleter deleter):
456  refine(refine),
457  deleter(deleter)
458 {};
460 std::vector<S_Ext_Instance> Refine::ext() LY_NEW_P_LIST(refine, ext, ext_size, Ext_Instance);
461 S_Module Refine::module() LY_NEW(refine, module, Module);
462 std::vector<S_Restr> Refine::must() LY_NEW_LIST(refine, must, must_size, Restr);
463 S_Refine_Mod Refine::mod() {return std::make_shared<Refine_Mod>(refine->mod, refine->target_type, deleter);};
464 
465 Deviate::Deviate(struct lys_deviate *deviate, S_Deleter deleter):
466  deviate(deviate),
467  deleter(deleter)
468 {};
470 std::vector<S_Ext_Instance> Deviate::ext() LY_NEW_P_LIST(deviate, ext, ext_size, Ext_Instance);
471 S_Restr Deviate::must() {return deviate->must ? std::make_shared<Restr>(deviate->must, deleter) : nullptr;};
472 S_Unique Deviate::unique() {return deviate->unique ? std::make_shared<Unique>(deviate->unique, deleter) : nullptr;};
473 S_Type Deviate::type() {return deviate->type ? std::make_shared<Type>(deviate->type, deleter) : nullptr;}
474 
475 Deviation::Deviation(struct lys_deviation *deviation, S_Deleter deleter):
476  deviation(deviation),
477  deleter(deleter)
478 {};
480 S_Schema_Node Deviation::orig_node() LY_NEW(deviation, orig_node, Schema_Node);
481 std::vector<S_Deviate> Deviation::deviate() LY_NEW_LIST(deviation, deviate, deviate_size, Deviate);
482 std::vector<S_Ext_Instance> Deviation::ext() LY_NEW_P_LIST(deviation, ext, ext_size, Ext_Instance);
483 
484 Import::Import(struct lys_import *import, S_Deleter deleter):
485  import(import),
486  deleter(deleter)
487 {};
489 
490 Include::Include(struct lys_include *include, S_Deleter deleter):
491  include(include),
492  deleter(deleter)
493 {}
495 
496 Tpdf::Tpdf(struct lys_tpdf *tpdf, S_Deleter deleter):
497  tpdf(tpdf),
498  deleter(deleter)
499 {}
501 S_Type Tpdf::type() {return std::make_shared<Type>(&tpdf->type, deleter);}
502 
503 Unique::Unique(struct lys_unique *unique, S_Deleter deleter):
504  unique(unique),
505  deleter(deleter)
506 {};
508 
509 Feature::Feature(struct lys_feature *feature, S_Deleter deleter):
510  feature(feature),
511  deleter(deleter)
512 {};
514 
515 Restr::Restr(struct lys_restr *restr, S_Deleter deleter):
516  restr(restr),
517  deleter(deleter)
518 {};
520 
521 Ident::Ident(struct lys_ident *ident, S_Deleter deleter):
522  ident(ident),
523  deleter(deleter)
524 {};
526 std::vector<S_Ident> Ident::base() LY_NEW_P_LIST(ident, base, base_size, Ident);
527 
528 }
Type_Enum(struct lys_type_enum *info_enum, S_Deleter deleter)
struct lys_module * module
Definition: tree_schema.h:1255
Common structure representing single YANG data statement describing.
Definition: tree_schema.h:1239
Schema leaf node structure.
Definition: tree_schema.h:1375
S_Type_Info_Enums enums()
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....
Ident(struct lys_ident *ident, S_Deleter deleter)
Tpdf(struct lys_tpdf *tpdf, S_Deleter deleter)
Schema grouping node structure.
Definition: tree_schema.h:1638
std::vector< S_Type_Enum > enm()
int lys_iffeature_value(const struct lys_iffeature *iff)
Learn how the if-feature statement currently evaluates.
struct lys_type_info_bits bits
Definition: tree_schema.h:974
S_Schema_Node_Leaf target()
struct lys_type_info_inst inst
Definition: tree_schema.h:978
Submodule schema node structure that can be included into a YANG module.
Definition: tree_schema.h:744
Unique(struct lys_unique *unique, S_Deleter deleter)
Schema choice node structure.
Definition: tree_schema.h:1333
std::vector< S_Ext_Instance > ext()
struct lys_type_info_num num
Definition: tree_schema.h:979
struct lys_unique * unique
Definition: tree_schema.h:1522
S_Revision rev()
Definition: Tree_Schema.cpp:36
Module(struct lys_module *module, S_Deleter deleter)
Definition: Tree_Schema.cpp:31
struct lys_node * dflt
Definition: tree_schema.h:1361
std::vector< S_Schema_Node > tree_for()
struct lys_restr * patterns
Definition: tree_schema.h:945
struct lys_refine_mod_list list
Definition: tree_schema.h:1900
std::vector< S_Ext_Instance > ext()
uint8_t iffeature_size
Definition: tree_schema.h:1245
Type_Bit(struct lys_type_bit *info_bit, S_Deleter deleter)
S_Revision rev()
Definition: Tree_Schema.cpp:90
std::vector< S_Tpdf > tpdf()
YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2
Definition: tree_schema.h:1907
std::vector< S_Schema_Node > tree_dfs()
YANG import structure used to reference other schemas (modules).
Definition: tree_schema.h:1991
std::vector< S_Schema_Node > data_instantiables(int options)
Definition: Tree_Schema.cpp:42
S_Type_Info_Inst inst()
union ly_set_set set
Definition: libyang.h:1723
Container for list modifications in lys_refine_mod.
Definition: tree_schema.h:1890
Container for information about string types (LY_TYPE_STRING), used in lys_type_info.
Definition: tree_schema.h:942
S_Schema_Node_List is_key()
const char ** dflt
Definition: tree_schema.h:1470
libyang representation of data model trees.
Deviate(struct lys_deviate *deviate, S_Deleter deleter)
classes for wrapping lys_submodule.
S_Type_Info_Lref lref()
std::vector< S_Ext_Instance > ext_instance()
struct ly_set * lys_find_path(const struct lys_module *cur_module, const struct lys_node *cur_node, const char *path)
Search for schema nodes matching the provided path.
YANG typedef structure providing information from the schema.
Definition: tree_schema.h:2027
struct lys_restr * length
Definition: tree_schema.h:828
std::vector< S_Tpdf > tpdf()
lyxp_node_type
Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions.
Definition: tree_schema.h:2329
struct lys_type * type
Definition: tree_schema.h:1965
Single enumeration value specification for lys_type_info_enums.
Definition: tree_schema.h:875
Union for holding type-specific information in lys_type.
Definition: tree_schema.h:972
int lys_features_disable(const struct lys_module *module, const char *feature)
Disable specified feature in the module.
S_Schema_Node_Grp grp()
S_Type_Info_Union uni()
struct lys_node * child
Definition: tree_schema.h:1259
Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info.
Definition: tree_schema.h:929
struct lys_tpdf * tpdf
Definition: tree_schema.h:1320
Compiled if-feature expression structure.
Definition: tree_schema.h:1085
union lys_type_info info
Definition: tree_schema.h:997
Schema leaf-list node structure.
Definition: tree_schema.h:1428
YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's su...
Definition: tree_schema.h:1855
LYS_OUTFORMAT
Schema output formats accepted by libyang printer functions.
Definition: tree_schema.h:204
Type_Info_Num(struct lys_type_info_num *info_num, S_Deleter deleter)
Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info.
Definition: tree_schema.h:894
Container for information about integer types, used in lys_type_info.
Definition: tree_schema.h:921
Ext_Instance(lys_ext_instance *ext_instance, S_Deleter deleter)
The main libyang public header.
std::vector< S_Tpdf > tpdf()
Restr(struct lys_restr *restr, S_Deleter deleter)
Class implementation for libyang C header tree_schema.h.
S_Type_Info_Dec64 dec64()
Union to hold target modification in lys_refine.
Definition: tree_schema.h:1898
Schema anydata (and anyxml) node structure.
Definition: tree_schema.h:1543
Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info.
Definition: tree_schema.h:862
int lys_features_enable(const struct lys_module *module, const char *feature)
Enable specified feature in the module.
std::vector< S_Restr > must()
Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects....
Definition: libyang.h:1720
const char * ref
Definition: tree_schema.h:1242
std::vector< S_Ext_Instance > ext()
struct lys_type_info_lref lref
Definition: tree_schema.h:980
S_Type_Info_Num num()
Type_Info_Union(struct lys_type_info_union *info_union, S_Deleter deleter)
Ext(struct lys_ext *ext, S_Deleter deleter)
std::vector< S_Ext_Instance > ext()
Deviation(struct lys_deviation *deviation, S_Deleter deleter)
int feature_enable(const char *feature)
Definition: Tree_Schema.cpp:80
S_Unique unique()
struct lys_iffeature * iffeature
Definition: tree_schema.h:1254
virtual S_Schema_Node next()
Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info.
Definition: tree_schema.h:902
YANG when restriction, see RFC 6020 sec. 7.19.5
Definition: tree_schema.h:2098
#define LY_TREE_DFS_BEGIN(START, NEXT, ELEM)
Macro to iterate via all elements in a tree. This is the opening part to the LY_TREE_DFS_END - they a...
Definition: tree_schema.h:98
Type_Info_Lref(struct lys_type_info_lref *info_lref, S_Deleter deleter)
Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info.
Definition: tree_schema.h:854
S_Type_Info_Binary binary()
Schema case node structure.
Definition: tree_schema.h:1677
int lys_features_state(const struct lys_module *module, const char *feature)
Get the current status of the specified feature in the module.
#define LY_TREE_DFS_END(START, NEXT, ELEM)
Definition: tree_schema.h:130
Schema list node structure.
Definition: tree_schema.h:1484
std::vector< S_Ext_Instance > ext()
Type(struct lys_type *type, S_Deleter deleter)
std::vector< S_Ident > base()
S_Set find_path(const char *path)
Iffeature(struct lys_iffeature *iffeature, S_Deleter deleter)
Refine_Mod(union lys_refine_mod mod, uint16_t target_type, S_Deleter deleter)
Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info.
Definition: tree_schema.h:910
Main schema node structure representing YANG module.
Definition: tree_schema.h:681
#define LY_TREE_FOR(START, ELEM)
Macro to iterate via all sibling elements without affecting the list itself.
Definition: tree_schema.h:48
std::vector< S_Type > types()
S_Refine_Mod_List list()
int lys_print_mem(char **strp, const struct lys_module *module, LYS_OUTFORMAT format, const char *target_node, int line_length, int options)
Print schema tree in the specified format into a memory block. It is up to caller to free the returne...
S_Set xpath_atomize(enum lyxp_node_type ctx_node_type, const char *expr, int options)
std::vector< S_Ident > ref()
S_Type_Info_Ident ident()
uint8_t unique_size
Definition: tree_schema.h:1496
Class implementation for libyang C header libyang.h.
Refine(struct lys_refine *refine, S_Deleter deleter)
RPC input and output node structure.
Definition: tree_schema.h:1722
LY_DATA_TYPE _PACKED base
Definition: tree_schema.h:989
LY_DATA_TYPE
YANG built-in types.
Definition: tree_schema.h:799
S_Schema_Node orig_node()
uint8_t ext_size
Definition: tree_schema.h:1244
struct lys_node * next
Definition: tree_schema.h:1263
struct lys_node_leaf * target
Definition: tree_schema.h:932
struct lys_type_info_dec64 dec64
Definition: tree_schema.h:975
struct lys_type_info_binary binary
Definition: tree_schema.h:973
struct lys_type type
Definition: tree_schema.h:1465
struct ly_set * lys_node_xpath_atomize(const struct lys_node *node, int options)
Call lys_xpath_atomize() on all the when and must expressions of the node. This node must be a descen...
std::string print_mem(LYS_OUTFORMAT format, int options)
Definition: Tree_Schema.cpp:52
uint16_t flags
Definition: tree_schema.h:1243
YANG type structure providing information from the schema.
Definition: tree_schema.h:988
char * lys_path(const struct lys_node *node, int options)
Build schema path (usable as path, see XPath Addressing) of the schema node.
std::vector< S_Ext_Instance > ext()
S_Tpdf parent()
struct lys_when * when
Definition: tree_schema.h:1318
YANG list's unique statement structure, see RFC 6020 sec. 7.8.3
Definition: tree_schema.h:2052
S_Type_Info_Bits bits()
struct lys_refine * refine
Definition: tree_schema.h:1622
Structure to hold information about identity, see RFC 6020 sec. 7.16
Definition: tree_schema.h:2112
struct lys_node * prev
Definition: tree_schema.h:1264
Schema_Node(lys_node *node, S_Deleter deleter)
std::vector< S_Schema_Node > child_instantiables(int options)
Description of the extension instance substatement.
Definition: tree_schema.h:450
S_Type_Info_Str str()
YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2
Definition: tree_schema.h:1948
struct lys_restr * range
Definition: tree_schema.h:863
std::vector< S_Ext_Instance > ext()
struct lys_type_info_enums enums
Definition: tree_schema.h:976
Schema uses node structure.
Definition: tree_schema.h:1591
int feature_state(const char *feature)
Definition: Tree_Schema.cpp:86
struct lys_type_info_union uni
Definition: tree_schema.h:982
Schema notification node structure.
Definition: tree_schema.h:1760
std::vector< S_Ext_Instance > ext()
union lys_refine_mod mod
Definition: tree_schema.h:1931
std::vector< S_Unique > unique()
YANG validity restriction (must, length, etc.) structure providing information from the schema.
Definition: tree_schema.h:2082
class for wrapping ly_set.
Definition: Libyang.hpp:186
const struct lys_node_list * lys_is_key(const struct lys_node_leaf *node, uint8_t *index)
Check if the schema leaf node is used as a key for a list.
std::vector< S_Ext_Instance > ext()
Schema rpc/action node structure.
Definition: tree_schema.h:1807
std::string path(int options=0)
struct lys_restr * must
Definition: tree_schema.h:1319
Generic extension instance structure.
Definition: tree_schema.h:479
Container for information about union types (LY_TYPE_UNION), used in lys_type_info.
Definition: tree_schema.h:962
struct lys_tpdf * parent
Definition: tree_schema.h:995
YANG extension definition.
Definition: tree_schema.h:459
struct ly_ctx * ctx
Definition: tree_schema.h:682
uint8_t value_flags
Definition: tree_schema.h:990
YANG revision statement for (sub)modules.
Definition: tree_schema.h:2016
struct lys_type_info_str str
Definition: tree_schema.h:981
YANG include structure used to reference submodules.
Definition: tree_schema.h:2004
YANG feature definition structure.
Definition: tree_schema.h:2061
Feature(struct lys_feature *feature, S_Deleter)
Type_Info_Str(struct lys_type_info_str *info_str, S_Deleter deleter)
std::vector< S_Tpdf > tpdf()
Include(struct lys_include *include, S_Deleter deleter)
int feature_disable(const char *feature)
Definition: Tree_Schema.cpp:83
std::vector< S_Type_Bit > bit()
Single bit value specification for lys_type_info_bits.
Definition: tree_schema.h:835
uint16_t target_type
Definition: tree_schema.h:1916
classes for wrapping lys_module.
Definition: Tree_Schema.hpp:44
S_Type_Info info()
struct lys_type_info_ident ident
Definition: tree_schema.h:977
struct lys_ext_instance ** ext
Definition: tree_schema.h:1253
Schema container node structure.
Definition: tree_schema.h:1285
struct lys_node * parent
Definition: tree_schema.h:1258
YANG deviation statement structure, see RFC 6020 sec. 7.18.3
Definition: tree_schema.h:1975
struct ly_set * lys_xpath_atomize(const struct lys_node *ctx_node, enum lyxp_node_type ctx_node_type, const char *expr, int options)
Get all the partial XPath nodes (atoms) that are required for expr to be evaluated.