blob: da65d7c527ffff488d53708c598979c991a6de25 [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át19097f32020-10-05 10:08:29 +020038bool bits_::operator==(const bits_& other) const
39{
40 return this->m_bits == other.m_bits;
41}
42
43bool bits_::operator<(const bits_& other) const
44{
45 return this->m_bits < other.m_bits;
46}
47
Václav Kubernátab612e92019-11-26 19:51:31 +010048bool module_::operator<(const module_& b) const
49{
50 return this->m_name < b.m_name;
51}
52
Václav Kubernát7edb5372019-12-13 12:40:49 +010053bool identityRef_::operator==(const identityRef_& b) const
54{
55 return this->m_prefix == b.m_prefix && this->m_value == b.m_value;
56}
57
Václav Kubernátab612e92019-11-26 19:51:31 +010058bool identityRef_::operator<(const identityRef_& b) const
59{
60 return std::tie(this->m_prefix, this->m_value) < std::tie(b.m_prefix, b.m_value);
61}
62
Václav Kubernát7edb5372019-12-13 12:40:49 +010063bool binary_::operator==(const binary_& b) const
64{
65 return this->m_value == b.m_value;
66}
67
Václav Kubernátab612e92019-11-26 19:51:31 +010068bool binary_::operator<(const binary_& b) const
69{
70 return this->m_value < b.m_value;
71}
72
Jan Kundrát379bb572020-05-07 03:23:13 +020073bool empty_::operator==(const empty_) const
74{
75 return true;
76}
77
78bool empty_::operator<(const empty_) const
79{
80 return false;
81}
82
Václav Kubernát7edb5372019-12-13 12:40:49 +010083bool enum_::operator==(const enum_& b) const
84{
85 return this->m_value == b.m_value;
86}
87
Václav Kubernátab612e92019-11-26 19:51:31 +010088bool enum_::operator<(const enum_& b) const
89{
90 return this->m_value < b.m_value;
91}
92
Václav Kubernát144729d2020-01-08 15:20:35 +010093bool special_::operator==(const special_& b) const
94{
95 return this->m_value == b.m_value;
96}
97
Václav Kubernátab612e92019-11-26 19:51:31 +010098bool special_::operator<(const special_& b) const
99{
100 return this->m_value < b.m_value;
101}
102
Václav Kubernát144729d2020-01-08 15:20:35 +0100103std::string specialValueToString(const special_& value)
104{
105 switch (value.m_value) {
106 case SpecialValue::Container:
107 return "(container)";
108 case SpecialValue::PresenceContainer:
109 return "(presence container)";
110 case SpecialValue::List:
111 return "(list)";
Václav Kubernát5b8a8f32020-05-20 00:57:22 +0200112 case SpecialValue::LeafList:
113 return "(leaflist)";
Václav Kubernát144729d2020-01-08 15:20:35 +0100114 }
115
116 __builtin_unreachable();
117}