Avro C++
Schema.hh
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * https://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef avro_Schema_hh__
20 #define avro_Schema_hh__
21 
22 #include "Config.hh"
23 #include "NodeImpl.hh"
24 #include <string>
25 
31 
32 namespace avro {
33 
35 
36 class AVRO_DECL Schema {
37 public:
38  virtual ~Schema() = default;
39 
40  Type type() const {
41  return node_->type();
42  }
43 
44  const NodePtr &root() const {
45  return node_;
46  }
47 
48  NodePtr &root() {
49  return node_;
50  }
51 
52 protected:
53  explicit Schema(NodePtr node) : node_(std::move(node)) {}
54  explicit Schema(Node *node) : node_(node) {}
55 
56  NodePtr node_;
57 };
58 
59 class AVRO_DECL NullSchema : public Schema {
60 public:
62 };
63 
64 class AVRO_DECL BoolSchema : public Schema {
65 public:
67 };
68 
69 class AVRO_DECL IntSchema : public Schema {
70 public:
72 };
73 
74 class AVRO_DECL LongSchema : public Schema {
75 public:
77 };
78 
79 class AVRO_DECL FloatSchema : public Schema {
80 public:
82 };
83 
84 class AVRO_DECL DoubleSchema : public Schema {
85 public:
87 };
88 
89 class AVRO_DECL StringSchema : public Schema {
90 public:
92 };
93 
94 class AVRO_DECL BytesSchema : public Schema {
95 public:
97 };
98 
99 class AVRO_DECL RecordSchema : public Schema {
100 public:
101  explicit RecordSchema(const std::string &name);
102  void addField(const std::string &name, const Schema &fieldSchema);
103 
104  std::string getDoc() const;
105  void setDoc(const std::string &);
106 };
107 
108 class AVRO_DECL EnumSchema : public Schema {
109 public:
110  explicit EnumSchema(const std::string &name);
111  void addSymbol(const std::string &symbol);
112 };
113 
114 class AVRO_DECL ArraySchema : public Schema {
115 public:
116  explicit ArraySchema(const Schema &itemsSchema);
117  ArraySchema(const ArraySchema &itemsSchema);
118 };
119 
120 class AVRO_DECL MapSchema : public Schema {
121 public:
122  explicit MapSchema(const Schema &valuesSchema);
123  MapSchema(const MapSchema &itemsSchema);
124 };
125 
126 class AVRO_DECL UnionSchema : public Schema {
127 public:
128  UnionSchema();
129  void addType(const Schema &typeSchema);
130 };
131 
132 class AVRO_DECL FixedSchema : public Schema {
133 public:
134  FixedSchema(int size, const std::string &name);
135 };
136 
137 class AVRO_DECL SymbolicSchema : public Schema {
138 public:
139  SymbolicSchema(const Name &name, const NodePtr &link);
140 };
141 } // namespace avro
142 
143 #endif
avro::AVRO_NULL
@ AVRO_NULL
Definition: Types.hh:40
avro::ArraySchema
Definition: Schema.hh:114
avro::UnionSchema
Definition: Schema.hh:126
avro::Node
Node is the building block for parse trees.
Definition: Node.hh:90
avro::AVRO_LONG
@ AVRO_LONG
Definition: Types.hh:36
avro::FixedSchema
Definition: Schema.hh:132
avro::StringSchema
Definition: Schema.hh:89
avro::AVRO_FLOAT
@ AVRO_FLOAT
Definition: Types.hh:37
avro::AVRO_BOOL
@ AVRO_BOOL
Definition: Types.hh:39
avro::NullSchema
Definition: Schema.hh:59
avro::AVRO_STRING
@ AVRO_STRING
Definition: Types.hh:33
avro::Name
Definition: Node.hh:41
avro::IntSchema
Definition: Schema.hh:69
avro::BoolSchema
Definition: Schema.hh:64
avro::AVRO_BYTES
@ AVRO_BYTES
Definition: Types.hh:34
avro::SymbolicSchema
Definition: Schema.hh:137
avro::RecordSchema
Definition: Schema.hh:99
avro::NodePrimitive
Definition: NodeImpl.hh:227
avro::AVRO_INT
@ AVRO_INT
Definition: Types.hh:35
avro
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
avro::DoubleSchema
Definition: Schema.hh:84
avro::AVRO_DOUBLE
@ AVRO_DOUBLE
Definition: Types.hh:38
avro::Schema
The root Schema object is a base class. Nobody constructs this class directly.
Definition: Schema.hh:36
avro::MapSchema
Definition: Schema.hh:120
avro::Type
Type
The "type" for the schema.
Definition: Types.hh:31
avro::FloatSchema
Definition: Schema.hh:79
avro::BytesSchema
Definition: Schema.hh:94
avro::EnumSchema
Definition: Schema.hh:108
avro::LongSchema
Definition: Schema.hh:74