Avro C++
Schema.hh
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one
00003  * or more contributor license agreements.  See the NOTICE file
00004  * distributed with this work for additional information
00005  * regarding copyright ownership.  The ASF licenses this file
00006  * to you under the Apache License, Version 2.0 (the
00007  * "License"); you may not use this file except in compliance
00008  * with the License.  You may obtain a copy of the License at
00009  *
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 #ifndef avro_Schema_hh__ 
00020 #define avro_Schema_hh__ 
00021 
00022 #include "Config.hh"
00023 #include "NodeImpl.hh"
00024 
00030 
00031 namespace avro {
00032 
00033 
00035 
00036 class AVRO_DECL Schema {
00037 public:
00038 
00039     virtual ~Schema();
00040 
00041     Type type() const {
00042         return node_->type();
00043     }
00044 
00045     const NodePtr &root() const {
00046         return node_;
00047     }
00048 
00049     NodePtr &root() {
00050         return node_;
00051     }
00052 
00053   protected:
00054     Schema();
00055     explicit Schema(const NodePtr &node);
00056     explicit Schema(Node *node);
00057 
00058     NodePtr node_;
00059 };
00060 
00061 class AVRO_DECL NullSchema : public Schema {
00062 public:
00063     NullSchema(): Schema(new NodePrimitive(AVRO_NULL)) {}
00064 };
00065 
00066 class AVRO_DECL BoolSchema : public Schema {
00067 public:
00068     BoolSchema(): Schema(new NodePrimitive(AVRO_BOOL)) {}
00069 };
00070 
00071 class AVRO_DECL IntSchema : public Schema {
00072 public:
00073     IntSchema(): Schema(new NodePrimitive(AVRO_INT)) {}
00074 };
00075 
00076 class AVRO_DECL LongSchema : public Schema {
00077 public:
00078     LongSchema(): Schema(new NodePrimitive(AVRO_LONG)) {}
00079 };
00080 
00081 class AVRO_DECL FloatSchema : public Schema {
00082 public:
00083     FloatSchema(): Schema(new NodePrimitive(AVRO_FLOAT)) {}
00084 };
00085 
00086 class AVRO_DECL DoubleSchema : public Schema {
00087 public:
00088     DoubleSchema(): Schema(new NodePrimitive(AVRO_DOUBLE)) {}
00089 };
00090 
00091 class AVRO_DECL StringSchema : public Schema {
00092 public:
00093     StringSchema(): Schema(new NodePrimitive(AVRO_STRING)) {}
00094 };
00095 
00096 class AVRO_DECL BytesSchema : public Schema {
00097 public:
00098     BytesSchema(): Schema(new NodePrimitive(AVRO_BYTES)) {}
00099 };
00100 
00101 class AVRO_DECL RecordSchema : public Schema {
00102 public:
00103     RecordSchema(const std::string &name);
00104     void addField(const std::string &name, const Schema &fieldSchema);
00105 };
00106 
00107 class AVRO_DECL EnumSchema : public Schema {
00108 public:
00109     EnumSchema(const std::string &name);
00110     void addSymbol(const std::string &symbol);
00111 };
00112 
00113 class AVRO_DECL ArraySchema : public Schema {
00114 public:
00115     ArraySchema(const Schema &itemsSchema);
00116 };
00117 
00118 class AVRO_DECL MapSchema : public Schema {
00119 public:
00120     MapSchema(const Schema &valuesSchema);
00121 };
00122 
00123 class AVRO_DECL UnionSchema : public Schema {
00124 public:
00125     UnionSchema();
00126     void addType(const Schema &typeSchema);
00127 };
00128 
00129 class AVRO_DECL FixedSchema : public Schema {
00130 public:
00131     FixedSchema(int size, const std::string &name);
00132 };
00133 
00134 class AVRO_DECL SymbolicSchema : public Schema {
00135 public:
00136     SymbolicSchema(const Name& name, const NodePtr& link);
00137 };
00138 } // namespace avro
00139 
00140 #endif