blob: a7aa5fef54f028301fc40ea0acd5048c3084c23d [file] [log] [blame]
Václav Kubernát7edb5372019-12-13 12:40:49 +01001/*
2 * Copyright (C) 2019 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Václav Kubernát <kubervac@fit.cvut.cz>
5 *
6*/
7#include "ast_values.hpp"
8
9enum_::enum_() = default;
10
11enum_::enum_(const std::string& value)
12 : m_value(value)
13{
14}
15
16identityRef_::identityRef_() = default;
17
18identityRef_::identityRef_(const std::string& value)
19 : m_value(value)
20{
21}
22
23identityRef_::identityRef_(const std::string& module, const std::string& value)
24 : m_prefix(module_{module})
25 , m_value(value)
26{
27}
28
Jan Kundrátbb7aa852023-08-30 11:51:43 +020029instanceIdentifier_::instanceIdentifier_(const std::string& xpath)
30 : m_xpath(xpath)
31{
32}
33
34bool instanceIdentifier_::operator==(const instanceIdentifier_& other) const
35{
36 return this->m_xpath == other.m_xpath;
37}
38
39bool instanceIdentifier_::operator<(const instanceIdentifier_& other) const
40{
41 return this->m_xpath < other.m_xpath;
42}
43
Václav Kubernát7edb5372019-12-13 12:40:49 +010044binary_::binary_() = default;
45
46binary_::binary_(const std::string& value)
47 : m_value(value)
48{
49}
50
Jan Kundrát379bb572020-05-07 03:23:13 +020051empty_::empty_() = default;
52
Václav Kubernát19097f32020-10-05 10:08:29 +020053bool bits_::operator==(const bits_& other) const
54{
55 return this->m_bits == other.m_bits;
56}
57
58bool bits_::operator<(const bits_& other) const
59{
60 return this->m_bits < other.m_bits;
61}
62
Václav Kubernátab612e92019-11-26 19:51:31 +010063bool module_::operator<(const module_& b) const
64{
65 return this->m_name < b.m_name;
66}
67
Václav Kubernát7edb5372019-12-13 12:40:49 +010068bool identityRef_::operator==(const identityRef_& b) const
69{
70 return this->m_prefix == b.m_prefix && this->m_value == b.m_value;
71}
72
Václav Kubernátab612e92019-11-26 19:51:31 +010073bool identityRef_::operator<(const identityRef_& b) const
74{
75 return std::tie(this->m_prefix, this->m_value) < std::tie(b.m_prefix, b.m_value);
76}
77
Václav Kubernát7edb5372019-12-13 12:40:49 +010078bool binary_::operator==(const binary_& b) const
79{
80 return this->m_value == b.m_value;
81}
82
Václav Kubernátab612e92019-11-26 19:51:31 +010083bool binary_::operator<(const binary_& b) const
84{
85 return this->m_value < b.m_value;
86}
87
Jan Kundrát379bb572020-05-07 03:23:13 +020088bool empty_::operator==(const empty_) const
89{
90 return true;
91}
92
93bool empty_::operator<(const empty_) const
94{
95 return false;
96}
97
Václav Kubernát7edb5372019-12-13 12:40:49 +010098bool enum_::operator==(const enum_& b) const
99{
100 return this->m_value == b.m_value;
101}
102
Václav Kubernátab612e92019-11-26 19:51:31 +0100103bool enum_::operator<(const enum_& b) const
104{
105 return this->m_value < b.m_value;
106}
107
Václav Kubernát144729d2020-01-08 15:20:35 +0100108bool special_::operator==(const special_& b) const
109{
110 return this->m_value == b.m_value;
111}
112
Václav Kubernátab612e92019-11-26 19:51:31 +0100113bool special_::operator<(const special_& b) const
114{
115 return this->m_value < b.m_value;
116}
117
Václav Kubernát144729d2020-01-08 15:20:35 +0100118std::string specialValueToString(const special_& value)
119{
120 switch (value.m_value) {
121 case SpecialValue::Container:
122 return "(container)";
123 case SpecialValue::PresenceContainer:
124 return "(presence container)";
125 case SpecialValue::List:
126 return "(list)";
Václav Kubernát5b8a8f32020-05-20 00:57:22 +0200127 case SpecialValue::LeafList:
128 return "(leaflist)";
Václav Kubernát144729d2020-01-08 15:20:35 +0100129 }
130
131 __builtin_unreachable();
132}