blob: c3c30c99ba34f7bf5b93f0ffbf769802e4736103 [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>
Jan Kundrátcc5dbe22021-05-17 13:02:03 +020010#include <optional>
Václav Kubernát3a99f002020-03-31 02:27:41 +020011#include <set>
12#include <string>
13#include <variant>
Václav Kubernát2984f442020-02-20 17:43:35 +010014#include <vector>
Václav Kubernát3a99f002020-03-31 02:27:41 +020015
16struct enum_;
17struct identityRef_;
18
19namespace yang {
20struct String {
21 bool operator==(const String&) const;
22};
23struct Decimal {
24 bool operator==(const Decimal&) const;
25};
26struct Bool {
27 bool operator==(const Bool&) const;
28};
29struct Int8 {
30 bool operator==(const Int8&) const;
31};
32struct Uint8 {
33 bool operator==(const Uint8&) const;
34};
35struct Int16 {
36 bool operator==(const Int16&) const;
37};
38struct Uint16 {
39 bool operator==(const Uint16&) const;
40};
41struct Int32 {
42 bool operator==(const Int32&) const;
43};
44struct Uint32 {
45 bool operator==(const Uint32&) const;
46};
47struct Int64 {
48 bool operator==(const Int64&) const;
49};
50struct Uint64 {
51 bool operator==(const Uint64&) const;
52};
53struct Binary {
54 bool operator==(const Binary&) const;
55};
Jan Kundrát379bb572020-05-07 03:23:13 +020056struct Empty {
57 bool operator==(const Empty&) const;
58};
Václav Kubernát3a99f002020-03-31 02:27:41 +020059struct Enum {
60 Enum(std::set<enum_>&& values);
61 bool operator==(const Enum& other) const;
62 std::set<enum_> m_allowedValues;
63};
64struct IdentityRef {
65 IdentityRef(std::set<identityRef_>&& list);
66 bool operator==(const IdentityRef& other) const;
67 std::set<identityRef_> m_allowedValues;
68};
Václav Kubernátdab73ca2020-10-26 23:44:43 +010069struct Bits {
70 bool operator==(const Bits& other) const;
71 std::set<std::string> m_allowedValues;
72};
Václav Kubernát3a99f002020-03-31 02:27:41 +020073struct LeafRef;
Václav Kubernát2984f442020-02-20 17:43:35 +010074struct Union;
Václav Kubernát3a99f002020-03-31 02:27:41 +020075using LeafDataType = std::variant<
76 yang::String,
77 yang::Decimal,
78 yang::Bool,
79 yang::Int8,
80 yang::Uint8,
81 yang::Int16,
82 yang::Uint16,
83 yang::Int32,
84 yang::Uint32,
85 yang::Int64,
86 yang::Uint64,
87 yang::Enum,
88 yang::Binary,
Jan Kundrát379bb572020-05-07 03:23:13 +020089 yang::Empty,
Václav Kubernát3a99f002020-03-31 02:27:41 +020090 yang::IdentityRef,
Václav Kubernátdab73ca2020-10-26 23:44:43 +010091 yang::Bits,
Václav Kubernát2984f442020-02-20 17:43:35 +010092 yang::LeafRef,
93 yang::Union
Václav Kubernát3a99f002020-03-31 02:27:41 +020094>;
Václav Kubernát13b23d72020-04-16 21:49:51 +020095struct TypeInfo;
Václav Kubernát3a99f002020-03-31 02:27:41 +020096struct LeafRef {
97 LeafRef(const LeafRef& src);
Václav Kubernát13b23d72020-04-16 21:49:51 +020098 LeafRef(const std::string& xpath, std::unique_ptr<TypeInfo>&& type);
Václav Kubernát3a99f002020-03-31 02:27:41 +020099 bool operator==(const LeafRef& other) const;
100 std::string m_targetXPath;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200101 std::unique_ptr<TypeInfo> m_targetType;
Václav Kubernát3a99f002020-03-31 02:27:41 +0200102};
Václav Kubernát2984f442020-02-20 17:43:35 +0100103
104struct Union {
105 bool operator==(const Union& other) const;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200106 std::vector<TypeInfo> m_unionTypes;
107};
108struct TypeInfo {
Václav Kubernát1ae24f42020-12-01 02:32:04 +0100109 TypeInfo(const yang::LeafDataType& type,
110 const std::optional<std::string> units = std::nullopt,
111 const std::optional<std::string> description = std::nullopt);
Václav Kubernát13b23d72020-04-16 21:49:51 +0200112 bool operator==(const TypeInfo& other) const;
113 yang::LeafDataType m_type;
114 std::optional<std::string> m_units;
Václav Kubernát1ae24f42020-12-01 02:32:04 +0100115 std::optional<std::string> m_description;
Václav Kubernát2984f442020-02-20 17:43:35 +0100116};
Václav Kubernát3a99f002020-03-31 02:27:41 +0200117}