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 
34 
36 
37 class AVRO_DECL Schema {
38 public:
39 
40  virtual ~Schema();
41 
42  Type type() const {
43  return node_->type();
44  }
45 
46  const NodePtr &root() const {
47  return node_;
48  }
49 
50  NodePtr &root() {
51  return node_;
52  }
53 
54  protected:
55  Schema();
56  explicit Schema(const NodePtr &node);
57  explicit Schema(Node *node);
58 
59  NodePtr node_;
60 };
61 
62 class AVRO_DECL NullSchema : public Schema {
63 public:
65 };
66 
67 class AVRO_DECL BoolSchema : public Schema {
68 public:
70 };
71 
72 class AVRO_DECL IntSchema : public Schema {
73 public:
75 };
76 
77 class AVRO_DECL LongSchema : public Schema {
78 public:
80 };
81 
82 class AVRO_DECL FloatSchema : public Schema {
83 public:
85 };
86 
87 class AVRO_DECL DoubleSchema : public Schema {
88 public:
90 };
91 
92 class AVRO_DECL StringSchema : public Schema {
93 public:
95 };
96 
97 class AVRO_DECL BytesSchema : public Schema {
98 public:
100 };
101 
102 class AVRO_DECL RecordSchema : public Schema {
103 public:
104  RecordSchema(const std::string &name);
105  void addField(const std::string &name, const Schema &fieldSchema);
106 
107  std::string getDoc() const;
108  void setDoc(const std::string &);
109 };
110 
111 class AVRO_DECL EnumSchema : public Schema {
112 public:
113  EnumSchema(const std::string &name);
114  void addSymbol(const std::string &symbol);
115 };
116 
117 class AVRO_DECL ArraySchema : public Schema {
118 public:
119  ArraySchema(const Schema &itemsSchema);
120  ArraySchema(const ArraySchema &itemsSchema);
121 };
122 
123 class AVRO_DECL MapSchema : public Schema {
124 public:
125  MapSchema(const Schema &valuesSchema);
126  MapSchema(const MapSchema &itemsSchema);
127 };
128 
129 class AVRO_DECL UnionSchema : public Schema {
130 public:
131  UnionSchema();
132  void addType(const Schema &typeSchema);
133 };
134 
135 class AVRO_DECL FixedSchema : public Schema {
136 public:
137  FixedSchema(int size, const std::string &name);
138 };
139 
140 class AVRO_DECL SymbolicSchema : public Schema {
141 public:
142  SymbolicSchema(const Name& name, const NodePtr& link);
143 };
144 } // namespace avro
145 
146 #endif
Definition: Schema.hh:102
Node is the building block for parse trees.
Definition: Node.hh:89
Definition: Types.hh:37
Definition: Schema.hh:87
Definition: Node.hh:40
Definition: Schema.hh:82
Definition: Types.hh:40
Type
The "type" for the schema.
Definition: Types.hh:31
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
Definition: Schema.hh:135
The root Schema object is a base class. Nobody constructs this class directly.
Definition: Schema.hh:37
Definition: Types.hh:39
Definition: Types.hh:33
Definition: NodeImpl.hh:237
Definition: Schema.hh:72
Definition: Types.hh:35
Definition: Types.hh:34
Definition: Types.hh:38
Definition: Schema.hh:97
Definition: Schema.hh:67
Definition: Schema.hh:117
Definition: Schema.hh:111
Definition: Schema.hh:77
Definition: Schema.hh:92
Definition: Schema.hh:123
Definition: Schema.hh:62
Definition: Types.hh:36
Definition: Schema.hh:140
Definition: Schema.hh:129