blob: 288f76531d7b661a444b02dcb8688628afd10cc9 [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
8#pragma once
9#include <memory>
10#include <set>
11#include <string>
12#include <variant>
Václav Kubernát2984f442020-02-20 17:43:35 +010013#include <vector>
Václav Kubernát3a99f002020-03-31 02:27:41 +020014
15struct enum_;
16struct identityRef_;
17
18namespace yang {
19struct String {
20 bool operator==(const String&) const;
21};
22struct Decimal {
23 bool operator==(const Decimal&) const;
24};
25struct Bool {
26 bool operator==(const Bool&) const;
27};
28struct Int8 {
29 bool operator==(const Int8&) const;
30};
31struct Uint8 {
32 bool operator==(const Uint8&) const;
33};
34struct Int16 {
35 bool operator==(const Int16&) const;
36};
37struct Uint16 {
38 bool operator==(const Uint16&) const;
39};
40struct Int32 {
41 bool operator==(const Int32&) const;
42};
43struct Uint32 {
44 bool operator==(const Uint32&) const;
45};
46struct Int64 {
47 bool operator==(const Int64&) const;
48};
49struct Uint64 {
50 bool operator==(const Uint64&) const;
51};
52struct Binary {
53 bool operator==(const Binary&) const;
54};
Jan Kundrát379bb572020-05-07 03:23:13 +020055struct Empty {
56 bool operator==(const Empty&) const;
57};
Václav Kubernát3a99f002020-03-31 02:27:41 +020058struct Enum {
59 Enum(std::set<enum_>&& values);
60 bool operator==(const Enum& other) const;
61 std::set<enum_> m_allowedValues;
62};
63struct IdentityRef {
64 IdentityRef(std::set<identityRef_>&& list);
65 bool operator==(const IdentityRef& other) const;
66 std::set<identityRef_> m_allowedValues;
67};
68struct LeafRef;
Václav Kubernát2984f442020-02-20 17:43:35 +010069struct Union;
Václav Kubernát3a99f002020-03-31 02:27:41 +020070using LeafDataType = std::variant<
71 yang::String,
72 yang::Decimal,
73 yang::Bool,
74 yang::Int8,
75 yang::Uint8,
76 yang::Int16,
77 yang::Uint16,
78 yang::Int32,
79 yang::Uint32,
80 yang::Int64,
81 yang::Uint64,
82 yang::Enum,
83 yang::Binary,
Jan Kundrát379bb572020-05-07 03:23:13 +020084 yang::Empty,
Václav Kubernát3a99f002020-03-31 02:27:41 +020085 yang::IdentityRef,
Václav Kubernát2984f442020-02-20 17:43:35 +010086 yang::LeafRef,
87 yang::Union
Václav Kubernát3a99f002020-03-31 02:27:41 +020088>;
Václav Kubernát13b23d72020-04-16 21:49:51 +020089struct TypeInfo;
Václav Kubernát3a99f002020-03-31 02:27:41 +020090struct LeafRef {
91 LeafRef(const LeafRef& src);
Václav Kubernát13b23d72020-04-16 21:49:51 +020092 LeafRef(const std::string& xpath, std::unique_ptr<TypeInfo>&& type);
Václav Kubernát3a99f002020-03-31 02:27:41 +020093 bool operator==(const LeafRef& other) const;
94 std::string m_targetXPath;
Václav Kubernát13b23d72020-04-16 21:49:51 +020095 std::unique_ptr<TypeInfo> m_targetType;
Václav Kubernát3a99f002020-03-31 02:27:41 +020096};
Václav Kubernát2984f442020-02-20 17:43:35 +010097
98struct Union {
99 bool operator==(const Union& other) const;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200100 std::vector<TypeInfo> m_unionTypes;
101};
102struct TypeInfo {
103 TypeInfo(const yang::LeafDataType& type, const std::optional<std::string> units = std::nullopt);
104 bool operator==(const TypeInfo& other) const;
105 yang::LeafDataType m_type;
106 std::optional<std::string> m_units;
Václav Kubernát2984f442020-02-20 17:43:35 +0100107};
Václav Kubernát3a99f002020-03-31 02:27:41 +0200108}