Václav Kubernát | 48fc383 | 2018-05-28 14:21:22 +0200 | [diff] [blame] | 1 | /* |
| 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át | 48fc383 | 2018-05-28 14:21:22 +0200 | [diff] [blame] | 9 | #include "schema.hpp" |
Václav Kubernát | 48fc383 | 2018-05-28 14:21:22 +0200 | [diff] [blame] | 10 | |
Václav Kubernát | bddbb17 | 2018-06-13 16:27:39 +0200 | [diff] [blame] | 11 | Schema::~Schema() = default; |
Václav Kubernát | 2a14139 | 2020-02-18 17:12:32 +0100 | [diff] [blame] | 12 | |
| 13 | bool 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 | |
| 22 | bool 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 | |
| 31 | bool 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 | |
| 41 | bool 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 | } |