blob: fe6fe04e3098ea32d9773f23b743af4393881b63 [file] [log] [blame]
Václav Kubernát3a99f002020-03-31 02:27:41 +02001/*
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
10namespace yang {
Václav Kubernát13b23d72020-04-16 21:49:51 +020011bool TypeInfo::operator==(const TypeInfo& other) const
12{
13 return this->m_type == other.m_type && this->m_units == other.m_units;
14}
15TypeInfo::TypeInfo(const yang::LeafDataType& type, const std::optional<std::string> units)
16 : m_type(type)
17 , m_units(units)
18{
19}
Václav Kubernát3a99f002020-03-31 02:27:41 +020020Enum::Enum(std::set<enum_>&& values)
21 : m_allowedValues(std::move(values))
22{
23}
24bool Enum::operator==(const Enum& other) const
25{
26 return this->m_allowedValues == other.m_allowedValues;
27}
28IdentityRef::IdentityRef(std::set<identityRef_>&& values)
29 : m_allowedValues(std::move(values))
30{
31}
32bool 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
37LeafRef::LeafRef(const LeafRef& src)
38 : m_targetXPath(src.m_targetXPath)
Václav Kubernát13b23d72020-04-16 21:49:51 +020039 , m_targetType(std::make_unique<TypeInfo>(*src.m_targetType))
Václav Kubernát3a99f002020-03-31 02:27:41 +020040{
41}
Václav Kubernát13b23d72020-04-16 21:49:51 +020042LeafRef::LeafRef(const std::string& xpath, std::unique_ptr<TypeInfo>&& type)
Václav Kubernát3a99f002020-03-31 02:27:41 +020043 : m_targetXPath(xpath)
44 , m_targetType(std::move(type))
45{
46}
47bool 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át2984f442020-02-20 17:43:35 +010051bool Union::operator==(const Union& other) const
52{
53 return this->m_unionTypes == other.m_unionTypes;
54}
Václav Kubernát3a99f002020-03-31 02:27:41 +020055bool String::operator==(const String&) const
56{
57 return true;
58}
59bool Decimal::operator==(const Decimal&) const
60{
61 return true;
62}
63bool Bool::operator==(const Bool&) const
64{
65 return true;
66}
67bool Int8::operator==(const Int8&) const
68{
69 return true;
70}
71bool Uint8::operator==(const Uint8&) const
72{
73 return true;
74}
75bool Int16::operator==(const Int16&) const
76{
77 return true;
78}
79bool Uint16::operator==(const Uint16&) const
80{
81 return true;
82}
83bool Int32::operator==(const Int32&) const
84{
85 return true;
86}
87bool Uint32::operator==(const Uint32&) const
88{
89 return true;
90}
91bool Int64::operator==(const Int64&) const
92{
93 return true;
94}
95bool Uint64::operator==(const Uint64&) const
96{
97 return true;
98}
99bool Binary::operator==(const Binary&) const
100{
101 return true;
102}
Jan Kundrát379bb572020-05-07 03:23:13 +0200103bool Empty::operator==(const Empty&) const
104{
105 return true;
106}
Václav Kubernátdab73ca2020-10-26 23:44:43 +0100107bool Bits::operator==(const Bits& other) const
108{
109 return this->m_allowedValues == other.m_allowedValues;
110}
Václav Kubernát3a99f002020-03-31 02:27:41 +0200111}