File: Type.hpp

package info (click to toggle)
reflect-cpp 0.18.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 12,524 kB
  • sloc: cpp: 44,484; python: 131; makefile: 30; sh: 3
file content (97 lines) | stat: -rw-r--r-- 1,730 bytes parent folder | download | duplicates (2)
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
#ifndef RFL_AVRO_SCHEMA_TYPE_HPP_
#define RFL_AVRO_SCHEMA_TYPE_HPP_

#include <map>
#include <memory>
#include <optional>
#include <string>

#include "../../Literal.hpp"
#include "../../Object.hpp"
#include "../../Ref.hpp"
#include "../../Rename.hpp"
#include "../../Variant.hpp"

namespace rfl::avro::schema {

struct Type {
  struct Null {
    Literal<"null"> type;
  };

  struct Boolean {
    Literal<"boolean"> type;
  };

  struct Int {
    Literal<"int"> type;
  };

  struct Long {
    Literal<"long"> type;
  };

  struct Float {
    Literal<"float"> type;
  };

  struct Double {
    Literal<"float"> type;
  };

  struct Bytes {
    Literal<"bytes"> type;
  };

  struct String {
    Literal<"string"> type;
  };

  struct RecordField {
    std::string name;
    rfl::Ref<Type> type;
  };

  struct Record {
    Literal<"record"> type;
    std::string name;
    std::vector<RecordField> fields;
    std::optional<std::string> doc;
  };

  struct Enum {
    Literal<"enum"> type;
    std::string name;
    std::vector<std::string> symbols;
  };

  struct Array {
    Literal<"array"> type;
    rfl::Ref<Type> items;
    Rename<"default", std::vector<std::string>> default_;
  };

  struct Map {
    Literal<"map"> type;
    rfl::Ref<Type> values;
    Rename<"default", std::map<std::string, std::string>> default_;
  };

  struct Reference {
    std::string type;
  };

  using ReflectionType =
      rfl::Variant<Null, Boolean, Int, Long, Float, Double, Bytes, String,
                   Record, Enum, Array, Map, Reference, std::vector<Type>>;

  const auto& reflection() const { return value; }

  Type with_name(const std::string& _name) const;

  ReflectionType value;
};

}  // namespace rfl::avro::schema

#endif