00001 #ifndef PROTON_TYPE_ID_HPP
00002 #define PROTON_TYPE_ID_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00028
00029 #include "./internal/export.hpp"
00030
00031 #include <proton/codec.h>
00032
00033 #include <string>
00034
00035 namespace proton {
00036
00038 enum type_id {
00039 NULL_TYPE = PN_NULL,
00040 BOOLEAN = PN_BOOL,
00041 UBYTE = PN_UBYTE,
00042 BYTE = PN_BYTE,
00043 USHORT = PN_USHORT,
00044 SHORT = PN_SHORT,
00045 UINT = PN_UINT,
00046 INT = PN_INT,
00047 CHAR = PN_CHAR,
00048 ULONG = PN_ULONG,
00049 LONG = PN_LONG,
00050 TIMESTAMP = PN_TIMESTAMP,
00051 FLOAT = PN_FLOAT,
00052 DOUBLE = PN_DOUBLE,
00053 DECIMAL32 = PN_DECIMAL32,
00054 DECIMAL64 = PN_DECIMAL64,
00055 DECIMAL128 = PN_DECIMAL128,
00056 UUID = PN_UUID,
00057 BINARY = PN_BINARY,
00058 STRING = PN_STRING,
00059 SYMBOL = PN_SYMBOL,
00060 DESCRIBED = PN_DESCRIBED,
00061 ARRAY = PN_ARRAY,
00062 LIST = PN_LIST,
00063 MAP = PN_MAP
00064 };
00065
00067 PN_CPP_EXTERN std::string type_name(type_id);
00068
00070 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
00071
00074 PN_CPP_EXTERN void assert_type_equal(type_id want, type_id got);
00075
00078 inline bool type_id_is_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
00079 inline bool type_id_is_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
00080 inline bool type_id_is_integral(type_id t) { return t == BOOLEAN || t == CHAR || t == TIMESTAMP || type_id_is_unsigned_int(t) || type_id_is_signed_int(t); }
00081 inline bool type_id_is_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
00082 inline bool type_id_is_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }
00083 inline bool type_id_is_signed(type_id t) { return type_id_is_signed_int(t) || type_id_is_floating_point(t) || type_id_is_decimal(t); }
00084 inline bool type_id_is_string_like(type_id t) { return t == BINARY || t == STRING || t == SYMBOL; }
00085 inline bool type_id_is_container(type_id t) { return t == LIST || t == MAP || t == ARRAY || t == DESCRIBED; }
00086 inline bool type_id_is_scalar(type_id t) { return type_id_is_integral(t) || type_id_is_floating_point(t) || type_id_is_decimal(t) || type_id_is_string_like(t) || t == TIMESTAMP || t == UUID; }
00087 inline bool type_id_is_null(type_id t) { return t == NULL_TYPE; }
00089
00090 }
00091
00092 #endif // PROTON_TYPE_ID_HPP