blob: 2cfcbf2e93d3bc25ad8548324d84f30b218ea4a3 [file] [log] [blame]
Václav Kubernát48fc3832018-05-28 14:21:22 +02001/*
2 * Copyright (C) 2018 CESNET, https://photonics.cesnet.cz/
3 * Copyright (C) 2018 FIT CVUT, https://fit.cvut.cz/
4 *
5 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
6 *
7*/
8
Václav Kubernát48fc3832018-05-28 14:21:22 +02009#include "schema.hpp"
Václav Kubernát48fc3832018-05-28 14:21:22 +020010
Václav Kubernátbddbb172018-06-13 16:27:39 +020011Schema::~Schema() = default;
Václav Kubernát2a141392020-02-18 17:12:32 +010012
13bool Schema::isList(const schemaPath_& location, const ModuleNodePair& node) const
14{
15 try {
16 return nodeType(location, node) == yang::NodeTypes::List;
17 } catch (InvalidNodeException&) {
18 return false;
19 }
20}
21
22bool Schema::isPresenceContainer(const schemaPath_& location, const ModuleNodePair& node) const
23{
24 try {
25 return nodeType(location, node) == yang::NodeTypes::PresenceContainer;
26 } catch (InvalidNodeException&) {
27 return false;
28 }
29}
30
31bool Schema::isContainer(const schemaPath_& location, const ModuleNodePair& node) const
32{
33 try {
34 auto type = nodeType(location, node);
35 return type == yang::NodeTypes::Container || type == yang::NodeTypes::PresenceContainer;
36 } catch (InvalidNodeException&) {
37 return false;
38 }
39}
40
41bool Schema::isLeaf(const schemaPath_& location, const ModuleNodePair& node) const
42{
43 try {
44 return nodeType(location, node) == yang::NodeTypes::Leaf;
45 } catch (InvalidNodeException&) {
46 return false;
47 }
48}