libyang  1.0.253
YANG data modeling language library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
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 Submodule::Submodule(S_Module module):
43  submodule((lys_submodule*)module->module),
44  deleter(module->deleter)
45 {
46  if (module->type() != 1) {
47  throw std::invalid_argument("Attempted to cast a YANG module into a YANG submodule");
48  }
49 }
50 std::vector<S_Schema_Node> Module::data_instantiables(int options) {
51  std::vector<S_Schema_Node> s_vector;
52  struct lys_node *iter = NULL;
53 
54  while ((iter = (struct lys_node *)lys_getnext(iter, NULL, module, options))) {
55  s_vector.push_back(std::make_shared<Schema_Node>(iter, deleter));
56  }
57 
58  return s_vector;
59 }
60 std::string Module::print_mem(LYS_OUTFORMAT format, int options) {
61  char *strp = nullptr;
62  int rc = 0;
63 
64  rc = lys_print_mem(&strp, module, format, NULL, 0, options);
65  if (rc) {
66  check_libyang_error(module->ctx);
67  return nullptr;
68  }
69 
70  std::string s_strp = strp;
71  free(strp);
72  return s_strp;
73 }
74 std::string Module::print_mem(LYS_OUTFORMAT format, const char *target, int options) {
75  char *strp = nullptr;
76  int rc = 0;
77 
78  rc = lys_print_mem(&strp, module, format, target, 0, options);
79  if (rc) {
80  check_libyang_error(module->ctx);
81  return nullptr;
82  }
83 
84  std::string s_strp = strp;
85  free(strp);
86  return s_strp;
87 }
88 int Module::feature_enable(const char *feature) {
89  return lys_features_enable(module, feature);
90 }
91 int Module::feature_disable(const char *feature) {
92  return lys_features_disable(module, feature);
93 }
94 int Module::feature_state(const char *feature) {
95  return lys_features_state(module, feature);
96 }
98 S_Revision Submodule::rev() LY_NEW(submodule, rev, Revision);
99 std::vector<S_Deviation> Submodule::deviation() LY_NEW_LIST(submodule, deviation, deviation_size, Deviation);
100 
101 Type_Info_Binary::Type_Info_Binary(struct lys_type_info_binary *info_binary, S_Deleter deleter):
102  info_binary(info_binary),
103  deleter(deleter)
104 {};
106 S_Restr Type_Info_Binary::length() {return info_binary->length ? std::make_shared<Restr>(info_binary->length, deleter) : nullptr;};
107 
108 Type_Bit::Type_Bit(struct lys_type_bit *info_bit, S_Deleter deleter):
109  info_bit(info_bit),
110  deleter(deleter)
111 {};
113 std::vector<S_Ext_Instance> Type_Bit::ext() LY_NEW_P_LIST(info_bit, ext, ext_size, Ext_Instance);
114 std::vector<S_Iffeature> Type_Bit::iffeature() LY_NEW_LIST(info_bit, iffeature, iffeature_size, Iffeature);
115 
116 Type_Info_Bits::Type_Info_Bits(struct lys_type_info_bits *info_bits, S_Deleter deleter):
117  info_bits(info_bits),
118  deleter(deleter)
119 {};
121 std::vector<S_Type_Bit> Type_Info_Bits::bit() LY_NEW_LIST(info_bits, bit, count, Type_Bit);
122 
123 Type_Info_Dec64::Type_Info_Dec64(struct lys_type_info_dec64 *info_dec64, S_Deleter deleter):
124  info_dec64(info_dec64),
125  deleter(deleter)
126 {};
128 S_Restr Type_Info_Dec64::range() {return info_dec64->range ? std::make_shared<Restr>(info_dec64->range, deleter) : nullptr;};
129 
130 Type_Enum::Type_Enum(struct lys_type_enum *info_enum, S_Deleter deleter):
131  info_enum(info_enum),
132  deleter(deleter)
133 {};
135 std::vector<S_Ext_Instance> Type_Enum::ext() LY_NEW_P_LIST(info_enum, ext, ext_size, Ext_Instance);
136 std::vector<S_Iffeature> Type_Enum::iffeature() LY_NEW_LIST(info_enum, iffeature, iffeature_size, Iffeature);
137 
138 Type_Info_Enums::Type_Info_Enums(struct lys_type_info_enums *info_enums, S_Deleter deleter):
139  info_enums(info_enums),
140  deleter(deleter)
141 {};
143 std::vector<S_Type_Enum> Type_Info_Enums::enm() LY_NEW_LIST(info_enums, enm, count, Type_Enum);
144 
145 Type_Info_Ident::Type_Info_Ident(struct lys_type_info_ident *info_ident, S_Deleter deleter):
146  info_ident(info_ident),
147  deleter(deleter)
148 {};
150 std::vector<S_Ident> Type_Info_Ident::ref() LY_NEW_P_LIST(info_ident, ref, count, Ident);
151 
152 Type_Info_Inst::Type_Info_Inst(struct lys_type_info_inst *info_inst, S_Deleter deleter):
153  info_inst(info_inst),
154  deleter(deleter)
155 {};
157 
158 Type_Info_Num::Type_Info_Num(struct lys_type_info_num *info_num, S_Deleter deleter):
159  info_num(info_num),
160  deleter(deleter)
161 {};
163 S_Restr Type_Info_Num::range() {return info_num->range ? std::make_shared<Restr>(info_num->range, deleter) : nullptr;};
164 
165 Type_Info_Lref::Type_Info_Lref(lys_type_info_lref *info_lref, S_Deleter deleter):
166  info_lref(info_lref),
167  deleter(deleter)
168 {};
170 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;};
171 
172 Type_Info_Str::Type_Info_Str(lys_type_info_str *info_str, S_Deleter deleter):
173  info_str(info_str),
174  deleter(deleter)
175 {};
177 S_Restr Type_Info_Str::length() {return info_str->length ? std::make_shared<Restr>(info_str->length, deleter) : nullptr;};
178 S_Restr Type_Info_Str::patterns() {return info_str->patterns ? std::make_shared<Restr>(info_str->patterns, deleter) : nullptr;};
179 
181  info_union(info_union),
182  deleter(deleter)
183 {};
185 std::vector<S_Type> Type_Info_Union::types() LY_NEW_LIST(info_union, types, count, Type);
186 
187 Type_Info::Type_Info(union lys_type_info *info, LY_DATA_TYPE *type, uint8_t flags, S_Deleter deleter):
188  info(info),
189  type(*type),
190  flags(flags),
191  deleter(deleter)
192 {};
194 S_Type_Info_Binary Type_Info::binary() {return LY_TYPE_BINARY == type ? std::make_shared<Type_Info_Binary>(&info->binary, deleter) : nullptr;};
195 S_Type_Info_Bits Type_Info::bits() {return LY_TYPE_BITS == type ? std::make_shared<Type_Info_Bits>(&info->bits, deleter) : nullptr;};
196 S_Type_Info_Dec64 Type_Info::dec64() {return LY_TYPE_DEC64 == type ? std::make_shared<Type_Info_Dec64>(&info->dec64, deleter) : nullptr;};
197 S_Type_Info_Enums Type_Info::enums() {return LY_TYPE_ENUM == type ? std::make_shared<Type_Info_Enums>(&info->enums, deleter) : nullptr;};
198 S_Type_Info_Ident Type_Info::ident() {return LY_TYPE_IDENT == type ? std::make_shared<Type_Info_Ident>(&info->ident, deleter) : nullptr;};
199 S_Type_Info_Inst Type_Info::inst() {return LY_TYPE_INST == type ? std::make_shared<Type_Info_Inst>(&info->inst, deleter) : nullptr;};
200 S_Type_Info_Num Type_Info::num() {
201  if (type >= LY_TYPE_INT8 && type <= LY_TYPE_UINT64) {
202  return std::make_shared<Type_Info_Num>(&info->num, deleter);
203  } else {
204  return nullptr;
205  }
206 };
207 S_Type_Info_Lref Type_Info::lref() {return LY_TYPE_LEAFREF == type ? std::make_shared<Type_Info_Lref>(&info->lref, deleter) : nullptr;};
208 S_Type_Info_Str Type_Info::str() {return LY_TYPE_STRING == type ? std::make_shared<Type_Info_Str>(&info->str, deleter) : nullptr;};
209 S_Type_Info_Union Type_Info::uni() {return LY_TYPE_UNION == type ? std::make_shared<Type_Info_Union>(&info->uni, deleter) : nullptr;};
210 
211 Type::Type(struct lys_type *type, S_Deleter deleter):
212  type(type),
213  deleter(deleter)
214 {};
216 std::vector<S_Ext_Instance> Type::ext() LY_NEW_P_LIST(type, ext, ext_size, Ext_Instance);
217 S_Tpdf Type::der() {return type->der ? std::make_shared<Tpdf>(type->der, deleter) : nullptr;};
218 S_Tpdf Type::parent() {return type->parent ? std::make_shared<Tpdf>(type->parent, deleter) : nullptr;};
219 S_Type_Info Type::info() {return std::make_shared<Type_Info>(&type->info, &type->base, type->value_flags, deleter);};
220 
221 Iffeature::Iffeature(struct lys_iffeature *iffeature, S_Deleter deleter):
222  iffeature(iffeature),
223  deleter(deleter)
224 {};
226 std::vector<S_Ext_Instance> Iffeature::ext() LY_NEW_P_LIST(iffeature, ext, ext_size, Ext_Instance);
227 int Iffeature::value() {
228  return lys_iffeature_value(iffeature);
229 }
230 
231 Ext_Instance::Ext_Instance(lys_ext_instance *ext_instance, S_Deleter deleter):
232  ext_instance(ext_instance),
233  deleter(deleter)
234 {};
236 std::vector<S_Ext_Instance> Ext_Instance::ext() LY_NEW_P_LIST(ext_instance, ext, ext_size, Ext_Instance);
237 
238 Revision::Revision(lys_revision *revision, S_Deleter deleter):
239  revision(revision),
240  deleter(deleter)
241 {};
243 
244 Schema_Node::Schema_Node(struct lys_node *node, S_Deleter deleter):
245  node(node),
246  deleter(deleter)
247 {};
249 std::vector<S_Ext_Instance> Schema_Node::ext() LY_NEW_P_LIST(node, ext, ext_size, Ext_Instance);
250 S_Module Schema_Node::module() LY_NEW(node, module, Module);
251 S_Schema_Node Schema_Node::parent() LY_NEW(node, parent, Schema_Node);
252 S_Schema_Node Schema_Node::child() LY_NEW(node, child, Schema_Node);
253 S_Schema_Node Schema_Node::next() LY_NEW(node, next, Schema_Node);
254 S_Schema_Node Schema_Node::prev() LY_NEW(node, prev, Schema_Node);
255 std::string Schema_Node::path(int options) {
256  char *path = nullptr;
257 
258  path = lys_path(node, options);
259  if (!path) {
260  return nullptr;
261  }
262 
263  std::string s_path = path;
264  free(path);
265  return s_path;
266 }
267 std::vector<S_Schema_Node> Schema_Node::child_instantiables(int options) {
268  std::vector<S_Schema_Node> s_vector;
269  struct lys_node *iter = NULL;
270 
271  while ((iter = (struct lys_node *)lys_getnext(iter, node, node->module, options))) {
272  s_vector.push_back(std::make_shared<Schema_Node>(iter, deleter));
273  }
274 
275  return s_vector;
276 }
277 S_Set Schema_Node::find_path(const char *path) {
278  struct ly_set *set = lys_find_path(node->module, node, path);
279  if (!set) {
280  check_libyang_error(node->module->ctx);
281  return nullptr;
282  }
283 
284  S_Deleter new_deleter = std::make_shared<Deleter>(set, deleter);
285  return std::make_shared<Set>(set, new_deleter);
286 }
287 
288 S_Set Schema_Node::xpath_atomize(enum lyxp_node_type ctx_node_type, const char *expr, int options) {
289  struct ly_set *set = lys_xpath_atomize(node, ctx_node_type, expr, options);
290  if (!set) {
291  check_libyang_error(node->module->ctx);
292  return nullptr;
293  }
294 
295  return std::make_shared<Set>(set, deleter);
296 }
297 S_Set Schema_Node::xpath_atomize(int options) {
298  struct ly_set *set = lys_node_xpath_atomize(node, options);
299  if (!set) {
300  check_libyang_error(node->module->ctx);
301  return nullptr;
302  }
303 
304  return std::make_shared<Set>(set, deleter);
305 }
306 std::vector<S_Schema_Node> Schema_Node::tree_for() {
307  std::vector<S_Schema_Node> s_vector;
308 
309  struct lys_node *elem = nullptr;
310  LY_TREE_FOR(node, elem) {
311  s_vector.push_back(std::make_shared<Schema_Node>(elem, deleter));
312  }
313 
314  return s_vector;
315 }
316 std::vector<S_Schema_Node> Schema_Node::tree_dfs() {
317  std::vector<S_Schema_Node> s_vector;
318 
319  struct lys_node *elem = nullptr, *next = nullptr;
320  LY_TREE_DFS_BEGIN(node, next, elem) {
321  s_vector.push_back(std::make_shared<Schema_Node>(elem, deleter));
322  LY_TREE_DFS_END(node, next, elem)
323  }
324 
325  return s_vector;
326 }
327 
329 S_When Schema_Node_Container::when() LY_NEW_CASTED(lys_node_container, node, when, When);
330 S_Restr Schema_Node_Container::must() {
331  struct lys_node_container *node_container = (struct lys_node_container *)node;
332  return node_container->must ? std::make_shared<Restr>(node_container->must, deleter) : nullptr;
333 };
335  struct lys_node_container *node_container = (struct lys_node_container *)node;
336  return node_container->tpdf ? std::make_shared<Tpdf>(node_container->tpdf, deleter) : nullptr;
337 };
338 
340 S_When Schema_Node_Choice::when() LY_NEW_CASTED(lys_node_choice, node, when, When);
341 S_Schema_Node Schema_Node_Choice::dflt() {
342  struct lys_node_choice *node_choice = (struct lys_node_choice *)node;
343  return node_choice->dflt ? std::make_shared<Schema_Node>(node_choice->dflt, deleter) : nullptr;
344 };
345 
347 S_When Schema_Node_Leaf::when() LY_NEW_CASTED(lys_node_leaf, node, when, When);
348 S_Type Schema_Node_Leaf::type() {return std::make_shared<Type>(&((struct lys_node_leaf *)node)->type, deleter);}
349 S_Schema_Node_List Schema_Node_Leaf::is_key() {
350  uint8_t pos;
351 
352  auto list = lys_is_key((struct lys_node_leaf *)node, &pos);
353  return list ? std::make_shared<Schema_Node_List>((struct lys_node *) list, deleter) : nullptr;
354 }
355 
357 S_When Schema_Node_Leaflist::when() LY_NEW_CASTED(lys_node_leaflist, node, when, When);
358 std::vector<std::string> Schema_Node_Leaflist::dflt() {
359  struct lys_node_leaflist *node_leaflist = (struct lys_node_leaflist *)node;
360  LY_NEW_STRING_LIST(node_leaflist, dflt, dflt_size);
361 }
362 std::vector<S_Restr> Schema_Node_Leaflist::must() LY_NEW_LIST_CASTED(lys_node_leaflist, node, must, must_size, Restr);
363 S_Type Schema_Node_Leaflist::type() {return std::make_shared<Type>(&((struct lys_node_leaflist *)node)->type, deleter);}
364 
366 S_When Schema_Node_List::when() LY_NEW_CASTED(lys_node_list, node, when, When);
367 std::vector<S_Restr> Schema_Node_List::must() LY_NEW_LIST_CASTED(lys_node_list, node, must, must_size, Restr);
368 std::vector<S_Tpdf> Schema_Node_List::tpdf() LY_NEW_LIST_CASTED(lys_node_list, node, tpdf, tpdf_size, Tpdf);
369 std::vector<S_Schema_Node_Leaf> Schema_Node_List::keys() {
370  auto list = (struct lys_node_list *) node;
371 
372  std::vector<S_Schema_Node_Leaf> s_vector;
373 
374  for (uint8_t i = 0; i < list->keys_size; i++) {
375  s_vector.push_back(std::make_shared<Schema_Node_Leaf>((struct lys_node *) list->keys[i], deleter));
376  }
377 
378  return s_vector;
379 }
380 std::vector<S_Unique> Schema_Node_List::unique() LY_NEW_LIST_CASTED(lys_node_list, node, unique, unique_size, Unique);
381 
383 S_When Schema_Node_Anydata::when() LY_NEW_CASTED(lys_node_anydata, node, when, When);
384 std::vector<S_Restr> Schema_Node_Anydata::must() LY_NEW_LIST_CASTED(lys_node_anydata, node, must, must_size, Restr);
385 
387 S_When Schema_Node_Uses::when() LY_NEW_CASTED(lys_node_uses, node, when, When);
388 std::vector<S_Refine> Schema_Node_Uses::refine() LY_NEW_LIST_CASTED(lys_node_uses, node, refine, refine_size, Refine);
389 std::vector<S_Schema_Node_Augment> Schema_Node_Uses::augment() {
390  auto uses = (struct lys_node_uses *) node;
391 
392  std::vector<S_Schema_Node_Augment> s_vector;
393 
394  for (uint8_t i = 0; i < uses->augment_size; i++) {
395  s_vector.push_back(std::make_shared<Schema_Node_Augment>((struct lys_node *) &uses->augment[i], deleter));
396  }
397 
398  return s_vector;
399 }
400 S_Schema_Node_Grp Schema_Node_Uses::grp() {
401  auto uses = (struct lys_node_uses *) node;
402  return uses->grp ? std::make_shared<Schema_Node_Grp>(node, deleter) : nullptr;
403 };
404 
406 std::vector<S_Tpdf> Schema_Node_Grp::tpdf() LY_NEW_LIST_CASTED(lys_node_grp, node, tpdf, tpdf_size, Tpdf);
407 
409 S_When Schema_Node_Case::when() LY_NEW_CASTED(lys_node_case, node, when, When);
410 
412 std::vector<S_Tpdf> Schema_Node_Inout::tpdf() LY_NEW_LIST_CASTED(lys_node_inout, node, tpdf, tpdf_size, Tpdf);
413 std::vector<S_Restr> Schema_Node_Inout::must() LY_NEW_LIST_CASTED(lys_node_inout, node, must, must_size, Restr);
414 
416 std::vector<S_Tpdf> Schema_Node_Notif::tpdf() LY_NEW_LIST_CASTED(lys_node_notif, node, tpdf, tpdf_size, Tpdf);
417 std::vector<S_Restr> Schema_Node_Notif::must() LY_NEW_LIST_CASTED(lys_node_notif, node, must, must_size, Restr);
418 
420 std::vector<S_Tpdf> Schema_Node_Rpc_Action::tpdf() LY_NEW_LIST_CASTED(lys_node_rpc_action, node, tpdf, tpdf_size, Tpdf);
421 
423 S_When Schema_Node_Augment::when() LY_NEW_CASTED(lys_node_augment, node, when, When);
424 
425 When::When(struct lys_when *when, S_Deleter deleter):
426  when(when),
427  deleter(deleter)
428 {};
430 std::vector<S_Ext_Instance> When::ext() LY_NEW_P_LIST(when, ext, ext_size, Ext_Instance);
431 
432 Substmt::Substmt(struct lyext_substmt *substmt, S_Deleter deleter):
433  substmt(substmt),
434  deleter(deleter)
435 {};
437 
438 Ext::Ext(struct lys_ext *ext, S_Deleter deleter):
439  ext(ext),
440  deleter(deleter)
441 {};
443 std::vector<S_Ext_Instance> Ext::ext_instance() LY_NEW_P_LIST(ext, ext, ext_size, Ext_Instance);
444 S_Module Ext::module() LY_NEW(ext, module, Module);
445 
446 Refine_Mod_List::Refine_Mod_List(struct lys_refine_mod_list *list, S_Deleter deleter):
447  list(list),
448  deleter(deleter)
449 {};
451 
452 Refine_Mod::Refine_Mod(union lys_refine_mod mod, uint16_t target_type, S_Deleter deleter):
453  mod(mod),
454  target_type(target_type),
455  deleter(deleter)
456 {};
458 //TODO check which type's to accept
459 S_Refine_Mod_List Refine_Mod::list() {return target_type != LYS_CONTAINER ? std::make_shared<Refine_Mod_List>(&mod.list, deleter) : nullptr;};
460 
461 Refine::Refine(struct lys_refine *refine, S_Deleter deleter):
462  refine(refine),
463  deleter(deleter)
464 {};
466 std::vector<S_Ext_Instance> Refine::ext() LY_NEW_P_LIST(refine, ext, ext_size, Ext_Instance);
467 S_Module Refine::module() LY_NEW(refine, module, Module);
468 std::vector<S_Restr> Refine::must() LY_NEW_LIST(refine, must, must_size, Restr);
469 S_Refine_Mod Refine::mod() {return std::make_shared<Refine_Mod>(refine->mod, refine->target_type, deleter);};
470 
471 Deviate::Deviate(struct lys_deviate *deviate, S_Deleter deleter):
472  deviate(deviate),
473  deleter(deleter)
474 {};
476 std::vector<S_Ext_Instance> Deviate::ext() LY_NEW_P_LIST(deviate, ext, ext_size, Ext_Instance);
477 S_Restr Deviate::must() {return deviate->must ? std::make_shared<Restr>(deviate->must, deleter) : nullptr;};
478 S_Unique Deviate::unique() {return deviate->unique ? std::make_shared<Unique>(deviate->unique, deleter) : nullptr;};
479 S_Type Deviate::type() {return deviate->type ? std::make_shared<Type>(deviate->type, deleter) : nullptr;}
480 
481 Deviation::Deviation(struct lys_deviation *deviation, S_Deleter deleter):
482  deviation(deviation),
483  deleter(deleter)
484 {};
486 S_Schema_Node Deviation::orig_node() LY_NEW(deviation, orig_node, Schema_Node);
487 std::vector<S_Deviate> Deviation::deviate() LY_NEW_LIST(deviation, deviate, deviate_size, Deviate);
488 std::vector<S_Ext_Instance> Deviation::ext() LY_NEW_P_LIST(deviation, ext, ext_size, Ext_Instance);
489 
490 Import::Import(struct lys_import *import, S_Deleter deleter):
491  import(import),
492  deleter(deleter)
493 {};
495 
496 Include::Include(struct lys_include *include, S_Deleter deleter):
497  include(include),
498  deleter(deleter)
499 {}
501 
502 Tpdf::Tpdf(struct lys_tpdf *tpdf, S_Deleter deleter):
503  tpdf(tpdf),
504  deleter(deleter)
505 {}
507 S_Type Tpdf::type() {return std::make_shared<Type>(&tpdf->type, deleter);}
508 
509 Unique::Unique(struct lys_unique *unique, S_Deleter deleter):
510  unique(unique),
511  deleter(deleter)
512 {};
514 
515 Feature::Feature(struct lys_feature *feature, S_Deleter deleter):
516  feature(feature),
517  deleter(deleter)
518 {};
520 
521 Restr::Restr(struct lys_restr *restr, S_Deleter deleter):
522  restr(restr),
523  deleter(deleter)
524 {};
526 
527 Ident::Ident(struct lys_ident *ident, S_Deleter deleter):
528  ident(ident),
529  deleter(deleter)
530 {};
532 std::vector<S_Ident> Ident::base() LY_NEW_P_LIST(ident, base, base_size, Ident);
533 
534 }
Type_Enum(struct lys_type_enum *info_enum, S_Deleter deleter)
struct lys_module * module
Definition: tree_schema.h:1247
Common structure representing single YANG data statement describing.
Definition: tree_schema.h:1231
Schema leaf node structure.
Definition: tree_schema.h:1367
S_Type_Info_Enums enums()
Ident(struct lys_ident *ident, S_Deleter deleter)
Tpdf(struct lys_tpdf *tpdf, S_Deleter deleter)
Schema grouping node structure.
Definition: tree_schema.h:1628
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:966
S_Schema_Node_Leaf target()
struct lys_type_info_inst inst
Definition: tree_schema.h:970
Submodule schema node structure that can be included into a YANG module.
Definition: tree_schema.h:736
Unique(struct lys_unique *unique, S_Deleter deleter)
Schema choice node structure.
Definition: tree_schema.h:1325
std::vector< S_Ext_Instance > ext()
struct lys_type_info_num num
Definition: tree_schema.h:971
struct lys_unique * unique
Definition: tree_schema.h:1512
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:1353
std::vector< S_Schema_Node > tree_for()
struct lys_restr * patterns
Definition: tree_schema.h:937
struct lys_refine_mod_list list
Definition: tree_schema.h:1890
std::vector< S_Ext_Instance > ext()
uint8_t iffeature_size
Definition: tree_schema.h:1237
Type_Bit(struct lys_type_bit *info_bit, S_Deleter deleter)
S_Revision rev()
Definition: Tree_Schema.cpp:98
std::vector< S_Tpdf > tpdf()
YANG uses&#39;s refine substatement structure, see RFC 6020 sec. 7.12.2
Definition: tree_schema.h:1897
std::vector< S_Schema_Node > tree_dfs()
YANG import structure used to reference other schemas (modules).
Definition: tree_schema.h:1981
std::vector< S_Schema_Node > data_instantiables(int options)
Definition: Tree_Schema.cpp:50
S_Type_Info_Inst inst()
Container for list modifications in lys_refine_mod.
Definition: tree_schema.h:1880
Container for information about string types (LY_TYPE_STRING), used in lys_type_info.
Definition: tree_schema.h:934
S_Schema_Node_List is_key()
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:2017
struct lys_restr * length
Definition: tree_schema.h:820
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:2343
struct lys_type * type
Definition: tree_schema.h:1955
Single enumeration value specification for lys_type_info_enums.
Definition: tree_schema.h:867
Union for holding type-specific information in lys_type.
Definition: tree_schema.h:964
int lys_features_disable(const struct lys_module *module, const char *feature)
Disable specified feature in the module. If it causes some dependant features to be disabled...
S_Schema_Node_Grp grp()
S_Type_Info_Union uni()
struct lys_node * child
Definition: tree_schema.h:1251
Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info.
Definition: tree_schema.h:921
struct lys_tpdf * tpdf
Definition: tree_schema.h:1312
Compiled if-feature expression structure.
Definition: tree_schema.h:1077
union lys_type_info info
Definition: tree_schema.h:989
Schema leaf-list node structure.
Definition: tree_schema.h:1418
YANG augment structure (covering both possibilities - uses&#39;s substatement as well as (sub)module&#39;s su...
Definition: tree_schema.h:1845
LYS_OUTFORMAT
Schema output formats accepted by libyang printer functions.
Definition: tree_schema.h:196
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:886
Container for information about integer types, used in lys_type_info.
Definition: tree_schema.h:913
Ext_Instance(lys_ext_instance *ext_instance, S_Deleter deleter)
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:1888
Schema anydata (and anyxml) node structure.
Definition: tree_schema.h:1533
Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info.
Definition: tree_schema.h:854
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.
int lys_features_enable(const struct lys_module *module, const char *feature)
Enable specified feature in the module. In case its if-feature evaluates to false, return an error.
std::vector< S_Restr > must()
const char * ref
Definition: tree_schema.h:1234
std::vector< S_Ext_Instance > ext()
struct lys_type_info_lref lref
Definition: tree_schema.h:972
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:88
S_Unique unique()
struct lys_iffeature * iffeature
Definition: tree_schema.h:1246
virtual S_Schema_Node next()
Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info.
Definition: tree_schema.h:894
YANG when restriction, see RFC 6020 sec. 7.19.5
Definition: tree_schema.h:2088
#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:90
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:846
Submodule(struct lys_submodule *submodule, S_Deleter deleter)
Definition: Tree_Schema.cpp:38
S_Type_Info_Binary binary()
Schema case node structure.
Definition: tree_schema.h:1667
int lys_features_state(const struct lys_module *module, const char *feature)
Get the current status of the specified feature in the module. Even if the feature is enabled but som...
#define LY_TREE_DFS_END(START, NEXT, ELEM)
Definition: tree_schema.h:122
Schema list node structure.
Definition: tree_schema.h:1474
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:902
Main schema node structure representing YANG module.
Definition: tree_schema.h:673
#define LY_TREE_FOR(START, ELEM)
Macro to iterate via all sibling elements without affecting the list itself.
Definition: tree_schema.h:40
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:1486
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:1712
LY_DATA_TYPE _PACKED base
Definition: tree_schema.h:981
LY_DATA_TYPE
YANG built-in types.
Definition: tree_schema.h:791
S_Schema_Node orig_node()
uint8_t ext_size
Definition: tree_schema.h:1236
struct lys_node * next
Definition: tree_schema.h:1255
struct lys_node_leaf * target
Definition: tree_schema.h:924
struct lys_type_info_dec64 dec64
Definition: tree_schema.h:967
struct lys_type_info_binary binary
Definition: tree_schema.h:965
struct lys_type type
Definition: tree_schema.h:1455
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:60
uint16_t flags
Definition: tree_schema.h:1235
YANG type structure providing information from the schema.
Definition: tree_schema.h:980
char * lys_path(const struct lys_node *node, int options)
Build schema path (usable as path, see howtoxpath) of the schema node.
std::vector< S_Ext_Instance > ext()
S_Tpdf parent()
struct lys_when * when
Definition: tree_schema.h:1310
YANG list&#39;s unique statement structure, see RFC 6020 sec. 7.8.3
Definition: tree_schema.h:2042
S_Type_Info_Bits bits()
struct lys_refine * refine
Definition: tree_schema.h:1612
Structure to hold information about identity, see RFC 6020 sec. 7.16
Definition: tree_schema.h:2102
struct lys_node * prev
Definition: tree_schema.h:1256
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:442
S_Type_Info_Str str()
YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2
Definition: tree_schema.h:1938
struct lys_restr * range
Definition: tree_schema.h:855
std::vector< S_Ext_Instance > ext()
struct lys_type_info_enums enums
Definition: tree_schema.h:968
Schema uses node structure.
Definition: tree_schema.h:1581
int feature_state(const char *feature)
Definition: Tree_Schema.cpp:94
struct lys_type_info_union uni
Definition: tree_schema.h:974
Schema notification node structure.
Definition: tree_schema.h:1750
std::vector< S_Ext_Instance > ext()
std::vector< S_Unique > unique()
YANG validity restriction (must, length, etc.) structure providing information from the schema...
Definition: tree_schema.h:2072
std::vector< S_Ext_Instance > ext()
Schema rpc/action node structure.
Definition: tree_schema.h:1797
struct lys_restr * must
Definition: tree_schema.h:1311
Generic extension instance structure.
Definition: tree_schema.h:471
Container for information about union types (LY_TYPE_UNION), used in lys_type_info.
Definition: tree_schema.h:954
struct lys_tpdf * parent
Definition: tree_schema.h:987
YANG extension definition.
Definition: tree_schema.h:451
struct ly_ctx * ctx
Definition: tree_schema.h:674
uint8_t value_flags
Definition: tree_schema.h:982
YANG revision statement for (sub)modules.
Definition: tree_schema.h:2006
struct lys_type_info_str str
Definition: tree_schema.h:973
YANG include structure used to reference submodules.
Definition: tree_schema.h:1994
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.
YANG feature definition structure.
Definition: tree_schema.h:2051
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:91
std::vector< S_Type_Bit > bit()
Single bit value specification for lys_type_info_bits.
Definition: tree_schema.h:827
classes for wrapping lys_module.
Definition: Tree_Schema.hpp:44
S_Type_Info info()
struct lys_type_info_ident ident
Definition: tree_schema.h:969
struct lys_ext_instance ** ext
Definition: tree_schema.h:1245
Schema container node structure.
Definition: tree_schema.h:1277
struct lys_node * parent
Definition: tree_schema.h:1250
YANG deviation statement structure, see RFC 6020 sec. 7.18.3
Definition: tree_schema.h:1965
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.