Types.hh

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_Types_hh__
00020 #define avro_Types_hh__
00021 
00022 #include <iostream>
00023 
00024 #include "Config.hh"
00025 
00026 namespace avro {
00027 
00031 enum Type {
00032 
00033     AVRO_STRING,    
00034     AVRO_BYTES,     
00035     AVRO_INT,       
00036     AVRO_LONG,      
00037     AVRO_FLOAT,     
00038     AVRO_DOUBLE,    
00039     AVRO_BOOL,      
00040     AVRO_NULL,      
00042     AVRO_RECORD,    
00043     AVRO_ENUM,      
00044     AVRO_ARRAY,     
00045     AVRO_MAP,       
00046     AVRO_UNION,     
00047     AVRO_FIXED,     
00049     AVRO_NUM_TYPES, 
00051     // The following is a pseudo-type used in implementation
00052     
00053     AVRO_SYMBOLIC = AVRO_NUM_TYPES, 
00054     AVRO_UNKNOWN  = -1 
00056 };
00057 
00063 inline bool isPrimitive(Type t) {
00064     return (t >= AVRO_STRING) && (t < AVRO_RECORD);
00065 }
00066 
00072 inline bool isCompound(Type t) {
00073     return (t>= AVRO_RECORD) && (t < AVRO_NUM_TYPES);
00074 }
00075 
00079 inline bool isAvroType(Type t) {
00080     return (t >= AVRO_STRING) && (t < AVRO_NUM_TYPES);
00081 }
00082 
00087 inline bool isAvroTypeOrPseudoType(Type t) {
00088     return (t >= AVRO_STRING) && (t <= AVRO_NUM_TYPES);
00089 }
00090 
00094 AVRO_DECL const std::string& toString(Type type);
00095 
00099 AVRO_DECL std::ostream &operator<< (std::ostream &os, avro::Type type);
00100 
00102 struct AVRO_DECL Null { };
00103 
00109 std::ostream& operator<< (std::ostream &os, const Null &null);
00110 
00111 } // namespace avro
00112 
00113 
00114 #endif