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 namespace avro {
00025 
00029 enum Type {
00030 
00031     AVRO_STRING,    
00032     AVRO_BYTES,     
00033     AVRO_INT,       
00034     AVRO_LONG,      
00035     AVRO_FLOAT,     
00036     AVRO_DOUBLE,    
00037     AVRO_BOOL,      
00038     AVRO_NULL,      
00040     AVRO_RECORD,    
00041     AVRO_ENUM,      
00042     AVRO_ARRAY,     
00043     AVRO_MAP,       
00044     AVRO_UNION,     
00045     AVRO_FIXED,     
00047     AVRO_NUM_TYPES, 
00049     // The following is a pseudo-type used in implementation
00050     
00051     AVRO_SYMBOLIC = AVRO_NUM_TYPES, 
00052     AVRO_UNKNOWN  = -1 
00054 };
00055 
00061 inline bool isPrimitive(Type t) {
00062     return (t >= AVRO_STRING) && (t < AVRO_RECORD);
00063 }
00064 
00070 inline bool isCompound(Type t) {
00071     return (t>= AVRO_RECORD) && (t < AVRO_NUM_TYPES);
00072 }
00073 
00077 inline bool isAvroType(Type t) {
00078     return (t >= AVRO_STRING) && (t < AVRO_NUM_TYPES);
00079 }
00080 
00085 inline bool isAvroTypeOrPseudoType(Type t) {
00086     return (t >= AVRO_STRING) && (t <= AVRO_NUM_TYPES);
00087 }
00088 
00092 const std::string& toString(Type type);
00093 
00097 std::ostream &operator<< (std::ostream &os, avro::Type type);
00098 
00100 struct Null { };
00101 
00107 std::ostream& operator<< (std::ostream &os, const Null &null);
00108 
00109 } // namespace avro
00110 
00111 
00112 #endif