1 #ifndef TYPE_TRAITS_HPP
2 #define TYPE_TRAITS_HPP
32 #include "proton/config.hpp"
39 template <
bool,
class T=
void>
struct enable_if {};
40 template <
class T>
struct enable_if<true, T> {
typedef T type; };
42 struct true_type {
static const bool value =
true; };
43 struct false_type {
static const bool value =
false; };
45 template <
class T>
struct is_integral :
public false_type {};
47 template <>
struct is_integral<unsigned char> :
public true_type {};
48 template <>
struct is_integral<unsigned short> :
public true_type {};
49 template <>
struct is_integral<unsigned int> :
public true_type {};
50 template <>
struct is_integral<unsigned long> :
public true_type {};
52 template <>
struct is_integral<signed char> :
public true_type {};
53 template <>
struct is_integral<signed short> :
public true_type {};
54 template <>
struct is_integral<signed int> :
public true_type {};
55 template <>
struct is_integral<signed long> :
public true_type {};
57 template <
class T>
struct is_signed :
public false_type {};
59 template <>
struct is_signed<unsigned char> :
public false_type {};
60 template <>
struct is_signed<unsigned short> :
public false_type {};
61 template <>
struct is_signed<unsigned int> :
public false_type {};
62 template <>
struct is_signed<unsigned long> :
public false_type {};
64 template <>
struct is_signed<signed char> :
public true_type {};
65 template <>
struct is_signed<signed short> :
public true_type {};
66 template <>
struct is_signed<signed int> :
public true_type {};
67 template <>
struct is_signed<signed long> :
public true_type {};
70 template <>
struct is_integral<unsigned long long> :
public true_type {};
71 template <>
struct is_integral<signed long long> :
public true_type {};
72 template <>
struct is_signed<unsigned long long> :
public false_type {};
73 template <>
struct is_signed<signed long long> :
public true_type {};
76 template <
class T,
class U>
struct is_same {
static const bool value=
false; };
77 template <
class T>
struct is_same<T,T> {
static const bool value=
true; };
80 template<
class T >
struct remove_const {
typedef T type; };
81 template<
class T >
struct remove_const<const T> {
typedef T type; };
84 template <
class T,
class Enable=
void>
struct type_id_of;
85 template<>
struct type_id_of<amqp_null> {
static const type_id value=NULL_TYPE; };
86 template<>
struct type_id_of<amqp_boolean> {
static const type_id value=BOOLEAN; };
87 template<>
struct type_id_of<amqp_ubyte> {
static const type_id value=UBYTE; };
88 template<>
struct type_id_of<amqp_byte> {
static const type_id value=BYTE; };
89 template<>
struct type_id_of<amqp_ushort> {
static const type_id value=USHORT; };
90 template<>
struct type_id_of<amqp_short> {
static const type_id value=SHORT; };
91 template<>
struct type_id_of<amqp_uint> {
static const type_id value=UINT; };
92 template<>
struct type_id_of<amqp_int> {
static const type_id value=INT; };
93 template<>
struct type_id_of<amqp_char> {
static const type_id value=CHAR; };
94 template<>
struct type_id_of<amqp_ulong> {
static const type_id value=ULONG; };
95 template<>
struct type_id_of<amqp_long> {
static const type_id value=LONG; };
96 template<>
struct type_id_of<amqp_timestamp> {
static const type_id value=TIMESTAMP; };
97 template<>
struct type_id_of<amqp_float> {
static const type_id value=FLOAT; };
98 template<>
struct type_id_of<amqp_double> {
static const type_id value=DOUBLE; };
99 template<>
struct type_id_of<amqp_decimal32> {
static const type_id value=DECIMAL32; };
100 template<>
struct type_id_of<amqp_decimal64> {
static const type_id value=DECIMAL64; };
101 template<>
struct type_id_of<amqp_decimal128> {
static const type_id value=DECIMAL128; };
102 template<>
struct type_id_of<amqp_uuid> {
static const type_id value=UUID; };
103 template<>
struct type_id_of<amqp_binary> {
static const type_id value=BINARY; };
104 template<>
struct type_id_of<amqp_string> {
static const type_id value=STRING; };
105 template<>
struct type_id_of<amqp_symbol> {
static const type_id value=SYMBOL; };
107 template <
class T,
class Enable=
void>
struct has_type_id :
public false_type {};
108 template <
class T>
struct has_type_id<T, typename enable_if<!!type_id_of<T>::value>::type> {
109 static const bool value =
true;
113 template<
size_t SIZE,
bool IS_SIGNED>
struct integer_type;
114 template<>
struct integer_type<1, true> {
typedef amqp_byte type; };
115 template<>
struct integer_type<2, true> {
typedef amqp_short type; };
116 template<>
struct integer_type<4, true> {
typedef amqp_int type; };
117 template<>
struct integer_type<8, true> {
typedef amqp_long type; };
118 template<>
struct integer_type<1, false> {
typedef amqp_ubyte type; };
119 template<>
struct integer_type<2, false> {
typedef amqp_ushort type; };
120 template<>
struct integer_type<4, false> {
typedef amqp_uint type; };
121 template<>
struct integer_type<8, false> {
typedef amqp_ulong type; };
124 template <
class T>
struct is_unknown_integer {
125 static const bool value = !has_type_id<T>::value && is_integral<T>::value;
132 #endif // TYPE_TRAITS_HPP
Defines C++ types representing AMQP types.