AMQP and C++ types {#types_page}

An AMQP message body can hold binary data using any encoding you like. AMQP also defines its own encoding and types. The AMQP encoding is often used in message bodies because it is supported by AMQP libraries on many languages and platforms. You also need to use the AMQP types to set and examine message properties.

Scalar types

Each type is identified by a proton::type_id.

C++ typeAMQP type_idDescription
boolproton::BOOLEANBoolean true or false
uint8_tproton::UBYTE8-bit unsigned byte
int8_tproton::BYTE8-bit signed byte
uint16_tproton::USHORT16-bit unsigned integer
int16_tproton::SHORT16-bit signed integer
uint32_tproton::UINT32-bit unsigned integer
int32_tproton::INT32-bit signed integer
uint64_tproton::ULONG64-bit unsigned integer
int64_tproton::LONG64-bit signed integer
wchar_tproton::CHAR32-bit unicode code point
floatproton::FLOAT32-bit binary floating point
doubleproton::DOUBLE64-bit binary floating point
proton::timestampproton::TIMESTAMP64-bit signed milliseconds since 00:00:00 (UTC), 1 January 1970.
proton::decimal32proton::DECIMAL3232-bit decimal floating point
proton::decimal64proton::DECIMAL6464-bit decimal floating point
proton::decimal128proton::DECIMAL128128-bit decimal floating point
proton::uuidproton::UUID128-bit universally-unique identifier
std::stringproton::STRINGUTF-8 encoded Unicode string
proton::symbolproton::SYMBOL7-bit ASCII encoded string
proton::binaryproton::BINARYVariable-length binary data

proton::scalar is a holder that can accept a scalar value of any type.

Compound types

C++ typeAMQP type_idDescription
See belowproton::ARRAYSequence of values of the same type
See belowproton::LISTSequence of values of mixed types
See belowproton::MAPMap of key-value pairs

proton::value is a holder that can accept any AMQP value, scalar or compound.

proton::ARRAY converts to and from C++ sequences: std::vector, std::deque, std::list, and std::forward_list.

proton::LIST converts to and from sequences of proton::value or proton::scalar, which can hold mixed types of data.

proton::MAP converts to and from std::map, std::unordered_map, and sequences of std::pair.

When decoding, the encoded map types must be convertible to the element type of the C++ sequence or the key-value types of the C++ map. Use proton::value as the element or key-value type to decode any ARRAY, LIST, or MAP.

For example you can decode any AMQP MAP into:

std::map<proton::value, proton::value>

You can decode any AMQP LIST or ARRAY into:


Include files

You can simply include proton/types.hpp to get all the type definitions and conversions. Alternatively, you can selectively include only what you need:

  • Include proton/types_fwd.hpp: forward declarations for all types.
  • Include individual .hpp files as per the table above.