Qpid Proton C++  0.17.0
type_id.hpp
Go to the documentation of this file.
1 #ifndef PROTON_TYPE_ID_HPP
2 #define PROTON_TYPE_ID_HPP
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
28 
29 #include "./internal/export.hpp"
30 
31 #include <proton/codec.h>
32 
33 #include <string>
34 
35 namespace proton {
36 
38 enum type_id {
39  NULL_TYPE = PN_NULL,
40  BOOLEAN = PN_BOOL,
41  UBYTE = PN_UBYTE,
42  BYTE = PN_BYTE,
43  USHORT = PN_USHORT,
44  SHORT = PN_SHORT,
45  UINT = PN_UINT,
46  INT = PN_INT,
47  CHAR = PN_CHAR,
48  ULONG = PN_ULONG,
49  LONG = PN_LONG,
50  TIMESTAMP = PN_TIMESTAMP,
51  FLOAT = PN_FLOAT,
52  DOUBLE = PN_DOUBLE,
53  DECIMAL32 = PN_DECIMAL32,
54  DECIMAL64 = PN_DECIMAL64,
55  DECIMAL128 = PN_DECIMAL128,
56  UUID = PN_UUID,
57  BINARY = PN_BINARY,
58  STRING = PN_STRING,
59  SYMBOL = PN_SYMBOL,
60  DESCRIBED = PN_DESCRIBED,
61  ARRAY = PN_ARRAY,
62  LIST = PN_LIST,
63  MAP = PN_MAP
64 };
65 
67 PN_CPP_EXTERN std::string type_name(type_id);
68 
70 PN_CPP_EXTERN std::ostream& operator<<(std::ostream&, type_id);
71 
74 PN_CPP_EXTERN void assert_type_equal(type_id want, type_id got);
75 
78 inline bool type_id_is_signed_int(type_id t) { return t == BYTE || t == SHORT || t == INT || t == LONG; }
79 inline bool type_id_is_unsigned_int(type_id t) { return t == UBYTE || t == USHORT || t == UINT || t == ULONG; }
80 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); }
81 inline bool type_id_is_floating_point(type_id t) { return t == FLOAT || t == DOUBLE; }
82 inline bool type_id_is_decimal(type_id t) { return t == DECIMAL32 || t == DECIMAL64 || t == DECIMAL128; }
83 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); }
84 inline bool type_id_is_string_like(type_id t) { return t == BINARY || t == STRING || t == SYMBOL; }
85 inline bool type_id_is_container(type_id t) { return t == LIST || t == MAP || t == ARRAY || t == DESCRIBED; }
86 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; }
87 inline bool type_id_is_null(type_id t) { return t == NULL_TYPE; }
89 
90 } // proton
91 
92 #endif // PROTON_TYPE_ID_HPP
std::ostream & operator<<(std::ostream &, const binary &)
Print a binary value.
16-byte UUID.
Definition: type_id.hpp:56
The null type, contains no data.
Definition: type_id.hpp:39
A descriptor and a value.
Definition: type_id.hpp:60
A sequence of values of the same type.
Definition: type_id.hpp:61
A sequence of key-value pairs.
Definition: type_id.hpp:63
Variable-length utf8-encoded string.
Definition: type_id.hpp:58
std::string type_name(type_id)
Get the name of the AMQP type.
Variable-length encoded string.
Definition: type_id.hpp:59
Signed 64-bit milliseconds since the epoch.
Definition: type_id.hpp:50
Variable-length sequence of bytes.
Definition: type_id.hpp:57
64-bit binary floating point.
Definition: type_id.hpp:52
32-bit decimal floating point.
Definition: type_id.hpp:53
Signed 8-bit integer.
Definition: type_id.hpp:42
Unsigned 8-bit integer.
Definition: type_id.hpp:41
Signed 64-bit integer.
Definition: type_id.hpp:49
Boolean true or false.
Definition: type_id.hpp:40
type_id
An identifier for AMQP types.
Definition: type_id.hpp:38
32-bit unicode character.
Definition: type_id.hpp:47
void assert_type_equal(type_id want, type_id got)
Throw a conversion_error if want != got with a message including the names of the types...
Unsigned 32-bit integer.
Definition: type_id.hpp:45
Unsigned 64-bit integer.
Definition: type_id.hpp:48
Signed 16-bit integer.
Definition: type_id.hpp:44
Signed 32-bit integer.
Definition: type_id.hpp:46
Unsigned 16-bit integer.
Definition: type_id.hpp:43
64-bit decimal floating point.
Definition: type_id.hpp:54
128-bit decimal floating point.
Definition: type_id.hpp:55
A sequence of values of mixed types.
Definition: type_id.hpp:62
The main Proton namespace.
Definition: annotation_key.hpp:30
32-bit binary floating point.
Definition: type_id.hpp:51