Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 9 | enum_::enum_() = default; |
| 10 | |
| 11 | enum_::enum_(const std::string& value) |
| 12 | : m_value(value) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | identityRef_::identityRef_() = default; |
| 17 | |
| 18 | identityRef_::identityRef_(const std::string& value) |
| 19 | : m_value(value) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | identityRef_::identityRef_(const std::string& module, const std::string& value) |
| 24 | : m_prefix(module_{module}) |
| 25 | , m_value(value) |
| 26 | { |
| 27 | } |
| 28 | |
Jan Kundrát | bb7aa85 | 2023-08-30 11:51:43 +0200 | [diff] [blame] | 29 | instanceIdentifier_::instanceIdentifier_(const std::string& xpath) |
| 30 | : m_xpath(xpath) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | bool instanceIdentifier_::operator==(const instanceIdentifier_& other) const |
| 35 | { |
| 36 | return this->m_xpath == other.m_xpath; |
| 37 | } |
| 38 | |
| 39 | bool instanceIdentifier_::operator<(const instanceIdentifier_& other) const |
| 40 | { |
| 41 | return this->m_xpath < other.m_xpath; |
| 42 | } |
| 43 | |
Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 44 | binary_::binary_() = default; |
| 45 | |
| 46 | binary_::binary_(const std::string& value) |
| 47 | : m_value(value) |
| 48 | { |
| 49 | } |
| 50 | |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 51 | empty_::empty_() = default; |
| 52 | |
Václav Kubernát | 19097f3 | 2020-10-05 10:08:29 +0200 | [diff] [blame] | 53 | bool bits_::operator==(const bits_& other) const |
| 54 | { |
| 55 | return this->m_bits == other.m_bits; |
| 56 | } |
| 57 | |
| 58 | bool bits_::operator<(const bits_& other) const |
| 59 | { |
| 60 | return this->m_bits < other.m_bits; |
| 61 | } |
| 62 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 63 | bool module_::operator<(const module_& b) const |
| 64 | { |
| 65 | return this->m_name < b.m_name; |
| 66 | } |
| 67 | |
Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 68 | bool 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át | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 73 | bool 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át | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 78 | bool binary_::operator==(const binary_& b) const |
| 79 | { |
| 80 | return this->m_value == b.m_value; |
| 81 | } |
| 82 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 83 | bool binary_::operator<(const binary_& b) const |
| 84 | { |
| 85 | return this->m_value < b.m_value; |
| 86 | } |
| 87 | |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 88 | bool empty_::operator==(const empty_) const |
| 89 | { |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | bool empty_::operator<(const empty_) const |
| 94 | { |
| 95 | return false; |
| 96 | } |
| 97 | |
Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 98 | bool enum_::operator==(const enum_& b) const |
| 99 | { |
| 100 | return this->m_value == b.m_value; |
| 101 | } |
| 102 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 103 | bool enum_::operator<(const enum_& b) const |
| 104 | { |
| 105 | return this->m_value < b.m_value; |
| 106 | } |
| 107 | |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 108 | bool special_::operator==(const special_& b) const |
| 109 | { |
| 110 | return this->m_value == b.m_value; |
| 111 | } |
| 112 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 113 | bool special_::operator<(const special_& b) const |
| 114 | { |
| 115 | return this->m_value < b.m_value; |
| 116 | } |
| 117 | |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 118 | std::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át | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 127 | case SpecialValue::LeafList: |
| 128 | return "(leaflist)"; |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | __builtin_unreachable(); |
| 132 | } |