Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/ |
| 3 | * |
| 4 | * Written by Václav Kubernát <kubernat@cesnet.cz> |
| 5 | * |
| 6 | */ |
| 7 | #include "ast_values.hpp" |
| 8 | #include "leaf_data_type.hpp" |
| 9 | |
| 10 | namespace yang { |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 11 | bool TypeInfo::operator==(const TypeInfo& other) const |
| 12 | { |
Václav Kubernát | 1ae24f4 | 2020-12-01 02:32:04 +0100 | [diff] [blame] | 13 | return std::tie(this->m_type, this->m_units, this->m_description) == std::tie(other.m_type, other.m_units, other.m_description); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 14 | } |
Václav Kubernát | 1ae24f4 | 2020-12-01 02:32:04 +0100 | [diff] [blame] | 15 | TypeInfo::TypeInfo(const yang::LeafDataType& type, const std::optional<std::string> units, const std::optional<std::string> description) |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 16 | : m_type(type) |
| 17 | , m_units(units) |
Václav Kubernát | 1ae24f4 | 2020-12-01 02:32:04 +0100 | [diff] [blame] | 18 | , m_description(description) |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 19 | { |
| 20 | } |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 21 | Enum::Enum(std::set<enum_>&& values) |
| 22 | : m_allowedValues(std::move(values)) |
| 23 | { |
| 24 | } |
| 25 | bool Enum::operator==(const Enum& other) const |
| 26 | { |
| 27 | return this->m_allowedValues == other.m_allowedValues; |
| 28 | } |
| 29 | IdentityRef::IdentityRef(std::set<identityRef_>&& values) |
| 30 | : m_allowedValues(std::move(values)) |
| 31 | { |
| 32 | } |
| 33 | bool IdentityRef::operator==(const IdentityRef& other) const |
| 34 | { |
| 35 | return this->m_allowedValues == other.m_allowedValues; |
| 36 | } |
| 37 | // Copy constructor needed, because unique_ptr is not copy-constructible |
| 38 | LeafRef::LeafRef(const LeafRef& src) |
| 39 | : m_targetXPath(src.m_targetXPath) |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 40 | , m_targetType(std::make_unique<TypeInfo>(*src.m_targetType)) |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 41 | { |
| 42 | } |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 43 | LeafRef::LeafRef(const std::string& xpath, std::unique_ptr<TypeInfo>&& type) |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 44 | : m_targetXPath(xpath) |
| 45 | , m_targetType(std::move(type)) |
| 46 | { |
| 47 | } |
| 48 | bool LeafRef::operator==(const LeafRef& other) const |
| 49 | { |
| 50 | return this->m_targetXPath == other.m_targetXPath && *this->m_targetType == *other.m_targetType; |
| 51 | } |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 52 | bool Union::operator==(const Union& other) const |
| 53 | { |
| 54 | return this->m_unionTypes == other.m_unionTypes; |
| 55 | } |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 56 | bool String::operator==(const String&) const |
| 57 | { |
| 58 | return true; |
| 59 | } |
| 60 | bool Decimal::operator==(const Decimal&) const |
| 61 | { |
| 62 | return true; |
| 63 | } |
| 64 | bool Bool::operator==(const Bool&) const |
| 65 | { |
| 66 | return true; |
| 67 | } |
| 68 | bool Int8::operator==(const Int8&) const |
| 69 | { |
| 70 | return true; |
| 71 | } |
| 72 | bool Uint8::operator==(const Uint8&) const |
| 73 | { |
| 74 | return true; |
| 75 | } |
| 76 | bool Int16::operator==(const Int16&) const |
| 77 | { |
| 78 | return true; |
| 79 | } |
| 80 | bool Uint16::operator==(const Uint16&) const |
| 81 | { |
| 82 | return true; |
| 83 | } |
| 84 | bool Int32::operator==(const Int32&) const |
| 85 | { |
| 86 | return true; |
| 87 | } |
| 88 | bool Uint32::operator==(const Uint32&) const |
| 89 | { |
| 90 | return true; |
| 91 | } |
| 92 | bool Int64::operator==(const Int64&) const |
| 93 | { |
| 94 | return true; |
| 95 | } |
| 96 | bool Uint64::operator==(const Uint64&) const |
| 97 | { |
| 98 | return true; |
| 99 | } |
| 100 | bool Binary::operator==(const Binary&) const |
| 101 | { |
| 102 | return true; |
| 103 | } |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 104 | bool Empty::operator==(const Empty&) const |
| 105 | { |
| 106 | return true; |
| 107 | } |
Václav Kubernát | dab73ca | 2020-10-26 23:44:43 +0100 | [diff] [blame] | 108 | bool Bits::operator==(const Bits& other) const |
| 109 | { |
| 110 | return this->m_allowedValues == other.m_allowedValues; |
| 111 | } |
Jan Kundrát | bb7aa85 | 2023-08-30 11:51:43 +0200 | [diff] [blame] | 112 | InstanceIdentifier::InstanceIdentifier() |
| 113 | { |
| 114 | } |
| 115 | bool InstanceIdentifier::operator==(const InstanceIdentifier&) const |
| 116 | { |
| 117 | return true; |
| 118 | } |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 119 | } |