19 #ifndef avro_AvroTraits_hh__ 20 #define avro_AvroTraits_hh__ 25 #include <type_traits> 62 template <
class U>
static yes& test(
char(*)[
sizeof(U)]) {
throw 0; };
64 template <
class U>
static no& test(...) {
throw 0; };
66 static const bool value =
sizeof(test<T>(0)) ==
sizeof(yes);
82 template <
class U>
static yes& test(
char(*)[
sizeof(U)]) {
throw 0; };
84 template <
class U>
static no& test(...) {
throw 0; };
86 static const bool value =
sizeof(test<T>(0)) ==
sizeof(no);
89 #define DEFINE_PRIMITIVE(CTYPE, AVROTYPE) \ 91 struct is_serializable<CTYPE> : public std::true_type{}; \ 94 struct type_to_avro<CTYPE> { \ 95 static const Type type = AVROTYPE; \ 98 #define DEFINE_PROMOTABLE_PRIMITIVE(CTYPE, AVROTYPE) \ 100 struct is_promotable<CTYPE> : public std::true_type{}; \ 102 DEFINE_PRIMITIVE(CTYPE, AVROTYPE) 104 DEFINE_PROMOTABLE_PRIMITIVE(int32_t,
AVRO_INT)
105 DEFINE_PROMOTABLE_PRIMITIVE(int64_t,
AVRO_LONG)
106 DEFINE_PROMOTABLE_PRIMITIVE(
float,
AVRO_FLOAT)
111 DEFINE_PRIMITIVE(std::vector<uint8_t>,
AVRO_BYTES)
Check if a T is a complete type i.e.
Definition: AvroTraits.hh:56
Type
The "type" for the schema.
Definition: Types.hh:31
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
define a type to identify Null in template functions
Definition: Types.hh:102
Similar to is_defined, but used to check if T is not defined.
Definition: AvroTraits.hh:76
Define an is_serializable trait for types we can serialize natively.
Definition: AvroTraits.hh:38
Definition: AvroTraits.hh:44