blob: c3f2ce7471156d9d87cdad4a32aa3065e37e9bbd [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
29binary_::binary_() = default;
30
31binary_::binary_(const std::string& value)
32 : m_value(value)
33{
34}
35
Jan Kundrát379bb572020-05-07 03:23:13 +020036empty_::empty_() = default;
37
Václav Kubernátab612e92019-11-26 19:51:31 +010038bool module_::operator<(const module_& b) const
39{
40 return this->m_name < b.m_name;
41}
42
Václav Kubernát7edb5372019-12-13 12:40:49 +010043bool identityRef_::operator==(const identityRef_& b) const
44{
45 return this->m_prefix == b.m_prefix && this->m_value == b.m_value;
46}
47
Václav Kubernátab612e92019-11-26 19:51:31 +010048bool identityRef_::operator<(const identityRef_& b) const
49{
50 return std::tie(this->m_prefix, this->m_value) < std::tie(b.m_prefix, b.m_value);
51}
52
Václav Kubernát7edb5372019-12-13 12:40:49 +010053bool binary_::operator==(const binary_& b) const
54{
55 return this->m_value == b.m_value;
56}
57
Václav Kubernátab612e92019-11-26 19:51:31 +010058bool binary_::operator<(const binary_& b) const
59{
60 return this->m_value < b.m_value;
61}
62
Jan Kundrát379bb572020-05-07 03:23:13 +020063bool empty_::operator==(const empty_) const
64{
65 return true;
66}
67
68bool empty_::operator<(const empty_) const
69{
70 return false;
71}
72
Václav Kubernát7edb5372019-12-13 12:40:49 +010073bool enum_::operator==(const enum_& b) const
74{
75 return this->m_value == b.m_value;
76}
77
Václav Kubernátab612e92019-11-26 19:51:31 +010078bool enum_::operator<(const enum_& b) const
79{
80 return this->m_value < b.m_value;
81}
82
Václav Kubernát144729d2020-01-08 15:20:35 +010083bool special_::operator==(const special_& b) const
84{
85 return this->m_value == b.m_value;
86}
87
Václav Kubernátab612e92019-11-26 19:51:31 +010088bool special_::operator<(const special_& b) const
89{
90 return this->m_value < b.m_value;
91}
92
Václav Kubernát144729d2020-01-08 15:20:35 +010093std::string specialValueToString(const special_& value)
94{
95 switch (value.m_value) {
96 case SpecialValue::Container:
97 return "(container)";
98 case SpecialValue::PresenceContainer:
99 return "(presence container)";
100 case SpecialValue::List:
101 return "(list)";
Václav Kubernát5b8a8f32020-05-20 00:57:22 +0200102 case SpecialValue::LeafList:
103 return "(leaflist)";
Václav Kubernát144729d2020-01-08 15:20:35 +0100104 }
105
106 __builtin_unreachable();
107}