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 | |
| 29 | binary_::binary_() = default; |
| 30 | |
| 31 | binary_::binary_(const std::string& value) |
| 32 | : m_value(value) |
| 33 | { |
| 34 | } |
| 35 | |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 36 | empty_::empty_() = default; |
| 37 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 38 | bool module_::operator<(const module_& b) const |
| 39 | { |
| 40 | return this->m_name < b.m_name; |
| 41 | } |
| 42 | |
Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 43 | bool 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át | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 48 | bool 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át | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 53 | bool binary_::operator==(const binary_& b) const |
| 54 | { |
| 55 | return this->m_value == b.m_value; |
| 56 | } |
| 57 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 58 | bool binary_::operator<(const binary_& b) const |
| 59 | { |
| 60 | return this->m_value < b.m_value; |
| 61 | } |
| 62 | |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 63 | bool empty_::operator==(const empty_) const |
| 64 | { |
| 65 | return true; |
| 66 | } |
| 67 | |
| 68 | bool empty_::operator<(const empty_) const |
| 69 | { |
| 70 | return false; |
| 71 | } |
| 72 | |
Václav Kubernát | 7edb537 | 2019-12-13 12:40:49 +0100 | [diff] [blame] | 73 | bool enum_::operator==(const enum_& b) const |
| 74 | { |
| 75 | return this->m_value == b.m_value; |
| 76 | } |
| 77 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 78 | bool enum_::operator<(const enum_& b) const |
| 79 | { |
| 80 | return this->m_value < b.m_value; |
| 81 | } |
| 82 | |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 83 | bool special_::operator==(const special_& b) const |
| 84 | { |
| 85 | return this->m_value == b.m_value; |
| 86 | } |
| 87 | |
Václav Kubernát | ab612e9 | 2019-11-26 19:51:31 +0100 | [diff] [blame] | 88 | bool special_::operator<(const special_& b) const |
| 89 | { |
| 90 | return this->m_value < b.m_value; |
| 91 | } |
| 92 | |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 93 | std::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át | 5b8a8f3 | 2020-05-20 00:57:22 +0200 | [diff] [blame] | 102 | case SpecialValue::LeafList: |
| 103 | return "(leaflist)"; |
Václav Kubernát | 144729d | 2020-01-08 15:20:35 +0100 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | __builtin_unreachable(); |
| 107 | } |