AvroTraits.hh
Go to the documentation of this file.00001
00019 #ifndef avro_AvroTraits_hh__
00020 #define avro_AvroTraits_hh__
00021
00022 #include "Boost.hh"
00023 #include "Types.hh"
00024
00029
00030 namespace avro {
00031
00032 template <typename T>
00033 struct is_serializable : public boost::false_type{};
00034
00035 template <typename T>
00036 struct is_promotable : public boost::false_type{};
00037
00038 template <typename T>
00039 struct type_to_avro {
00040 static const Type type = AVRO_NUM_TYPES;
00041 };
00042
00043 #define DEFINE_PRIMITIVE(CTYPE, AVROTYPE) \
00044 template <> \
00045 struct is_serializable<CTYPE> : public boost::true_type{}; \
00046 \
00047 template <> \
00048 struct type_to_avro<CTYPE> { \
00049 static const Type type = AVROTYPE; \
00050 };
00051
00052 #define DEFINE_PROMOTABLE_PRIMITIVE(CTYPE, AVROTYPE) \
00053 template <> \
00054 struct is_promotable<CTYPE> : public boost::true_type{}; \
00055 \
00056 DEFINE_PRIMITIVE(CTYPE, AVROTYPE)
00057
00058 DEFINE_PROMOTABLE_PRIMITIVE(int32_t, AVRO_INT)
00059 DEFINE_PROMOTABLE_PRIMITIVE(int64_t, AVRO_LONG)
00060 DEFINE_PROMOTABLE_PRIMITIVE(float, AVRO_FLOAT)
00061 DEFINE_PRIMITIVE(double, AVRO_DOUBLE)
00062 DEFINE_PRIMITIVE(bool, AVRO_BOOL)
00063 DEFINE_PRIMITIVE(Null, AVRO_NULL)
00064 DEFINE_PRIMITIVE(std::string, AVRO_STRING)
00065 DEFINE_PRIMITIVE(std::vector<uint8_t>, AVRO_BYTES)
00066
00067
00068 }
00069
00070 #endif