blob: b4ddff7423c71bbd23a24bf655e2a8a04051b92c [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Qpid Proton C++ API: AMQP and C++ types</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function() { init_search(); });
/* @license-end */
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Qpid Proton C++ API
&#160;<span id="projectnumber">0.32.0</span>
</div>
</td>
<td> <div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.svg"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('types_page.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">AMQP and C++ types </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="md__tmp_rgemmell_transom_qpid-proton-0"></a>.32.0_cpp_docs_types</p>
<p>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.</p>
<h1><a class="anchor" id="autotoc_md12"></a>
Scalar types</h1>
<p>Each type is identified by a <a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9" title="An identifier for AMQP types.">proton::type_id</a>.</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">C++ type </th><th class="markdownTableHeadNone">AMQP type_id </th><th class="markdownTableHeadNone">Description </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">bool </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a8a583f16e8d237a423c8c1d9087a4c72" title="Boolean true or false.">proton::BOOLEAN</a> </td><td class="markdownTableBodyNone">Boolean true or false </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">uint8_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a29dfb12306aac24cadeaa1f6bac455be" title="Unsigned 8-bit integer.">proton::UBYTE</a> </td><td class="markdownTableBodyNone">8-bit unsigned byte </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">int8_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9aa7f492d725033c06576ac4ba21007297" title="Signed 8-bit integer.">proton::BYTE</a> </td><td class="markdownTableBodyNone">8-bit signed byte </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">uint16_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a9ae509995ac75484348487a7477900ca" title="Unsigned 16-bit integer.">proton::USHORT</a> </td><td class="markdownTableBodyNone">16-bit unsigned integer </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">int16_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a7a1fe3ba88f0c16cb494922948a9597d" title="Signed 16-bit integer.">proton::SHORT</a> </td><td class="markdownTableBodyNone">16-bit signed integer </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">uint32_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a4756f5bbd9f28d6b8905f32024b57398" title="Unsigned 32-bit integer.">proton::UINT</a> </td><td class="markdownTableBodyNone">32-bit unsigned integer </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">int32_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9afd5a5f51ce25953f3db2c7e93eb7864a" title="Signed 32-bit integer.">proton::INT</a> </td><td class="markdownTableBodyNone">32-bit signed integer </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">uint64_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a574bf5ec73e28138b997d24464adb70c" title="Unsigned 64-bit integer.">proton::ULONG</a> </td><td class="markdownTableBodyNone">64-bit unsigned integer </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">int64_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9aaee055c4a5aba7d55774e4f1c01dacea" title="Signed 64-bit integer.">proton::LONG</a> </td><td class="markdownTableBodyNone">64-bit signed integer </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">wchar_t </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a4618cf21306b3c647741afa7ebefcab8" title="32-bit unicode character.">proton::CHAR</a> </td><td class="markdownTableBodyNone">32-bit unicode code point </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">float </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a9cf4a0866224b0bb4a7a895da27c9c4c" title="32-bit binary floating point.">proton::FLOAT</a> </td><td class="markdownTableBodyNone">32-bit binary floating point </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">double </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a33465d1d419b1074fb259ef444609e92" title="64-bit binary floating point.">proton::DOUBLE</a> </td><td class="markdownTableBodyNone">64-bit binary floating point </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><a class="el" href="classproton_1_1timestamp.html" title="A 64-bit timestamp in milliseconds since the Unix epoch.">proton::timestamp</a> </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a3f2dbbd8fe9ad35caa594416336ceeda" title="Signed 64-bit milliseconds since the epoch.">proton::TIMESTAMP</a> </td><td class="markdownTableBodyNone">64-bit signed milliseconds since 00:00:00 (UTC), 1 January 1970. </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><a class="el" href="classproton_1_1decimal32.html" title="A 32-bit decimal floating-point value.">proton::decimal32</a> </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a8df764f32f4aeba9ac8c7baccfd73388" title="32-bit decimal floating point.">proton::DECIMAL32</a> </td><td class="markdownTableBodyNone">32-bit decimal floating point </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><a class="el" href="classproton_1_1decimal64.html" title="A 64-bit decimal floating-point value.">proton::decimal64</a> </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a9a82428c8d08720e3134f1243496f7d6" title="64-bit decimal floating point.">proton::DECIMAL64</a> </td><td class="markdownTableBodyNone">64-bit decimal floating point </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><a class="el" href="classproton_1_1decimal128.html" title="A 128-bit decimal floating-point value.">proton::decimal128</a> </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9ac68fb86fda41e4314b0ee0d00e3d5170" title="128-bit decimal floating point.">proton::DECIMAL128</a> </td><td class="markdownTableBodyNone">128-bit decimal floating point </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><a class="el" href="classproton_1_1uuid.html" title="A 16-byte universally unique identifier.">proton::uuid</a> </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9aaf1ea4a849fa4bcb9d351a6bde6d7600" title="16-byte UUID.">proton::UUID</a> </td><td class="markdownTableBodyNone">128-bit universally-unique identifier </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">std::string </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9aee847e634a4297b274316de8a8ca9921" title="Variable-length utf8-encoded string.">proton::STRING</a> </td><td class="markdownTableBodyNone">UTF-8 encoded Unicode string </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone"><a class="el" href="classproton_1_1symbol.html" title="A string that represents the AMQP symbol type.">proton::symbol</a> </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9ae3d30ffaffa3c06ed917e565dda1fbc5" title="Variable-length encoded string.">proton::SYMBOL</a> </td><td class="markdownTableBodyNone">7-bit ASCII encoded string </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone"><a class="el" href="classproton_1_1binary.html" title="Arbitrary binary data.">proton::binary</a> </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9aecafbc1299672a8c1521cc0d5f1ae986" title="Variable-length sequence of bytes.">proton::BINARY</a> </td><td class="markdownTableBodyNone">Variable-length binary data </td></tr>
</table>
<h1><a class="anchor" id="autotoc_md13"></a>
Holder types</h1>
<p><code><a class="el" href="classproton_1_1message.html#a2b826744dc9d3d3d0988ffe05c81a41d" title="Get a reference to the body that can be modified in place.">proton::message::body()</a></code> and other message-related data can contain different types of data at runtime. There are two "holder" types provided to hold runtime typed data:</p>
<ul>
<li><code><a class="el" href="classproton_1_1scalar.html" title="A holder for an instance of any scalar AMQP type.">proton::scalar</a></code> can hold a scalar value of any type.</li>
<li><code><a class="el" href="classproton_1_1value.html" title="A holder for any AMQP value, simple or complex.">proton::value</a></code> can hold any AMQP value, scalar or compound.</li>
</ul>
<p>You can set the value in a holder by assignment, and use the <code><a class="el" href="namespaceproton.html#a61968283b9e1fc067dcad67e9fe58f6a" title="Get a contained value of type T.">proton::get()</a></code> and <code><a class="el" href="namespaceproton.html#ab73c44b530463fda5e11bc403ca9edd3" title="Get the binary value or throw conversion_error.">proton::coerce()</a></code> templates to extract data in a type-safe way. Holders also provide functions to query the type of value they contain.</p>
<h1><a class="anchor" id="autotoc_md14"></a>
Compound types</h1>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">C++ type </th><th class="markdownTableHeadNone">AMQP type_id </th><th class="markdownTableHeadNone">Description </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">See below </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a1e029fbf0c881b85d80fc8e89b753688" title="A sequence of values of the same type.">proton::ARRAY</a> </td><td class="markdownTableBodyNone">Sequence of values of the same type </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">See below </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a25688e799536738ea469158ef15fd1c0" title="A sequence of values of mixed types.">proton::LIST</a> </td><td class="markdownTableBodyNone">Sequence of values of mixed types </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">See below </td><td class="markdownTableBodyNone"><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a4cafa5feda04184537b4d7d346e1e89b" title="A sequence of key-value pairs.">proton::MAP</a> </td><td class="markdownTableBodyNone">Map of key-value pairs </td></tr>
</table>
<p>A <code><a class="el" href="classproton_1_1value.html" title="A holder for any AMQP value, simple or complex.">proton::value</a></code> containing a <code><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a1e029fbf0c881b85d80fc8e89b753688" title="A sequence of values of the same type.">proton::ARRAY</a></code> can convert to and from C++ sequences of the corresponding C++ type: <code>std::vector</code>, <code>std::deque</code>, <code>std::list</code>, and <code>std::forward_list</code>.</p>
<p><code><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a25688e799536738ea469158ef15fd1c0" title="A sequence of values of mixed types.">proton::LIST</a></code> converts to and from sequences of <code><a class="el" href="classproton_1_1value.html" title="A holder for any AMQP value, simple or complex.">proton::value</a></code> or <code><a class="el" href="classproton_1_1scalar.html" title="A holder for an instance of any scalar AMQP type.">proton::scalar</a></code>, which can hold mixed types of data.</p>
<p><code><a class="el" href="namespaceproton.html#a83c2656d467d69eb49725c18f5aa13a9a4cafa5feda04184537b4d7d346e1e89b" title="A sequence of key-value pairs.">proton::MAP</a></code> converts to and from <code>std::map</code>, <code>std::unordered_map</code>, and sequences of <code>std::pair</code>.</p>
<p>For example, you can decode a message body with any AMQP map as follows. </p><pre class="fragment">proton::message m = ...;
std::map&lt;proton::value, proton::value&gt; map;
proton::get(m.body(), map);
</pre><p>You can encode a message body with a map of string keys and <code>uint64_t</code> values like this: </p><pre class="fragment">std::unordered_map&lt;std::string, uint64_t&gt; map;
map["foo"] = 123;
m.body() = map;
</pre><h1><a class="anchor" id="autotoc_md15"></a>
Include files</h1>
<p><code><a class="el" href="types_8hpp.html" title="Proton types used to represent AMQP types.">proton/types.hpp</a></code> includes all available type definitions and conversions. Alternatively, you can selectively include the <code>.hpp</code> files you want. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="footer">Generated by <a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20 </li>
</ul>
</div>
</body>
</html>