-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathast_values.cpp
More file actions
132 lines (106 loc) · 2.54 KB
/
ast_values.cpp
File metadata and controls
132 lines (106 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright (C) 2019 CESNET, https://photonics.cesnet.cz/
*
* Written by Václav Kubernát <[email protected]>
*
*/
#include "ast_values.hpp"
enum_::enum_() = default;
enum_::enum_(const std::string& value)
: m_value(value)
{
}
identityRef_::identityRef_() = default;
identityRef_::identityRef_(const std::string& value)
: m_value(value)
{
}
identityRef_::identityRef_(const std::string& module, const std::string& value)
: m_prefix(module_{module})
, m_value(value)
{
}
instanceIdentifier_::instanceIdentifier_(const std::string& xpath)
: m_xpath(xpath)
{
}
bool instanceIdentifier_::operator==(const instanceIdentifier_& other) const
{
return this->m_xpath == other.m_xpath;
}
bool instanceIdentifier_::operator<(const instanceIdentifier_& other) const
{
return this->m_xpath < other.m_xpath;
}
binary_::binary_() = default;
binary_::binary_(const std::string& value)
: m_value(value)
{
}
empty_::empty_() = default;
bool bits_::operator==(const bits_& other) const
{
return this->m_bits == other.m_bits;
}
bool bits_::operator<(const bits_& other) const
{
return this->m_bits < other.m_bits;
}
bool module_::operator<(const module_& b) const
{
return this->m_name < b.m_name;
}
bool identityRef_::operator==(const identityRef_& b) const
{
return this->m_prefix == b.m_prefix && this->m_value == b.m_value;
}
bool identityRef_::operator<(const identityRef_& b) const
{
return std::tie(this->m_prefix, this->m_value) < std::tie(b.m_prefix, b.m_value);
}
bool binary_::operator==(const binary_& b) const
{
return this->m_value == b.m_value;
}
bool binary_::operator<(const binary_& b) const
{
return this->m_value < b.m_value;
}
bool empty_::operator==(const empty_) const
{
return true;
}
bool empty_::operator<(const empty_) const
{
return false;
}
bool enum_::operator==(const enum_& b) const
{
return this->m_value == b.m_value;
}
bool enum_::operator<(const enum_& b) const
{
return this->m_value < b.m_value;
}
bool special_::operator==(const special_& b) const
{
return this->m_value == b.m_value;
}
bool special_::operator<(const special_& b) const
{
return this->m_value < b.m_value;
}
std::string specialValueToString(const special_& value)
{
switch (value.m_value) {
case SpecialValue::Container:
return "(container)";
case SpecialValue::PresenceContainer:
return "(presence container)";
case SpecialValue::List:
return "(list)";
case SpecialValue::LeafList:
return "(leaflist)";
}
__builtin_unreachable();
}