Go to the documentation of this file.
19 #ifndef avro_AvroTraits_hh__
20 #define avro_AvroTraits_hh__
25 #include <type_traits>
63 static yes &test(
char (*)[
sizeof(U)]) {
throw 0; }
66 static no &test(...) {
throw 0; }
68 static const bool value =
sizeof(test<T>(0)) ==
sizeof(yes);
85 static yes &test(
char (*)[
sizeof(U)]) {
throw 0; }
88 static no &test(...) {
throw 0; }
90 static const bool value =
sizeof(test<T>(0)) ==
sizeof(no);
93 #define DEFINE_PRIMITIVE(CTYPE, AVROTYPE) \
95 struct is_serializable<CTYPE> : public std::true_type {}; \
98 struct type_to_avro<CTYPE> { \
99 static const Type type = AVROTYPE; \
102 #define DEFINE_PROMOTABLE_PRIMITIVE(CTYPE, AVROTYPE) \
104 struct is_promotable<CTYPE> : public std::true_type {}; \
106 DEFINE_PRIMITIVE(CTYPE, AVROTYPE)
108 DEFINE_PROMOTABLE_PRIMITIVE(int32_t,
AVRO_INT)
109 DEFINE_PROMOTABLE_PRIMITIVE(int64_t,
AVRO_LONG)
110 DEFINE_PROMOTABLE_PRIMITIVE(
float,
AVRO_FLOAT)
115 DEFINE_PRIMITIVE(std::vector<uint8_t>,
AVRO_BYTES)
@ AVRO_NULL
Definition: Types.hh:40
Definition: AvroTraits.hh:44
@ AVRO_LONG
Definition: Types.hh:36
Define an is_serializable trait for types we can serialize natively.
Definition: AvroTraits.hh:38
Check if a T is a complete type i.e.
Definition: AvroTraits.hh:56
@ AVRO_FLOAT
Definition: Types.hh:37
@ AVRO_BOOL
Definition: Types.hh:39
@ AVRO_STRING
Definition: Types.hh:33
@ AVRO_NUM_TYPES
Definition: Types.hh:49
@ AVRO_BYTES
Definition: Types.hh:34
Similar to is_defined, but used to check if T is not defined.
Definition: AvroTraits.hh:78
@ AVRO_INT
Definition: Types.hh:35
A bunch of templates and specializations for encoding and decoding specific types.
Definition: AvroParse.hh:30
@ AVRO_DOUBLE
Definition: Types.hh:38
define a type to represent Avro Null in template functions
Definition: Types.hh:101
Type
The "type" for the schema.
Definition: Types.hh:31