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