1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#ifndef RFL_PARSING_SCHEMA_TYPE_HPP_
#define RFL_PARSING_SCHEMA_TYPE_HPP_
#include <cstddef>
#include <memory>
#include <string>
#include <vector>
#include "../../Object.hpp"
#include "../../Ref.hpp"
#include "../../Variant.hpp"
#include "ValidationType.hpp"
namespace rfl::parsing::schema {
struct Type {
struct Boolean {};
struct Bytestring {};
struct Int32 {};
struct Int64 {};
struct UInt32 {};
struct UInt64 {};
struct Integer {};
struct Float {};
struct Double {};
struct String {};
struct AnyOf {
std::vector<Type> types_;
};
struct Description {
std::string description_;
Ref<Type> type_;
};
struct FixedSizeTypedArray {
size_t size_;
Ref<Type> type_;
};
struct Literal {
std::vector<std::string> values_;
};
struct Object {
rfl::Object<Type> types_;
std::shared_ptr<Type> additional_properties_;
};
/// All values are assumed to be required unless explicitly stated otherwise
/// using this wrapper.
struct Optional {
Ref<Type> type_;
};
/// The is necessary to resolve circular definitions. Refers to something in
/// Definitions.
struct Reference {
std::string name_;
};
// A map with key type string.
struct StringMap {
Ref<Type> value_type_;
};
struct Tuple {
std::vector<Type> types_;
};
struct TypedArray {
Ref<Type> type_;
};
struct Validated {
Ref<Type> type_;
ValidationType validation_;
};
using VariantType =
rfl::Variant<Boolean, Bytestring, Int32, Int64, UInt32, UInt64, Integer,
Float, Double, String, AnyOf, Description,
FixedSizeTypedArray, Literal, Object, Optional, Reference,
StringMap, Tuple, TypedArray, Validated>;
Type();
Type(const VariantType& _variant);
~Type();
/// A type can be determined to be any of the above.
VariantType variant_;
};
} // namespace rfl::parsing::schema
#endif
|