1#ifndef PROTON_INTERNAL_TYPE_TRAITS_HPP
2#define PROTON_INTERNAL_TYPE_TRAITS_HPP
30#include "../types_fwd.hpp"
31#include "../type_id.hpp"
33#include <proton/type_compat.h>
44struct type_id_unknown {
45 static constexpr bool has_id =
false;
48template <type_
id ID,
class T>
struct type_id_constant {
50 static constexpr type_id value = ID;
51 static constexpr bool has_id =
true;
56template <
class T>
struct type_id_of :
public type_id_unknown {};
57template<>
struct type_id_of<null> :
public type_id_constant<NULL_TYPE, null> {};
58template<>
struct type_id_of<decltype(nullptr)> :
public type_id_constant<NULL_TYPE, null> {};
59template<>
struct type_id_of<bool> :
public type_id_constant<BOOLEAN, bool> {};
60template<>
struct type_id_of<uint8_t> :
public type_id_constant<UBYTE, uint8_t> {};
61template<>
struct type_id_of<int8_t> :
public type_id_constant<BYTE, int8_t> {};
62template<>
struct type_id_of<uint16_t> :
public type_id_constant<USHORT, uint16_t> {};
63template<>
struct type_id_of<int16_t> :
public type_id_constant<SHORT, int16_t> {};
64template<>
struct type_id_of<uint32_t> :
public type_id_constant<UINT, uint32_t> {};
65template<>
struct type_id_of<int32_t> :
public type_id_constant<INT, int32_t> {};
66template<>
struct type_id_of<uint64_t> :
public type_id_constant<ULONG, uint64_t> {};
67template<>
struct type_id_of<int64_t> :
public type_id_constant<LONG, int64_t> {};
68template<>
struct type_id_of<wchar_t> :
public type_id_constant<CHAR, wchar_t> {};
69template<>
struct type_id_of<float> :
public type_id_constant<FLOAT, float> {};
70template<>
struct type_id_of<double> :
public type_id_constant<DOUBLE, double> {};
71template<>
struct type_id_of<timestamp> :
public type_id_constant<TIMESTAMP, timestamp> {};
72template<>
struct type_id_of<decimal32> :
public type_id_constant<DECIMAL32, decimal32> {};
73template<>
struct type_id_of<decimal64> :
public type_id_constant<DECIMAL64, decimal64> {};
74template<>
struct type_id_of<decimal128> :
public type_id_constant<DECIMAL128, decimal128> {};
75template<>
struct type_id_of<uuid> :
public type_id_constant<UUID, uuid> {};
76template<>
struct type_id_of<std::string> :
public type_id_constant<STRING, std::string> {};
77template<>
struct type_id_of<symbol> :
public type_id_constant<SYMBOL, symbol> {};
78template<>
struct type_id_of<binary> :
public type_id_constant<BINARY, binary> {};
82template <
class T>
struct has_type_id {
83 static constexpr bool value = type_id_of<T>::has_id;
100template<
size_t SIZE,
bool IS_SIGNED>
struct integer_type;
101template<>
struct integer_type<1, true> {
typedef int8_t type; };
102template<>
struct integer_type<2, true> {
typedef int16_t type; };
103template<>
struct integer_type<4, true> {
typedef int32_t type; };
104template<>
struct integer_type<8, true> {
typedef int64_t type; };
105template<>
struct integer_type<1, false> {
typedef uint8_t type; };
106template<>
struct integer_type<2, false> {
typedef uint16_t type; };
107template<>
struct integer_type<4, false> {
typedef uint32_t type; };
108template<>
struct integer_type<8, false> {
typedef uint64_t type; };
111template <
class T>
struct is_unknown_integer {
112 static constexpr bool value = !has_type_id<T>::value && std::is_integral<T>::value;
115template<class T, class = typename std::enable_if<is_unknown_integer<T>::value>::type>
116struct known_integer :
public integer_type<sizeof(T), std::is_signed<T>::value> {};
123 template <
typename T > any_t(T
const&);
The main Proton namespace.
Definition: annotation_key.hpp:33
type_id
An identifier for AMQP types.
Definition: type_id.hpp:37