Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 1 | /* |
| 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át | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 13 | #include <vector> |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 14 | |
| 15 | struct enum_; |
| 16 | struct identityRef_; |
| 17 | |
| 18 | namespace yang { |
| 19 | struct String { |
| 20 | bool operator==(const String&) const; |
| 21 | }; |
| 22 | struct Decimal { |
| 23 | bool operator==(const Decimal&) const; |
| 24 | }; |
| 25 | struct Bool { |
| 26 | bool operator==(const Bool&) const; |
| 27 | }; |
| 28 | struct Int8 { |
| 29 | bool operator==(const Int8&) const; |
| 30 | }; |
| 31 | struct Uint8 { |
| 32 | bool operator==(const Uint8&) const; |
| 33 | }; |
| 34 | struct Int16 { |
| 35 | bool operator==(const Int16&) const; |
| 36 | }; |
| 37 | struct Uint16 { |
| 38 | bool operator==(const Uint16&) const; |
| 39 | }; |
| 40 | struct Int32 { |
| 41 | bool operator==(const Int32&) const; |
| 42 | }; |
| 43 | struct Uint32 { |
| 44 | bool operator==(const Uint32&) const; |
| 45 | }; |
| 46 | struct Int64 { |
| 47 | bool operator==(const Int64&) const; |
| 48 | }; |
| 49 | struct Uint64 { |
| 50 | bool operator==(const Uint64&) const; |
| 51 | }; |
| 52 | struct Binary { |
| 53 | bool operator==(const Binary&) const; |
| 54 | }; |
Jan Kundrát | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 55 | struct Empty { |
| 56 | bool operator==(const Empty&) const; |
| 57 | }; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 58 | struct Enum { |
| 59 | Enum(std::set<enum_>&& values); |
| 60 | bool operator==(const Enum& other) const; |
| 61 | std::set<enum_> m_allowedValues; |
| 62 | }; |
| 63 | struct IdentityRef { |
| 64 | IdentityRef(std::set<identityRef_>&& list); |
| 65 | bool operator==(const IdentityRef& other) const; |
| 66 | std::set<identityRef_> m_allowedValues; |
| 67 | }; |
| 68 | struct LeafRef; |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 69 | struct Union; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 70 | using 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át | 379bb57 | 2020-05-07 03:23:13 +0200 | [diff] [blame] | 84 | yang::Empty, |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 85 | yang::IdentityRef, |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 86 | yang::LeafRef, |
| 87 | yang::Union |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 88 | >; |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 89 | struct TypeInfo; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 90 | struct LeafRef { |
| 91 | LeafRef(const LeafRef& src); |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 92 | LeafRef(const std::string& xpath, std::unique_ptr<TypeInfo>&& type); |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 93 | bool operator==(const LeafRef& other) const; |
| 94 | std::string m_targetXPath; |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 95 | std::unique_ptr<TypeInfo> m_targetType; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 96 | }; |
Václav Kubernát | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 97 | |
| 98 | struct Union { |
| 99 | bool operator==(const Union& other) const; |
Václav Kubernát | 13b23d7 | 2020-04-16 21:49:51 +0200 | [diff] [blame] | 100 | std::vector<TypeInfo> m_unionTypes; |
| 101 | }; |
| 102 | struct 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át | 2984f44 | 2020-02-20 17:43:35 +0100 | [diff] [blame] | 107 | }; |
Václav Kubernát | 3a99f00 | 2020-03-31 02:27:41 +0200 | [diff] [blame] | 108 | } |