libyang 1.0.184
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
24extern "C" {
25#include "libyang.h"
26#include "tree_schema.h"
27}
28
29namespace libyang {
30
31Module::Module(struct lys_module *module, S_Deleter deleter):
32 module(module),
33 deleter(deleter)
34{};
36S_Revision Module::rev() LY_NEW(module, rev, Revision);
37std::vector<S_Deviation> Module::deviation() LY_NEW_LIST(module, deviation, deviation_size, Deviation);
38Submodule::Submodule(struct lys_submodule *submodule, S_Deleter deleter):
39 submodule(submodule),
40 deleter(deleter)
41{};
42Submodule::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}
50std::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}
60std::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}
74std::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}
88int Module::feature_enable(const char *feature) {
89 return lys_features_enable(module, feature);
90}
91int Module::feature_disable(const char *feature) {
92 return lys_features_disable(module, feature);
93}
94int Module::feature_state(const char *feature) {
95 return lys_features_state(module, feature);
96}
98S_Revision Submodule::rev() LY_NEW(submodule, rev, Revision);
99std::vector<S_Deviation> Submodule::deviation() LY_NEW_LIST(submodule, deviation, deviation_size, Deviation);
100
101Type_Info_Binary::Type_Info_Binary(struct lys_type_info_binary *info_binary, S_Deleter deleter):
102 info_binary(info_binary),
103 deleter(deleter)
104{};
106S_Restr Type_Info_Binary::length() {return info_binary->length ? std::make_shared<Restr>(info_binary->length, deleter) : nullptr;};
107
108Type_Bit::Type_Bit(struct lys_type_bit *info_bit, S_Deleter deleter):
109 info_bit(info_bit),
110 deleter(deleter)
111{};
113std::vector<S_Ext_Instance> Type_Bit::ext() LY_NEW_P_LIST(info_bit, ext, ext_size, Ext_Instance);
114std::vector<S_Iffeature> Type_Bit::iffeature() LY_NEW_LIST(info_bit, iffeature, iffeature_size, Iffeature);
115
116Type_Info_Bits::Type_Info_Bits(struct lys_type_info_bits *info_bits, S_Deleter deleter):
117 info_bits(info_bits),
118 deleter(deleter)
119{};
121std::vector<S_Type_Bit> Type_Info_Bits::bit() LY_NEW_LIST(info_bits, bit, count, Type_Bit);
122
123Type_Info_Dec64::Type_Info_Dec64(struct lys_type_info_dec64 *info_dec64, S_Deleter deleter):
124 info_dec64(info_dec64),
125 deleter(deleter)
126{};
128S_Restr Type_Info_Dec64::range() {return info_dec64->range ? std::make_shared<Restr>(info_dec64->range, deleter) : nullptr;};
129
130Type_Enum::Type_Enum(struct lys_type_enum *info_enum, S_Deleter deleter):
131 info_enum(info_enum),
132 deleter(deleter)
133{};
135std::vector<S_Ext_Instance> Type_Enum::ext() LY_NEW_P_LIST(info_enum, ext, ext_size, Ext_Instance);
136std::vector<S_Iffeature> Type_Enum::iffeature() LY_NEW_LIST(info_enum, iffeature, iffeature_size, Iffeature);
137
138Type_Info_Enums::Type_Info_Enums(struct lys_type_info_enums *info_enums, S_Deleter deleter):
139 info_enums(info_enums),
140 deleter(deleter)
141{};
143std::vector<S_Type_Enum> Type_Info_Enums::enm() LY_NEW_LIST(info_enums, enm, count, Type_Enum);
144
145Type_Info_Ident::Type_Info_Ident(struct lys_type_info_ident *info_ident, S_Deleter deleter):
146 info_ident(info_ident),
147 deleter(deleter)
148{};
150std::vector<S_Ident> Type_Info_Ident::ref() LY_NEW_P_LIST(info_ident, ref, count, Ident);
151
152Type_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
158Type_Info_Num::Type_Info_Num(struct lys_type_info_num *info_num, S_Deleter deleter):
159 info_num(info_num),
160 deleter(deleter)
161{};
163S_Restr Type_Info_Num::range() {return info_num->range ? std::make_shared<Restr>(info_num->range, deleter) : nullptr;};
164
166 info_lref(info_lref),
167 deleter(deleter)
168{};
170S_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
173 info_str(info_str),
174 deleter(deleter)
175{};
177S_Restr Type_Info_Str::length() {return info_str->length ? std::make_shared<Restr>(info_str->length, deleter) : nullptr;};
178S_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{};
185std::vector<S_Type> Type_Info_Union::types() LY_NEW_LIST(info_union, types, count, Type);
186
187Type_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{};
194S_Type_Info_Binary Type_Info::binary() {return LY_TYPE_BINARY == type ? std::make_shared<Type_Info_Binary>(&info.binary, deleter) : nullptr;};
195S_Type_Info_Bits Type_Info::bits() {return LY_TYPE_BITS == type ? std::make_shared<Type_Info_Bits>(&info.bits, deleter) : nullptr;};
196S_Type_Info_Dec64 Type_Info::dec64() {return LY_TYPE_DEC64 == type ? std::make_shared<Type_Info_Dec64>(&info.dec64, deleter) : nullptr;};
197S_Type_Info_Enums Type_Info::enums() {return LY_TYPE_ENUM == type ? std::make_shared<Type_Info_Enums>(&info.enums, deleter) : nullptr;};
198S_Type_Info_Ident Type_Info::ident() {return LY_TYPE_IDENT == type ? std::make_shared<Type_Info_Ident>(&info.ident, deleter) : nullptr;};
199S_Type_Info_Inst Type_Info::inst() {return LY_TYPE_INST == type ? std::make_shared<Type_Info_Inst>(&info.inst, deleter) : nullptr;};
200S_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};
207S_Type_Info_Lref Type_Info::lref() {return LY_TYPE_LEAFREF == type ? std::make_shared<Type_Info_Lref>(&info.lref, deleter) : nullptr;};
208S_Type_Info_Str Type_Info::str() {return LY_TYPE_STRING == type ? std::make_shared<Type_Info_Str>(&info.str, deleter) : nullptr;};
209S_Type_Info_Union Type_Info::uni() {return LY_TYPE_UNION == type ? std::make_shared<Type_Info_Union>(&info.uni, deleter) : nullptr;};
210
211Type::Type(struct lys_type *type, S_Deleter deleter):
212 type(type),
213 deleter(deleter)
214{};
216std::vector<S_Ext_Instance> Type::ext() LY_NEW_P_LIST(type, ext, ext_size, Ext_Instance);
217S_Tpdf Type::der() {return type->der ? std::make_shared<Tpdf>(type->der, deleter) : nullptr;};
218S_Tpdf Type::parent() {return type->parent ? std::make_shared<Tpdf>(type->parent, deleter) : nullptr;};
219S_Type_Info Type::info() {return std::make_shared<Type_Info>(type->info, &type->base, type->value_flags, deleter);};
220
221Iffeature::Iffeature(struct lys_iffeature *iffeature, S_Deleter deleter):
223 deleter(deleter)
224{};
226std::vector<S_Ext_Instance> Iffeature::ext() LY_NEW_P_LIST(iffeature, ext, ext_size, Ext_Instance);
227int Iffeature::value() {
229}
230
231Ext_Instance::Ext_Instance(lys_ext_instance *ext_instance, S_Deleter deleter):
232 ext_instance(ext_instance),
233 deleter(deleter)
234{};
236std::vector<S_Ext_Instance> Ext_Instance::ext() LY_NEW_P_LIST(ext_instance, ext, ext_size, Ext_Instance);
237
238Revision::Revision(lys_revision *revision, S_Deleter deleter):
239 revision(revision),
240 deleter(deleter)
241{};
243
244Schema_Node::Schema_Node(struct lys_node *node, S_Deleter deleter):
245 node(node),
246 deleter(deleter)
247{};
249std::vector<S_Ext_Instance> Schema_Node::ext() LY_NEW_P_LIST(node, ext, ext_size, Ext_Instance);
250S_Module Schema_Node::module() LY_NEW(node, module, Module);
251S_Schema_Node Schema_Node::parent() LY_NEW(node, parent, Schema_Node);
252S_Schema_Node Schema_Node::child() LY_NEW(node, child, Schema_Node);
253S_Schema_Node Schema_Node::next() LY_NEW(node, next, Schema_Node);
254S_Schema_Node Schema_Node::prev() LY_NEW(node, prev, Schema_Node);
255std::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}
267std::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}
277S_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
288S_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}
297S_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}
306std::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}
316std::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
329S_When Schema_Node_Container::when() LY_NEW_CASTED(lys_node_container, node, when, When);
330S_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
340S_When Schema_Node_Choice::when() LY_NEW_CASTED(lys_node_choice, node, when, When);
341S_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
347S_When Schema_Node_Leaf::when() LY_NEW_CASTED(lys_node_leaf, node, when, When);
348S_Type Schema_Node_Leaf::type() {return std::make_shared<Type>(&((struct lys_node_leaf *)node)->type, deleter);}
349S_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
358std::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}
362std::vector<S_Restr> Schema_Node_Leaflist::must() LY_NEW_LIST_CASTED(lys_node_leaflist, node, must, must_size, Restr);
363S_Type Schema_Node_Leaflist::type() {return std::make_shared<Type>(&((struct lys_node_leaflist *)node)->type, deleter);}
364
366S_When Schema_Node_List::when() LY_NEW_CASTED(lys_node_list, node, when, When);
367std::vector<S_Restr> Schema_Node_List::must() LY_NEW_LIST_CASTED(lys_node_list, node, must, must_size, Restr);
368std::vector<S_Tpdf> Schema_Node_List::tpdf() LY_NEW_LIST_CASTED(lys_node_list, node, tpdf, tpdf_size, Tpdf);
369std::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}
380std::vector<S_Unique> Schema_Node_List::unique() LY_NEW_LIST_CASTED(lys_node_list, node, unique, unique_size, Unique);
381
383S_When Schema_Node_Anydata::when() LY_NEW_CASTED(lys_node_anydata, node, when, When);
384std::vector<S_Restr> Schema_Node_Anydata::must() LY_NEW_LIST_CASTED(lys_node_anydata, node, must, must_size, Restr);
385
387S_When Schema_Node_Uses::when() LY_NEW_CASTED(lys_node_uses, node, when, When);
388std::vector<S_Refine> Schema_Node_Uses::refine() LY_NEW_LIST_CASTED(lys_node_uses, node, refine, refine_size, Refine);
389std::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}
400S_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
406std::vector<S_Tpdf> Schema_Node_Grp::tpdf() LY_NEW_LIST_CASTED(lys_node_grp, node, tpdf, tpdf_size, Tpdf);
407
409S_When Schema_Node_Case::when() LY_NEW_CASTED(lys_node_case, node, when, When);
410
412std::vector<S_Tpdf> Schema_Node_Inout::tpdf() LY_NEW_LIST_CASTED(lys_node_inout, node, tpdf, tpdf_size, Tpdf);
413std::vector<S_Restr> Schema_Node_Inout::must() LY_NEW_LIST_CASTED(lys_node_inout, node, must, must_size, Restr);
414
416std::vector<S_Tpdf> Schema_Node_Notif::tpdf() LY_NEW_LIST_CASTED(lys_node_notif, node, tpdf, tpdf_size, Tpdf);
417std::vector<S_Restr> Schema_Node_Notif::must() LY_NEW_LIST_CASTED(lys_node_notif, node, must, must_size, Restr);
418
420std::vector<S_Tpdf> Schema_Node_Rpc_Action::tpdf() LY_NEW_LIST_CASTED(lys_node_rpc_action, node, tpdf, tpdf_size, Tpdf);
421
423S_When Schema_Node_Augment::when() LY_NEW_CASTED(lys_node_augment, node, when, When);
424
425When::When(struct lys_when *when, S_Deleter deleter):
426 when(when),
427 deleter(deleter)
428{};
430std::vector<S_Ext_Instance> When::ext() LY_NEW_P_LIST(when, ext, ext_size, Ext_Instance);
431
432Substmt::Substmt(struct lyext_substmt *substmt, S_Deleter deleter):
433 substmt(substmt),
434 deleter(deleter)
435{};
437
438Ext::Ext(struct lys_ext *ext, S_Deleter deleter):
439 ext(ext),
440 deleter(deleter)
441{};
443std::vector<S_Ext_Instance> Ext::ext_instance() LY_NEW_P_LIST(ext, ext, ext_size, Ext_Instance);
444S_Module Ext::module() LY_NEW(ext, module, Module);
445
446Refine_Mod_List::Refine_Mod_List(struct lys_refine_mod_list *list, S_Deleter deleter):
447 list(list),
448 deleter(deleter)
449{};
451
452Refine_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
459S_Refine_Mod_List Refine_Mod::list() {return target_type != LYS_CONTAINER ? std::make_shared<Refine_Mod_List>(&mod.list, deleter) : nullptr;};
460
461Refine::Refine(struct lys_refine *refine, S_Deleter deleter):
462 refine(refine),
463 deleter(deleter)
464{};
466std::vector<S_Ext_Instance> Refine::ext() LY_NEW_P_LIST(refine, ext, ext_size, Ext_Instance);
467S_Module Refine::module() LY_NEW(refine, module, Module);
468std::vector<S_Restr> Refine::must() LY_NEW_LIST(refine, must, must_size, Restr);
469S_Refine_Mod Refine::mod() {return std::make_shared<Refine_Mod>(refine->mod, refine->target_type, deleter);};
470
471Deviate::Deviate(struct lys_deviate *deviate, S_Deleter deleter):
472 deviate(deviate),
473 deleter(deleter)
474{};
476std::vector<S_Ext_Instance> Deviate::ext() LY_NEW_P_LIST(deviate, ext, ext_size, Ext_Instance);
477S_Restr Deviate::must() {return deviate->must ? std::make_shared<Restr>(deviate->must, deleter) : nullptr;};
478S_Unique Deviate::unique() {return deviate->unique ? std::make_shared<Unique>(deviate->unique, deleter) : nullptr;};
479S_Type Deviate::type() {return deviate->type ? std::make_shared<Type>(deviate->type, deleter) : nullptr;}
480
481Deviation::Deviation(struct lys_deviation *deviation, S_Deleter deleter):
482 deviation(deviation),
483 deleter(deleter)
484{};
486S_Schema_Node Deviation::orig_node() LY_NEW(deviation, orig_node, Schema_Node);
487std::vector<S_Deviate> Deviation::deviate() LY_NEW_LIST(deviation, deviate, deviate_size, Deviate);
488std::vector<S_Ext_Instance> Deviation::ext() LY_NEW_P_LIST(deviation, ext, ext_size, Ext_Instance);
489
490Import::Import(struct lys_import *import, S_Deleter deleter):
491 import(import),
492 deleter(deleter)
493{};
495
496Include::Include(struct lys_include *include, S_Deleter deleter):
497 include(include),
498 deleter(deleter)
499{}
501
502Tpdf::Tpdf(struct lys_tpdf *tpdf, S_Deleter deleter):
503 tpdf(tpdf),
504 deleter(deleter)
505{}
507S_Type Tpdf::type() {return std::make_shared<Type>(&tpdf->type, deleter);}
508
509Unique::Unique(struct lys_unique *unique, S_Deleter deleter):
510 unique(unique),
511 deleter(deleter)
512{};
514
515Feature::Feature(struct lys_feature *feature, S_Deleter deleter):
516 feature(feature),
517 deleter(deleter)
518{};
520
521Restr::Restr(struct lys_restr *restr, S_Deleter deleter):
522 restr(restr),
523 deleter(deleter)
524{};
526
527Ident::Ident(struct lys_ident *ident, S_Deleter deleter):
528 ident(ident),
529 deleter(deleter)
530{};
532std::vector<S_Ident> Ident::base() LY_NEW_P_LIST(ident, base, base_size, Ident);
533
534}
Class implementation for libyang C header libyang.h.
Class implementation for libyang C header tree_schema.h.
std::vector< S_Ext_Instance > ext()
Deviate(struct lys_deviate *deviate, S_Deleter deleter)
S_Unique unique()
Deviation(struct lys_deviation *deviation, S_Deleter deleter)
S_Schema_Node orig_node()
std::vector< S_Ext_Instance > ext()
Ext_Instance(lys_ext_instance *ext_instance, S_Deleter deleter)
std::vector< S_Ext_Instance > ext_instance()
Ext(struct lys_ext *ext, S_Deleter deleter)
Feature(struct lys_feature *feature, S_Deleter)
std::vector< S_Ident > base()
Ident(struct lys_ident *ident, S_Deleter deleter)
std::vector< S_Ext_Instance > ext()
Iffeature(struct lys_iffeature *iffeature, S_Deleter deleter)
Include(struct lys_include *include, S_Deleter deleter)
classes for wrapping lys_module.
Definition: Tree_Schema.hpp:45
int feature_disable(const char *feature)
Definition: Tree_Schema.cpp:91
std::string print_mem(LYS_OUTFORMAT format, int options)
Definition: Tree_Schema.cpp:60
Module(struct lys_module *module, S_Deleter deleter)
Definition: Tree_Schema.cpp:31
int feature_state(const char *feature)
Definition: Tree_Schema.cpp:94
S_Revision rev()
Definition: Tree_Schema.cpp:36
std::vector< S_Schema_Node > data_instantiables(int options)
Definition: Tree_Schema.cpp:50
int feature_enable(const char *feature)
Definition: Tree_Schema.cpp:88
Refine_Mod(union lys_refine_mod mod, uint16_t target_type, S_Deleter deleter)
S_Refine_Mod_List list()
std::vector< S_Ext_Instance > ext()
Refine(struct lys_refine *refine, S_Deleter deleter)
Restr(struct lys_restr *restr, S_Deleter deleter)
std::vector< S_Tpdf > tpdf()
std::vector< S_Tpdf > tpdf()
S_Schema_Node_List is_key()
std::vector< S_Restr > must()
std::vector< S_Unique > unique()
std::vector< S_Tpdf > tpdf()
std::vector< S_Tpdf > tpdf()
S_Schema_Node_Grp grp()
std::vector< S_Schema_Node > tree_dfs()
std::vector< S_Ext_Instance > ext()
std::vector< S_Schema_Node > child_instantiables(int options)
std::vector< S_Schema_Node > tree_for()
std::string path(int options=0)
S_Set xpath_atomize(enum lyxp_node_type ctx_node_type, const char *expr, int options)
S_Set find_path(const char *path)
virtual S_Schema_Node next()
Schema_Node(lys_node *node, S_Deleter deleter)
classes for wrapping lys_submodule.
S_Revision rev()
Definition: Tree_Schema.cpp:98
Submodule(struct lys_submodule *submodule, S_Deleter deleter)
Definition: Tree_Schema.cpp:38
Tpdf(struct lys_tpdf *tpdf, S_Deleter deleter)
std::vector< S_Ext_Instance > ext()
Type_Bit(struct lys_type_bit *info_bit, S_Deleter deleter)
std::vector< S_Ext_Instance > ext()
Type_Enum(struct lys_type_enum *info_enum, S_Deleter deleter)
std::vector< S_Type_Bit > bit()
std::vector< S_Type_Enum > enm()
std::vector< S_Ident > ref()
Type_Info_Lref(struct lys_type_info_lref *info_lref, S_Deleter deleter)
S_Schema_Node_Leaf target()
Type_Info_Num(struct lys_type_info_num *info_num, S_Deleter deleter)
Type_Info_Str(struct lys_type_info_str *info_str, S_Deleter deleter)
Type_Info_Union(struct lys_type_info_union *info_union, S_Deleter deleter)
std::vector< S_Type > types()
S_Type_Info_Inst inst()
S_Type_Info_Str str()
S_Type_Info_Binary binary()
S_Type_Info_Bits bits()
S_Type_Info_Enums enums()
S_Type_Info_Lref lref()
S_Type_Info_Ident ident()
S_Type_Info_Dec64 dec64()
S_Type_Info_Union uni()
S_Type_Info_Num num()
S_Type_Info info()
std::vector< S_Ext_Instance > ext()
Type(struct lys_type *type, S_Deleter deleter)
S_Tpdf parent()
Unique(struct lys_unique *unique, S_Deleter deleter)
std::vector< S_Ext_Instance > ext()
#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
#define LY_TREE_FOR(START, ELEM)
Macro to iterate via all sibling elements without affecting the list itself.
Definition: tree_schema.h:40
Description of the extension instance substatement.
Definition: tree_schema.h:435
YANG extension definition.
Definition: tree_schema.h:444
Generic extension instance structure.
Definition: tree_schema.h:464
union ly_set_set set
Definition: libyang.h:1711
Structure to hold a set of (not necessary somehow connected) lyd_node or lys_node objects....
Definition: libyang.h:1708
struct lys_module * module
Definition: tree_schema.h:1225
uint8_t unique_size
Definition: tree_schema.h:1464
uint16_t flags
Definition: tree_schema.h:1213
const char ** dflt
Definition: tree_schema.h:1438
uint8_t value_flags
Definition: tree_schema.h:975
struct lys_type_info_lref lref
Definition: tree_schema.h:965
struct lys_node * parent
Definition: tree_schema.h:1228
struct lys_type_info_union uni
Definition: tree_schema.h:967
struct lys_node * prev
Definition: tree_schema.h:1234
struct lys_type_info_num num
Definition: tree_schema.h:964
struct lys_type_info_ident ident
Definition: tree_schema.h:962
struct lys_refine_mod_list list
Definition: tree_schema.h:1868
struct lys_type_info_dec64 dec64
Definition: tree_schema.h:960
struct lys_tpdf * tpdf
Definition: tree_schema.h:1290
struct lys_when * when
Definition: tree_schema.h:1288
uint8_t ext_size
Definition: tree_schema.h:1214
struct lys_type * type
Definition: tree_schema.h:1933
struct lys_ext_instance ** ext
Definition: tree_schema.h:1223
struct lys_node_leaf * target
Definition: tree_schema.h:917
struct lys_refine * refine
Definition: tree_schema.h:1590
uint16_t target_type
Definition: tree_schema.h:1884
struct lys_node * child
Definition: tree_schema.h:1229
struct lys_type_info_str str
Definition: tree_schema.h:966
struct lys_restr * patterns
Definition: tree_schema.h:930
struct lys_restr * length
Definition: tree_schema.h:813
uint8_t iffeature_size
Definition: tree_schema.h:1215
union lys_type_info info
Definition: tree_schema.h:982
struct lys_unique * unique
Definition: tree_schema.h:1490
struct lys_tpdf * parent
Definition: tree_schema.h:980
struct lys_type_info_enums enums
Definition: tree_schema.h:961
struct lys_iffeature * iffeature
Definition: tree_schema.h:1224
struct lys_node * next
Definition: tree_schema.h:1233
struct lys_type_info_inst inst
Definition: tree_schema.h:963
LY_DATA_TYPE _PACKED base
Definition: tree_schema.h:974
union lys_refine_mod mod
Definition: tree_schema.h:1899
struct lys_type type
Definition: tree_schema.h:1433
const char * ref
Definition: tree_schema.h:1212
struct lys_restr * range
Definition: tree_schema.h:848
struct lys_type_info_binary binary
Definition: tree_schema.h:958
struct lys_node * dflt
Definition: tree_schema.h:1331
struct lys_type_info_bits bits
Definition: tree_schema.h:959
struct ly_ctx * ctx
Definition: tree_schema.h:667
struct lys_restr * must
Definition: tree_schema.h:1289
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.
LY_DATA_TYPE
YANG built-in types.
Definition: tree_schema.h:784
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.
char * lys_path(const struct lys_node *node, int options)
Build schema path (usable as path, see XPath Addressing) of the schema node.
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...
lyxp_node_type
Types of context nodes, LYXP_NODE_ROOT_CONFIG used only in when or must conditions.
Definition: tree_schema.h:2317
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,...
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,...
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...
LYS_OUTFORMAT
Schema output formats accepted by libyang printer functions.
Definition: tree_schema.h:196
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....
int lys_iffeature_value(const struct lys_iffeature *iff)
Learn how the if-feature statement currently evaluates.
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...
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.
@ LY_TYPE_STRING
Definition: tree_schema.h:795
@ LY_TYPE_BITS
Definition: tree_schema.h:787
@ LY_TYPE_IDENT
Definition: tree_schema.h:792
@ LY_TYPE_LEAFREF
Definition: tree_schema.h:794
@ LY_TYPE_UNION
Definition: tree_schema.h:796
@ LY_TYPE_ENUM
Definition: tree_schema.h:791
@ LY_TYPE_INST
Definition: tree_schema.h:793
@ LY_TYPE_BINARY
Definition: tree_schema.h:786
@ LY_TYPE_INT8
Definition: tree_schema.h:797
@ LY_TYPE_UINT64
Definition: tree_schema.h:804
@ LY_TYPE_DEC64
Definition: tree_schema.h:789
@ LYS_CONTAINER
Definition: tree_schema.h:231
YANG deviate statement structure, see RFC 6020 sec. 7.18.3.2
Definition: tree_schema.h:1916
YANG deviation statement structure, see RFC 6020 sec. 7.18.3
Definition: tree_schema.h:1943
YANG feature definition structure.
Definition: tree_schema.h:2029
Structure to hold information about identity, see RFC 6020 sec. 7.16
Definition: tree_schema.h:2080
Compiled if-feature expression structure.
Definition: tree_schema.h:1070
YANG import structure used to reference other schemas (modules).
Definition: tree_schema.h:1959
YANG include structure used to reference submodules.
Definition: tree_schema.h:1972
Main schema node structure representing YANG module.
Definition: tree_schema.h:666
Common structure representing single YANG data statement describing.
Definition: tree_schema.h:1209
Schema anydata (and anyxml) node structure.
Definition: tree_schema.h:1511
YANG augment structure (covering both possibilities - uses's substatement as well as (sub)module's su...
Definition: tree_schema.h:1823
Schema case node structure.
Definition: tree_schema.h:1645
Schema choice node structure.
Definition: tree_schema.h:1303
Schema container node structure.
Definition: tree_schema.h:1255
Schema grouping node structure.
Definition: tree_schema.h:1606
RPC input and output node structure.
Definition: tree_schema.h:1690
Schema leaf node structure.
Definition: tree_schema.h:1345
Schema leaf-list node structure.
Definition: tree_schema.h:1396
Schema list node structure.
Definition: tree_schema.h:1452
Schema notification node structure.
Definition: tree_schema.h:1728
Schema rpc/action node structure.
Definition: tree_schema.h:1775
Schema uses node structure.
Definition: tree_schema.h:1559
YANG uses's refine substatement structure, see RFC 6020 sec. 7.12.2
Definition: tree_schema.h:1875
Container for list modifications in lys_refine_mod.
Definition: tree_schema.h:1858
YANG validity restriction (must, length, etc.) structure providing information from the schema.
Definition: tree_schema.h:2050
YANG revision statement for (sub)modules.
Definition: tree_schema.h:1984
Submodule schema node structure that can be included into a YANG module.
Definition: tree_schema.h:729
YANG typedef structure providing information from the schema.
Definition: tree_schema.h:1995
YANG type structure providing information from the schema.
Definition: tree_schema.h:973
Single bit value specification for lys_type_info_bits.
Definition: tree_schema.h:820
Single enumeration value specification for lys_type_info_enums.
Definition: tree_schema.h:860
Container for information about bits types (LY_TYPE_BINARY), used in lys_type_info.
Definition: tree_schema.h:839
Container for information about decimal64 types (LY_TYPE_DEC64), used in lys_type_info.
Definition: tree_schema.h:847
Container for information about enumeration types (LY_TYPE_ENUM), used in lys_type_info.
Definition: tree_schema.h:879
Container for information about identity types (LY_TYPE_IDENT), used in lys_type_info.
Definition: tree_schema.h:887
Container for information about instance-identifier types (LY_TYPE_INST), used in lys_type_info.
Definition: tree_schema.h:895
Container for information about leafref types (LY_TYPE_LEAFREF), used in lys_type_info.
Definition: tree_schema.h:914
Container for information about integer types, used in lys_type_info.
Definition: tree_schema.h:906
Container for information about string types (LY_TYPE_STRING), used in lys_type_info.
Definition: tree_schema.h:927
Container for information about union types (LY_TYPE_UNION), used in lys_type_info.
Definition: tree_schema.h:947
YANG list's unique statement structure, see RFC 6020 sec. 7.8.3
Definition: tree_schema.h:2020
YANG when restriction, see RFC 6020 sec. 7.19.5
Definition: tree_schema.h:2066
Union to hold target modification in lys_refine.
Definition: tree_schema.h:1866
Union for holding type-specific information in lys_type.
Definition: tree_schema.h:957
The main libyang public header.
libyang representation of data model trees.
#define LY_TREE_DFS_END(START, NEXT, ELEM)
Definition: tree_schema.h:122