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 | { |
| 13 | return this->m_type == other.m_type && this->m_units == other.m_units; |
| 14 | } |
| 15 | TypeInfo::TypeInfo(const yang::LeafDataType& type, const std::optional<std::string> units) |
| 16 | : m_type(type) |
| 17 | , m_units(units) |
| 18 | { |
| 19 | } |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 20 | Enum::Enum(std::set<enum_>&& values) |
| 21 | : m_allowedValues(std::move(values)) |
| 22 | { |
| 23 | } |
| 24 | bool Enum::operator==(const Enum& other) const |
| 25 | { |
| 26 | return this->m_allowedValues == other.m_allowedValues; |
| 27 | } |
| 28 | IdentityRef::IdentityRef(std::set<identityRef_>&& values) |
| 29 | : m_allowedValues(std::move(values)) |
| 30 | { |
| 31 | } |
| 32 | bool IdentityRef::operator==(const IdentityRef& other) const |
| 33 | { |
| 34 | return this->m_allowedValues == other.m_allowedValues; |
| 35 | } |
| 36 | // Copy constructor needed, because unique_ptr is not copy-constructible |
| 37 | LeafRef::LeafRef(const LeafRef& src) |
| 38 | : m_targetXPath(src.m_targetXPath) |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 39 | , m_targetType(std::make_unique<TypeInfo>(*src.m_targetType)) |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 40 | { |
| 41 | } |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 42 | 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] | 43 | : m_targetXPath(xpath) |
| 44 | , m_targetType(std::move(type)) |
| 45 | { |
| 46 | } |
| 47 | bool LeafRef::operator==(const LeafRef& other) const |
| 48 | { |
| 49 | return this->m_targetXPath == other.m_targetXPath && *this->m_targetType == *other.m_targetType; |
| 50 | } |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 51 | bool Union::operator==(const Union& other) const |
| 52 | { |
| 53 | return this->m_unionTypes == other.m_unionTypes; |
| 54 | } |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 55 | bool String::operator==(const String&) const |
| 56 | { |
| 57 | return true; |
| 58 | } |
| 59 | bool Decimal::operator==(const Decimal&) const |
| 60 | { |
| 61 | return true; |
| 62 | } |
| 63 | bool Bool::operator==(const Bool&) const |
| 64 | { |
| 65 | return true; |
| 66 | } |
| 67 | bool Int8::operator==(const Int8&) const |
| 68 | { |
| 69 | return true; |
| 70 | } |
| 71 | bool Uint8::operator==(const Uint8&) const |
| 72 | { |
| 73 | return true; |
| 74 | } |
| 75 | bool Int16::operator==(const Int16&) const |
| 76 | { |
| 77 | return true; |
| 78 | } |
| 79 | bool Uint16::operator==(const Uint16&) const |
| 80 | { |
| 81 | return true; |
| 82 | } |
| 83 | bool Int32::operator==(const Int32&) const |
| 84 | { |
| 85 | return true; |
| 86 | } |
| 87 | bool Uint32::operator==(const Uint32&) const |
| 88 | { |
| 89 | return true; |
| 90 | } |
| 91 | bool Int64::operator==(const Int64&) const |
| 92 | { |
| 93 | return true; |
| 94 | } |
| 95 | bool Uint64::operator==(const Uint64&) const |
| 96 | { |
| 97 | return true; |
| 98 | } |
| 99 | bool Binary::operator==(const Binary&) const |
| 100 | { |
| 101 | return true; |
| 102 | } |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 103 | bool Empty::operator==(const Empty&) const |
| 104 | { |
| 105 | return true; |
| 106 | } |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 107 | } |