blob: f1619ec4df3e9fbf1c8cc876741f248892faa2e7 [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;
Jan Kundrátbb7aa852023-08-30 11:51:43 +020074struct InstanceIdentifier {
75 InstanceIdentifier();
76 bool operator==(const InstanceIdentifier& other) const;
77};
Václav Kubernát2984f442020-02-20 17:43:35 +010078struct Union;
Václav Kubernát3a99f002020-03-31 02:27:41 +020079using LeafDataType = std::variant<
80 yang::String,
81 yang::Decimal,
82 yang::Bool,
83 yang::Int8,
84 yang::Uint8,
85 yang::Int16,
86 yang::Uint16,
87 yang::Int32,
88 yang::Uint32,
89 yang::Int64,
90 yang::Uint64,
91 yang::Enum,
92 yang::Binary,
Jan Kundrát379bb572020-05-07 03:23:13 +020093 yang::Empty,
Václav Kubernát3a99f002020-03-31 02:27:41 +020094 yang::IdentityRef,
Václav Kubernátdab73ca2020-10-26 23:44:43 +010095 yang::Bits,
Václav Kubernát2984f442020-02-20 17:43:35 +010096 yang::LeafRef,
Jan Kundrátbb7aa852023-08-30 11:51:43 +020097 yang::InstanceIdentifier,
Václav Kubernát2984f442020-02-20 17:43:35 +010098 yang::Union
Václav Kubernát3a99f002020-03-31 02:27:41 +020099>;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200100struct TypeInfo;
Václav Kubernát3a99f002020-03-31 02:27:41 +0200101struct LeafRef {
102 LeafRef(const LeafRef& src);
Václav Kubernát13b23d72020-04-16 21:49:51 +0200103 LeafRef(const std::string& xpath, std::unique_ptr<TypeInfo>&& type);
Václav Kubernát3a99f002020-03-31 02:27:41 +0200104 bool operator==(const LeafRef& other) const;
105 std::string m_targetXPath;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200106 std::unique_ptr<TypeInfo> m_targetType;
Václav Kubernát3a99f002020-03-31 02:27:41 +0200107};
Václav Kubernát2984f442020-02-20 17:43:35 +0100108
109struct Union {
110 bool operator==(const Union& other) const;
Václav Kubernát13b23d72020-04-16 21:49:51 +0200111 std::vector<TypeInfo> m_unionTypes;
112};
113struct TypeInfo {
Václav Kubernát1ae24f42020-12-01 02:32:04 +0100114 TypeInfo(const yang::LeafDataType& type,
115 const std::optional<std::string> units = std::nullopt,
116 const std::optional<std::string> description = std::nullopt);
Václav Kubernát13b23d72020-04-16 21:49:51 +0200117 bool operator==(const TypeInfo& other) const;
118 yang::LeafDataType m_type;
119 std::optional<std::string> m_units;
Václav Kubernát1ae24f42020-12-01 02:32:04 +0100120 std::optional<std::string> m_description;
Václav Kubernát2984f442020-02-20 17:43:35 +0100121};
Václav Kubernát3a99f002020-03-31 02:27:41 +0200122}