blob: 35a2961d75289f506b14ab2f531523de730217a0 [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};
Václav Kubernátdab73ca2020-10-26 23:44:43 +010068struct Bits {
69 bool operator==(const Bits& other) const;
70 std::set<std::string> m_allowedValues;
71};
Václav Kubernát3a99f002020-03-31 02:27:41 +020072struct LeafRef;
Václav Kubernát2984f442020-02-20 17:43:35 +010073struct Union;
Václav Kubernát3a99f002020-03-31 02:27:41 +020074using LeafDataType = std::variant<
75 yang::String,
76 yang::Decimal,
77 yang::Bool,
78 yang::Int8,
79 yang::Uint8,
80 yang::Int16,
81 yang::Uint16,
82 yang::Int32,
83 yang::Uint32,
84 yang::Int64,
85 yang::Uint64,
86 yang::Enum,
87 yang::Binary,
Jan Kundrát379bb572020-05-07 03:23:13 +020088 yang::Empty,
Václav Kubernát3a99f002020-03-31 02:27:41 +020089 yang::IdentityRef,
Václav Kubernátdab73ca2020-10-26 23:44:43 +010090 yang::Bits,
Václav Kubernát2984f442020-02-20 17:43:35 +010091 yang::LeafRef,
92 yang::Union
Václav Kubernát3a99f002020-03-31 02:27:41 +020093>;
Václav Kubernát13b23d72020-04-16 21:49:51 +020094struct TypeInfo;
Václav Kubernát3a99f002020-03-31 02:27:41 +020095struct LeafRef {
96 LeafRef(const LeafRef& src);
Václav Kubernát13b23d72020-04-16 21:49:51 +020097 LeafRef(const std::string& xpath, std::unique_ptr<TypeInfo>&& type);
Václav Kubernát3a99f002020-03-31 02:27:41 +020098 bool operator==(const LeafRef& other) const;
99 std::string m_targetXPath;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200100 std::unique_ptr<TypeInfo> m_targetType;
Václav Kubernát3a99f002020-03-31 02:27:41 +0200101};
Václav Kubernát2984f442020-02-20 17:43:35 +0100102
103struct Union {
104 bool operator==(const Union& other) const;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200105 std::vector<TypeInfo> m_unionTypes;
106};
107struct TypeInfo {
Václav Kubernát1ae24f42020-12-01 02:32:04 +0100108 TypeInfo(const yang::LeafDataType& type,
109 const std::optional<std::string> units = std::nullopt,
110 const std::optional<std::string> description = std::nullopt);
Václav Kubernát13b23d72020-04-16 21:49:51 +0200111 bool operator==(const TypeInfo& other) const;
112 yang::LeafDataType m_type;
113 std::optional<std::string> m_units;
Václav Kubernát1ae24f42020-12-01 02:32:04 +0100114 std::optional<std::string> m_description;
Václav Kubernát2984f442020-02-20 17:43:35 +0100115};
Václav Kubernát3a99f002020-03-31 02:27:41 +0200116}