Types.hh

00001 
00019 #ifndef avro_Types_hh__
00020 #define avro_Types_hh__
00021 
00022 #include <iostream>
00023 
00024 namespace avro {
00025 
00026 enum Type {
00027 
00028     AVRO_STRING,
00029     AVRO_BYTES,
00030     AVRO_INT,
00031     AVRO_LONG,
00032     AVRO_FLOAT,
00033     AVRO_DOUBLE,
00034     AVRO_BOOL,
00035     AVRO_NULL,
00036 
00037     AVRO_RECORD,
00038     AVRO_ENUM,
00039     AVRO_ARRAY,
00040     AVRO_MAP,
00041     AVRO_UNION,
00042     AVRO_FIXED,
00043 
00044     AVRO_NUM_TYPES, // marker
00045     
00046     // The following is a pseudo-type used in implementation
00047     
00048     AVRO_SYMBOLIC = AVRO_NUM_TYPES,
00049     AVRO_UNKNOWN  = -1
00050 
00051 };
00052 
00053 inline bool isPrimitive(Type t) {
00054     return (t >= AVRO_STRING) && (t < AVRO_RECORD);
00055 }
00056 
00057 inline bool isCompound(Type t) {
00058     return (t>= AVRO_RECORD) && (t < AVRO_NUM_TYPES);
00059 }
00060 
00061 inline bool isAvroType(Type t) {
00062     return (t >= AVRO_STRING) && (t < AVRO_NUM_TYPES);
00063 }
00064 
00065 inline bool isAvroTypeOrPseudoType(Type t) {
00066     return (t >= AVRO_STRING) && (t <= AVRO_NUM_TYPES);
00067 }
00068 
00069 
00070 const std::string& toString(Type type);
00071 
00072 std::ostream &operator<< (std::ostream &os, avro::Type type);
00073 
00075 struct Null { };
00076 
00077 std::ostream& operator<< (std::ostream &os, const Null &null);
00078 
00079 } // namespace avro
00080 
00081 
00082 #endif