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
00027
00028 #include "./internal/export.hpp"
00029
00030 #include <proton/codec.h>
00031
00032 #include <string>
00033
00034 namespace proton {
00035
00037 enum type_id {
00038 NULL_TYPE = PN_NULL,
00039 BOOLEAN = PN_BOOL,
00040 UBYTE = PN_UBYTE,
00041 BYTE = PN_BYTE,
00042 USHORT = PN_USHORT,
00043 SHORT = PN_SHORT,
00044 UINT = PN_UINT,
00045 INT = PN_INT,
00046 CHAR = PN_CHAR,
00047 ULONG = PN_ULONG,
00048 LONG = PN_LONG,
00049 TIMESTAMP = PN_TIMESTAMP,
00050 FLOAT = PN_FLOAT,
00051 DOUBLE = PN_DOUBLE,
00052 DECIMAL32 = PN_DECIMAL32,
00053 DECIMAL64 = PN_DECIMAL64,
00054 DECIMAL128 = PN_DECIMAL128,
00055 UUID = PN_UUID,
00056 BINARY = PN_BINARY,
00057 STRING = PN_STRING,
00058 SYMBOL = PN_SYMBOL,
00059 DESCRIBED = PN_DESCRIBED,
00060 ARRAY = PN_ARRAY,
00061 LIST = PN_LIST,
00062 MAP = PN_MAP
00063 };
00064
00066 PN_CPP_EXTERN std::string type_name(type_id);
00067
00069 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
00070
00073 PN_CPP_EXTERN void assert_type_equal(type_id want, type_id got);
00074
00077 inline bool type_id_is_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
00078 inline bool type_id_is_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
00079 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); }
00080 inline bool type_id_is_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
00081 inline bool type_id_is_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }
00082 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); }
00083 inline bool type_id_is_string_like(type_id t) { return t == BINARY || t == STRING || t == SYMBOL; }
00084 inline bool type_id_is_container(type_id t) { return t == LIST || t == MAP || t == ARRAY || t == DESCRIBED; }
00085
00086 inline bool type_id_is_null(type_id t) { return t == NULL_TYPE; }
00087
00088 inline bool type_id_is_scalar(type_id t) {
00089 return type_id_is_integral(t) ||
00090 type_id_is_floating_point(t) ||
00091 type_id_is_decimal(t) ||
00092 type_id_is_string_like(t) ||
00093 type_id_is_null(t) ||
00094 t == TIMESTAMP ||
00095 t == UUID;
00096 }
00097
00099
00100 }
00101
00102 #endif // PROTON_TYPE_ID_HPP