blob: 73841bb1e05a8cddeedc88de5b60716d63c61eb6 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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.6"/>
<title>TinyCBOR API: Encoding to CBOR</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="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 style="padding-left: 0.5em;">
<div id="projectname">TinyCBOR API
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#func-members">Functions</a> </div>
<div class="headertitle">
<div class="title">Encoding to CBOR</div> </div>
</div><!--header-->
<div class="contents">
<p>Group of functions used to encode data to CBOR.
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00001.html">CborEncoder</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Structure used to encode to CBOR. <a href="a00001.html#details">More...</a><br/></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga257051966d907f88af804f30f2e9d8e2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2">cbor_encoder_init</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, uint8_t *buffer, size_t size, int flags)</td></tr>
<tr class="memdesc:ga257051966d907f88af804f30f2e9d8e2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes a <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> structure <em>encoder</em> by pointing it to buffer <em>buffer</em> of size <em>size</em>. <a href="#ga257051966d907f88af804f30f2e9d8e2">More...</a><br/></td></tr>
<tr class="separator:ga257051966d907f88af804f30f2e9d8e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2b898ce6f5821c5aba8b6f0020c4b5ba"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga2b898ce6f5821c5aba8b6f0020c4b5ba">cbor_encode_uint</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, uint64_t value)</td></tr>
<tr class="memdesc:ga2b898ce6f5821c5aba8b6f0020c4b5ba"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the unsigned 64-bit integer <em>value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga2b898ce6f5821c5aba8b6f0020c4b5ba">More...</a><br/></td></tr>
<tr class="separator:ga2b898ce6f5821c5aba8b6f0020c4b5ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0e84daa854e0480f4a3758bcb46b9b60"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga0e84daa854e0480f4a3758bcb46b9b60">cbor_encode_negative_int</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, uint64_t absolute_value)</td></tr>
<tr class="memdesc:ga0e84daa854e0480f4a3758bcb46b9b60"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the negative 64-bit integer whose absolute value is <em>absolute_value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga0e84daa854e0480f4a3758bcb46b9b60">More...</a><br/></td></tr>
<tr class="separator:ga0e84daa854e0480f4a3758bcb46b9b60"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabbf6e10fd963d673f5ad293dff4a67a9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gabbf6e10fd963d673f5ad293dff4a67a9">cbor_encode_int</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, int64_t value)</td></tr>
<tr class="memdesc:gabbf6e10fd963d673f5ad293dff4a67a9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the signed 64-bit integer <em>value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#gabbf6e10fd963d673f5ad293dff4a67a9">More...</a><br/></td></tr>
<tr class="separator:gabbf6e10fd963d673f5ad293dff4a67a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga923a63a01dae47a3dd46f74a3f744008"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga923a63a01dae47a3dd46f74a3f744008">cbor_encode_simple_value</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, uint8_t value)</td></tr>
<tr class="memdesc:ga923a63a01dae47a3dd46f74a3f744008"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the CBOR Simple Type of value <em>value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga923a63a01dae47a3dd46f74a3f744008">More...</a><br/></td></tr>
<tr class="separator:ga923a63a01dae47a3dd46f74a3f744008"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gac56f8c2ad79916f2719acb24f049cde5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gac56f8c2ad79916f2719acb24f049cde5">cbor_encode_floating_point</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, <a class="el" href="a00017.html#ga38f51ceba8bc8a9b1cf7dd31e3f9c178">CborType</a> fpType, const void *value)</td></tr>
<tr class="memdesc:gac56f8c2ad79916f2719acb24f049cde5"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the floating-point value of type <em>fpType</em> and pointed to by <em>value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#gac56f8c2ad79916f2719acb24f049cde5">More...</a><br/></td></tr>
<tr class="separator:gac56f8c2ad79916f2719acb24f049cde5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga77b579b1a5a867fc0712e46bb4eb3200"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga77b579b1a5a867fc0712e46bb4eb3200">cbor_encode_tag</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, <a class="el" href="a00017.html#ga46c29d9d57408740dc269d6125d37d26">CborTag</a> tag)</td></tr>
<tr class="memdesc:ga77b579b1a5a867fc0712e46bb4eb3200"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the CBOR tag <em>tag</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga77b579b1a5a867fc0712e46bb4eb3200">More...</a><br/></td></tr>
<tr class="separator:ga77b579b1a5a867fc0712e46bb4eb3200"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1260b72bb0f067fd3c68d49a6b5f58d0"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga1260b72bb0f067fd3c68d49a6b5f58d0">cbor_encode_byte_string</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, const uint8_t *string, size_t length)</td></tr>
<tr class="memdesc:ga1260b72bb0f067fd3c68d49a6b5f58d0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the text string <em>string</em> of length <em>length</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga1260b72bb0f067fd3c68d49a6b5f58d0">More...</a><br/></td></tr>
<tr class="separator:ga1260b72bb0f067fd3c68d49a6b5f58d0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4fa673c63e85b1fd6f8067aca4ccdde4"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga4fa673c63e85b1fd6f8067aca4ccdde4">cbor_encode_text_string</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, const char *string, size_t length)</td></tr>
<tr class="memdesc:ga4fa673c63e85b1fd6f8067aca4ccdde4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the byte string <em>string</em> of length <em>length</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga4fa673c63e85b1fd6f8067aca4ccdde4">More...</a><br/></td></tr>
<tr class="separator:ga4fa673c63e85b1fd6f8067aca4ccdde4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga97b4d15feaa128ed900704523979bd3f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga97b4d15feaa128ed900704523979bd3f">cbor_encoder_create_array</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, <a class="el" href="a00001.html">CborEncoder</a> *arrayEncoder, size_t length)</td></tr>
<tr class="memdesc:ga97b4d15feaa128ed900704523979bd3f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a CBOR array in the CBOR stream provided by <em>encoder</em> and initializes <em>arrayEncoder</em> so that items can be added to the array using the <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> functions. <a href="#ga97b4d15feaa128ed900704523979bd3f">More...</a><br/></td></tr>
<tr class="separator:ga97b4d15feaa128ed900704523979bd3f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad4a5ef2d574b5ac30d18ba696e219340"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340">cbor_encoder_create_map</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, <a class="el" href="a00001.html">CborEncoder</a> *mapEncoder, size_t length)</td></tr>
<tr class="memdesc:gad4a5ef2d574b5ac30d18ba696e219340"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates a CBOR map in the CBOR stream provided by <em>encoder</em> and initializes <em>mapEncoder</em> so that items can be added to the map using the <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> functions. <a href="#gad4a5ef2d574b5ac30d18ba696e219340">More...</a><br/></td></tr>
<tr class="separator:gad4a5ef2d574b5ac30d18ba696e219340"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gacb4352260971102dbbd2f2a20e854c57"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gacb4352260971102dbbd2f2a20e854c57">cbor_encoder_close_container</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, const <a class="el" href="a00001.html">CborEncoder</a> *containerEncoder)</td></tr>
<tr class="memdesc:gacb4352260971102dbbd2f2a20e854c57"><td class="mdescLeft">&#160;</td><td class="mdescRight">Closes the CBOR container (array or map) provided by <em>containerEncoder</em> and updates the CBOR stream provided by <em>encoder</em>. <a href="#gacb4352260971102dbbd2f2a20e854c57">More...</a><br/></td></tr>
<tr class="separator:gacb4352260971102dbbd2f2a20e854c57"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa597ba3b072473a41448e131ca20a66b"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gaa597ba3b072473a41448e131ca20a66b">cbor_encoder_close_container_checked</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, const <a class="el" href="a00001.html">CborEncoder</a> *containerEncoder)</td></tr>
<tr class="separator:gaa597ba3b072473a41448e131ca20a66b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga6df3eff486535322f66584dc5431f9e9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga6df3eff486535322f66584dc5431f9e9">cbor_encode_text_stringz</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, const char *string)</td></tr>
<tr class="memdesc:ga6df3eff486535322f66584dc5431f9e9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the null-terminated text string <em>string</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga6df3eff486535322f66584dc5431f9e9">More...</a><br/></td></tr>
<tr class="separator:ga6df3eff486535322f66584dc5431f9e9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga857154b97cad978f4afb3e2f809051bd"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ga857154b97cad978f4afb3e2f809051bd"></a>
<a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga857154b97cad978f4afb3e2f809051bd">cbor_encode_boolean</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, bool value)</td></tr>
<tr class="memdesc:ga857154b97cad978f4afb3e2f809051bd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the boolean value <em>value</em> to the CBOR stream provided by <em>encoder</em>. <br/></td></tr>
<tr class="separator:ga857154b97cad978f4afb3e2f809051bd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga30b769ff1da73ed8b4536f551347c5ed"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga30b769ff1da73ed8b4536f551347c5ed">cbor_encode_null</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder)</td></tr>
<tr class="memdesc:ga30b769ff1da73ed8b4536f551347c5ed"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the CBOR type representing a null value to the CBOR stream provided by <em>encoder</em>. <a href="#ga30b769ff1da73ed8b4536f551347c5ed">More...</a><br/></td></tr>
<tr class="separator:ga30b769ff1da73ed8b4536f551347c5ed"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga9d9f0668e2cf69352a45095006efab4f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga9d9f0668e2cf69352a45095006efab4f">cbor_encode_undefined</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder)</td></tr>
<tr class="memdesc:ga9d9f0668e2cf69352a45095006efab4f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the CBOR type representing an undefined value to the CBOR stream provided by <em>encoder</em>. <a href="#ga9d9f0668e2cf69352a45095006efab4f">More...</a><br/></td></tr>
<tr class="separator:ga9d9f0668e2cf69352a45095006efab4f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad8e5a125cfaceb9a32528e620e003bc6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gad8e5a125cfaceb9a32528e620e003bc6">cbor_encode_half_float</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, const void *value)</td></tr>
<tr class="memdesc:gad8e5a125cfaceb9a32528e620e003bc6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the IEEE 754 half-precision (16-bit) floating point value pointed to by <em>value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#gad8e5a125cfaceb9a32528e620e003bc6">More...</a><br/></td></tr>
<tr class="separator:gad8e5a125cfaceb9a32528e620e003bc6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae981ee934ef22ce4c5b52f8069e1b15c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gae981ee934ef22ce4c5b52f8069e1b15c">cbor_encode_float</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, float value)</td></tr>
<tr class="memdesc:gae981ee934ef22ce4c5b52f8069e1b15c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the IEEE 754 single-precision (32-bit) floating point value <em>value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#gae981ee934ef22ce4c5b52f8069e1b15c">More...</a><br/></td></tr>
<tr class="separator:gae981ee934ef22ce4c5b52f8069e1b15c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga211aa80dc5b793ee8dd74d24cb9e7ca6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga211aa80dc5b793ee8dd74d24cb9e7ca6">cbor_encode_double</a> (<a class="el" href="a00001.html">CborEncoder</a> *encoder, double value)</td></tr>
<tr class="memdesc:ga211aa80dc5b793ee8dd74d24cb9e7ca6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Appends the IEEE 754 double-precision (64-bit) floating point value <em>value</em> to the CBOR stream provided by <em>encoder</em>. <a href="#ga211aa80dc5b793ee8dd74d24cb9e7ca6">More...</a><br/></td></tr>
<tr class="separator:ga211aa80dc5b793ee8dd74d24cb9e7ca6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga753c2f9e09db7fa9317f1c1f19a16342"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#ga753c2f9e09db7fa9317f1c1f19a16342">cbor_encoder_get_buffer_size</a> (const <a class="el" href="a00001.html">CborEncoder</a> *encoder, const uint8_t *buffer)</td></tr>
<tr class="memdesc:ga753c2f9e09db7fa9317f1c1f19a16342"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the total size of the buffer starting at <em>buffer</em> after the encoding finished without errors. <a href="#ga753c2f9e09db7fa9317f1c1f19a16342">More...</a><br/></td></tr>
<tr class="separator:ga753c2f9e09db7fa9317f1c1f19a16342"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gafc9abf6503d40787c3fd637a86bc0fb6"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00018.html#gafc9abf6503d40787c3fd637a86bc0fb6">cbor_encoder_get_extra_bytes_needed</a> (const <a class="el" href="a00001.html">CborEncoder</a> *encoder)</td></tr>
<tr class="memdesc:gafc9abf6503d40787c3fd637a86bc0fb6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns how many more bytes the original buffer supplied to <a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2" title="Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size...">cbor_encoder_init()</a> needs to be extended by so that no CborErrorOutOfMemory condition will happen for the encoding. <a href="#gafc9abf6503d40787c3fd637a86bc0fb6">More...</a><br/></td></tr>
<tr class="separator:gafc9abf6503d40787c3fd637a86bc0fb6"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Group of functions used to encode data to CBOR. </p>
<p><a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> is used to encode data into a CBOR stream. The outermost <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> is initialized by calling <a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2" title="Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size...">cbor_encoder_init()</a>, with the buffer where the CBOR stream will be stored. The outermost <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> is usually used to encode exactly one item, most often an array or map. It is possible to encode more than one item, but care must then be taken on the decoder side to ensure the state is reset after each item was decoded.</p>
<p>Nested <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> objects are created using <a class="el" href="a00018.html#ga97b4d15feaa128ed900704523979bd3f" title="Creates a CBOR array in the CBOR stream provided by encoder and initializes arrayEncoder so that item...">cbor_encoder_create_array()</a> and <a class="el" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340" title="Creates a CBOR map in the CBOR stream provided by encoder and initializes mapEncoder so that items ca...">cbor_encoder_create_map()</a>, later closed with <a class="el" href="a00018.html#gacb4352260971102dbbd2f2a20e854c57" title="Closes the CBOR container (array or map) provided by containerEncoder and updates the CBOR stream pro...">cbor_encoder_close_container()</a> or <a class="el" href="a00018.html#gaa597ba3b072473a41448e131ca20a66b">cbor_encoder_close_container_checked()</a>. The pairs of creation and closing must be exactly matched and their parameters are always the same.</p>
<p><a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> writes directly to the user-supplied buffer, without extra buffering. <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> does not allocate memory and <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> objects are usually created on the stack of the encoding functions.</p>
<p>The example below initializes a <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> object with a buffer and encodes a single integer.</p>
<div class="fragment"><div class="line">uint8_t buf[16];</div>
<div class="line"><a class="code" href="a00001.html">CborEncoder</a> encoder;</div>
<div class="line"><a class="code" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2">cbor_encoder_init</a>(&amp;encoder, &amp;buf, <span class="keyword">sizeof</span>(buf), 0);</div>
<div class="line"><a class="code" href="a00018.html#gabbf6e10fd963d673f5ad293dff4a67a9">cbor_encode_int</a>(&amp;encoder, some_value);</div>
</div><!-- fragment --><p>As explained before, usually the outermost <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> object is used to add one array or map, which in turn contains multiple elements. The example below creates a CBOR map with one element: a key "foo" and a boolean value.</p>
<div class="fragment"><div class="line">uint8_t buf[16];</div>
<div class="line"><a class="code" href="a00001.html">CborEncoder</a> encoder, mapEncoder;</div>
<div class="line"><a class="code" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2">cbor_encoder_init</a>(&amp;encoder, &amp;buf, <span class="keyword">sizeof</span>(buf), 0);</div>
<div class="line"><a class="code" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340">cbor_encoder_create_map</a>(&amp;encoder, &amp;mapEncoder, 1);</div>
<div class="line"><a class="code" href="a00018.html#ga6df3eff486535322f66584dc5431f9e9">cbor_encode_text_stringz</a>(&amp;mapEncoder, <span class="stringliteral">&quot;foo&quot;</span>);</div>
<div class="line"><a class="code" href="a00018.html#ga857154b97cad978f4afb3e2f809051bd">cbor_encode_boolean</a>(&amp;mapEncoder, some_value);</div>
<div class="line"><a class="code" href="a00018.html#gacb4352260971102dbbd2f2a20e854c57">cbor_encoder_close_container</a>(&amp;encoder, &amp;mapEncoder);</div>
</div><!-- fragment --><h3 class="groupheader">Error checking and buffer size</h3>
<p>All functions operating on <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> return a condition of type CborError. If the encoding was successful, they return CborNoError. Some functions do extra checking on the input provided and may return some other error conditions (for example, <a class="el" href="a00018.html#ga923a63a01dae47a3dd46f74a3f744008" title="Appends the CBOR Simple Type of value value to the CBOR stream provided by encoder. ">cbor_encode_simple_value()</a> checks that the type is of the correct type).</p>
<p>In addition, all functions check whether the buffer has enough bytes to encode the item being appended. If that is not possible, they return CborErrorOutOfMemory.</p>
<p>It is possible to continue with the encoding of data past the first function that returns CborErrorOutOfMemory. <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> functions will not overrun the buffer, but will instead count how many more bytes are needed to complete the encoding. At the end, you can obtain that count by calling <a class="el" href="a00018.html#gafc9abf6503d40787c3fd637a86bc0fb6" title="Returns how many more bytes the original buffer supplied to cbor_encoder_init() needs to be extended ...">cbor_encoder_get_extra_bytes_needed()</a>.</p>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ga1260b72bb0f067fd3c68d49a6b5f58d0"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_byte_string </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint8_t *&#160;</td>
<td class="paramname"><em>string</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the text string <em>string</em> of length <em>length</em> to the CBOR stream provided by <em>encoder</em>. </p>
<p>CBOR requires that <em>string</em> be valid UTF-8, but TinyCBOR makes no verification of correctness.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5" title="The CborError enum contains the possible error values used by the CBOR encoder and decoder...">CborError</a> <a class="el" href="a00018.html#ga6df3eff486535322f66584dc5431f9e9" title="Appends the null-terminated text string string to the CBOR stream provided by encoder. ">cbor_encode_text_stringz</a>, <a class="el" href="a00018.html#ga1260b72bb0f067fd3c68d49a6b5f58d0" title="Appends the text string string of length length to the CBOR stream provided by encoder. ">cbor_encode_byte_string</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga211aa80dc5b793ee8dd74d24cb9e7ca6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_double </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">double&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the IEEE 754 double-precision (64-bit) floating point value <em>value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#gac56f8c2ad79916f2719acb24f049cde5" title="Appends the floating-point value of type fpType and pointed to by value to the CBOR stream provided b...">cbor_encode_floating_point()</a>, <a class="el" href="a00018.html#gad8e5a125cfaceb9a32528e620e003bc6" title="Appends the IEEE 754 half-precision (16-bit) floating point value pointed to by value to the CBOR str...">cbor_encode_half_float()</a>, <a class="el" href="a00018.html#gae981ee934ef22ce4c5b52f8069e1b15c" title="Appends the IEEE 754 single-precision (32-bit) floating point value value to the CBOR stream provided...">cbor_encode_float()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gae981ee934ef22ce4c5b52f8069e1b15c"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_float </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">float&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the IEEE 754 single-precision (32-bit) floating point value <em>value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#gac56f8c2ad79916f2719acb24f049cde5" title="Appends the floating-point value of type fpType and pointed to by value to the CBOR stream provided b...">cbor_encode_floating_point()</a>, <a class="el" href="a00018.html#gad8e5a125cfaceb9a32528e620e003bc6" title="Appends the IEEE 754 half-precision (16-bit) floating point value pointed to by value to the CBOR str...">cbor_encode_half_float()</a>, <a class="el" href="a00018.html#ga211aa80dc5b793ee8dd74d24cb9e7ca6" title="Appends the IEEE 754 double-precision (64-bit) floating point value value to the CBOR stream provided...">cbor_encode_double()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gac56f8c2ad79916f2719acb24f049cde5"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_floating_point </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="a00017.html#ga38f51ceba8bc8a9b1cf7dd31e3f9c178">CborType</a>&#160;</td>
<td class="paramname"><em>fpType</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const void *&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the floating-point value of type <em>fpType</em> and pointed to by <em>value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<p>The value of <em>fpType</em> must be one of CborHalfFloatType, CborFloatType or CborDoubleType, otherwise the behavior of this function is undefined.</p>
<p>This function is useful for code that needs to pass through floating point values but does not wish to have the actual floating-point code.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#gad8e5a125cfaceb9a32528e620e003bc6" title="Appends the IEEE 754 half-precision (16-bit) floating point value pointed to by value to the CBOR str...">cbor_encode_half_float</a>, <a class="el" href="a00018.html#gae981ee934ef22ce4c5b52f8069e1b15c" title="Appends the IEEE 754 single-precision (32-bit) floating point value value to the CBOR stream provided...">cbor_encode_float</a>, <a class="el" href="a00018.html#ga211aa80dc5b793ee8dd74d24cb9e7ca6" title="Appends the IEEE 754 double-precision (64-bit) floating point value value to the CBOR stream provided...">cbor_encode_double</a> </dd></dl>
<p>Referenced by <a class="el" href="a00018.html#ga211aa80dc5b793ee8dd74d24cb9e7ca6">cbor_encode_double()</a>, <a class="el" href="a00018.html#gae981ee934ef22ce4c5b52f8069e1b15c">cbor_encode_float()</a>, and <a class="el" href="a00018.html#gad8e5a125cfaceb9a32528e620e003bc6">cbor_encode_half_float()</a>.</p>
</div>
</div>
<a class="anchor" id="gad8e5a125cfaceb9a32528e620e003bc6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_half_float </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const void *&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the IEEE 754 half-precision (16-bit) floating point value pointed to by <em>value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#gac56f8c2ad79916f2719acb24f049cde5" title="Appends the floating-point value of type fpType and pointed to by value to the CBOR stream provided b...">cbor_encode_floating_point()</a>, <a class="el" href="a00018.html#gae981ee934ef22ce4c5b52f8069e1b15c" title="Appends the IEEE 754 single-precision (32-bit) floating point value value to the CBOR stream provided...">cbor_encode_float()</a>, <a class="el" href="a00018.html#ga211aa80dc5b793ee8dd74d24cb9e7ca6" title="Appends the IEEE 754 double-precision (64-bit) floating point value value to the CBOR stream provided...">cbor_encode_double()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gabbf6e10fd963d673f5ad293dff4a67a9"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_int </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int64_t&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the signed 64-bit integer <em>value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga0e84daa854e0480f4a3758bcb46b9b60" title="Appends the negative 64-bit integer whose absolute value is absolute_value to the CBOR stream provide...">cbor_encode_negative_int</a>, <a class="el" href="a00018.html#ga2b898ce6f5821c5aba8b6f0020c4b5ba" title="Appends the unsigned 64-bit integer value to the CBOR stream provided by encoder. ...">cbor_encode_uint</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga0e84daa854e0480f4a3758bcb46b9b60"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_negative_int </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint64_t&#160;</td>
<td class="paramname"><em>absolute_value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the negative 64-bit integer whose absolute value is <em>absolute_value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<p>If the value <em>absolute_value</em> is zero, this function encodes -2^64 - 1.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga2b898ce6f5821c5aba8b6f0020c4b5ba" title="Appends the unsigned 64-bit integer value to the CBOR stream provided by encoder. ...">cbor_encode_uint</a>, <a class="el" href="a00018.html#gabbf6e10fd963d673f5ad293dff4a67a9" title="Appends the signed 64-bit integer value to the CBOR stream provided by encoder. ">cbor_encode_int</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga30b769ff1da73ed8b4536f551347c5ed"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_null </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the CBOR type representing a null value to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga9d9f0668e2cf69352a45095006efab4f" title="Appends the CBOR type representing an undefined value to the CBOR stream provided by encoder...">cbor_encode_undefined()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga923a63a01dae47a3dd46f74a3f744008"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_simple_value </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the CBOR Simple Type of value <em>value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<p>This function may return error CborErrorIllegalSimpleType if the <em>value</em> variable contains a number that is not a valid simple type. </p>
<p>Referenced by <a class="el" href="a00018.html#ga857154b97cad978f4afb3e2f809051bd">cbor_encode_boolean()</a>, <a class="el" href="a00018.html#ga30b769ff1da73ed8b4536f551347c5ed">cbor_encode_null()</a>, and <a class="el" href="a00018.html#ga9d9f0668e2cf69352a45095006efab4f">cbor_encode_undefined()</a>.</p>
</div>
</div>
<a class="anchor" id="ga77b579b1a5a867fc0712e46bb4eb3200"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_tag </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="a00017.html#ga46c29d9d57408740dc269d6125d37d26">CborTag</a>&#160;</td>
<td class="paramname"><em>tag</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the CBOR tag <em>tag</em> to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00017.html#ga46c29d9d57408740dc269d6125d37d26" title="This typedef is an unsigned 64-bit integer. ">CborTag</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga4fa673c63e85b1fd6f8067aca4ccdde4"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_text_string </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>string</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the byte string <em>string</em> of length <em>length</em> to the CBOR stream provided by <em>encoder</em>. </p>
<p>CBOR byte strings are arbitrary raw data.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga6df3eff486535322f66584dc5431f9e9" title="Appends the null-terminated text string string to the CBOR stream provided by encoder. ">cbor_encode_text_stringz</a>, <a class="el" href="a00018.html#ga4fa673c63e85b1fd6f8067aca4ccdde4" title="Appends the byte string string of length length to the CBOR stream provided by encoder. ">cbor_encode_text_string</a> </dd></dl>
<p>Referenced by <a class="el" href="a00018.html#ga6df3eff486535322f66584dc5431f9e9">cbor_encode_text_stringz()</a>.</p>
</div>
</div>
<a class="anchor" id="ga6df3eff486535322f66584dc5431f9e9"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_text_stringz </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const char *&#160;</td>
<td class="paramname"><em>string</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the null-terminated text string <em>string</em> to the CBOR stream provided by <em>encoder</em>. </p>
<p>CBOR requires that <em>string</em> be valid UTF-8, but TinyCBOR makes no verification of correctness. The terminating null is not included in the stream.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga4fa673c63e85b1fd6f8067aca4ccdde4" title="Appends the byte string string of length length to the CBOR stream provided by encoder. ">cbor_encode_text_string</a>, <a class="el" href="a00018.html#ga1260b72bb0f067fd3c68d49a6b5f58d0" title="Appends the text string string of length length to the CBOR stream provided by encoder. ">cbor_encode_byte_string</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga2b898ce6f5821c5aba8b6f0020c4b5ba"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_uint </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint64_t&#160;</td>
<td class="paramname"><em>value</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the unsigned 64-bit integer <em>value</em> to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga0e84daa854e0480f4a3758bcb46b9b60" title="Appends the negative 64-bit integer whose absolute value is absolute_value to the CBOR stream provide...">cbor_encode_negative_int</a>, <a class="el" href="a00018.html#gabbf6e10fd963d673f5ad293dff4a67a9" title="Appends the signed 64-bit integer value to the CBOR stream provided by encoder. ">cbor_encode_int</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga9d9f0668e2cf69352a45095006efab4f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encode_undefined </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Appends the CBOR type representing an undefined value to the CBOR stream provided by <em>encoder</em>. </p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga30b769ff1da73ed8b4536f551347c5ed" title="Appends the CBOR type representing a null value to the CBOR stream provided by encoder. ">cbor_encode_null()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gacb4352260971102dbbd2f2a20e854c57"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encoder_close_container </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>containerEncoder</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Closes the CBOR container (array or map) provided by <em>containerEncoder</em> and updates the CBOR stream provided by <em>encoder</em>. </p>
<p>Both parameters must be the same as were passed to <a class="el" href="a00018.html#ga97b4d15feaa128ed900704523979bd3f" title="Creates a CBOR array in the CBOR stream provided by encoder and initializes arrayEncoder so that item...">cbor_encoder_create_array()</a> or <a class="el" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340" title="Creates a CBOR map in the CBOR stream provided by encoder and initializes mapEncoder so that items ca...">cbor_encoder_create_map()</a>.</p>
<p>Since version 0.5, this function verifies that the number of items (or pair of items, in the case of a map) was correct. It is no longer needed to call <a class="el" href="a00018.html#gaa597ba3b072473a41448e131ca20a66b">cbor_encoder_close_container_checked()</a> instead.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga97b4d15feaa128ed900704523979bd3f" title="Creates a CBOR array in the CBOR stream provided by encoder and initializes arrayEncoder so that item...">cbor_encoder_create_array()</a>, <a class="el" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340" title="Creates a CBOR map in the CBOR stream provided by encoder and initializes mapEncoder so that items ca...">cbor_encoder_create_map()</a> </dd></dl>
<p>Referenced by <a class="el" href="a00018.html#gaa597ba3b072473a41448e131ca20a66b">cbor_encoder_close_container_checked()</a>.</p>
</div>
</div>
<a class="anchor" id="gaa597ba3b072473a41448e131ca20a66b"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encoder_close_container_checked </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>containerEncoder</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Closes the CBOR container (array or map) provided by <em>containerEncoder</em> and updates the CBOR stream provided by <em>encoder</em>. Both parameters must be the same as were passed to <a class="el" href="a00018.html#ga97b4d15feaa128ed900704523979bd3f" title="Creates a CBOR array in the CBOR stream provided by encoder and initializes arrayEncoder so that item...">cbor_encoder_create_array()</a> or <a class="el" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340" title="Creates a CBOR map in the CBOR stream provided by encoder and initializes mapEncoder so that items ca...">cbor_encoder_create_map()</a>.</p>
<p>Prior to version 0.5, <a class="el" href="a00018.html#gacb4352260971102dbbd2f2a20e854c57" title="Closes the CBOR container (array or map) provided by containerEncoder and updates the CBOR stream pro...">cbor_encoder_close_container()</a> did not check the number of items added. Since that version, it does and now <a class="el" href="a00018.html#gaa597ba3b072473a41448e131ca20a66b">cbor_encoder_close_container_checked()</a> is no longer needed.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga97b4d15feaa128ed900704523979bd3f" title="Creates a CBOR array in the CBOR stream provided by encoder and initializes arrayEncoder so that item...">cbor_encoder_create_array()</a>, <a class="el" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340" title="Creates a CBOR map in the CBOR stream provided by encoder and initializes mapEncoder so that items ca...">cbor_encoder_create_map()</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga97b4d15feaa128ed900704523979bd3f"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encoder_create_array </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>arrayEncoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Creates a CBOR array in the CBOR stream provided by <em>encoder</em> and initializes <em>arrayEncoder</em> so that items can be added to the array using the <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> functions. </p>
<p>The array must be terminated by calling either <a class="el" href="a00018.html#gacb4352260971102dbbd2f2a20e854c57" title="Closes the CBOR container (array or map) provided by containerEncoder and updates the CBOR stream pro...">cbor_encoder_close_container()</a> or <a class="el" href="a00018.html#gaa597ba3b072473a41448e131ca20a66b">cbor_encoder_close_container_checked()</a> with the same <em>encoder</em> and <em>arrayEncoder</em> parameters.</p>
<p>The number of items inserted into the array must be exactly <em>length</em> items, otherwise the stream is invalid. If the number of items is not known when creating the array, the constant <a class="el" href="a00017.html#gadc05d7725df5c9a2995580e2be0e5b57">CborIndefiniteLength</a> may be passed as length instead.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#gad4a5ef2d574b5ac30d18ba696e219340" title="Creates a CBOR map in the CBOR stream provided by encoder and initializes mapEncoder so that items ca...">cbor_encoder_create_map</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gad4a5ef2d574b5ac30d18ba696e219340"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="a00017.html#ga76e9c9acc63dd940da4ab7e91309f7b5">CborError</a> cbor_encoder_create_map </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>mapEncoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>length</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Creates a CBOR map in the CBOR stream provided by <em>encoder</em> and initializes <em>mapEncoder</em> so that items can be added to the map using the <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> functions. </p>
<p>The map must be terminated by calling either <a class="el" href="a00018.html#gacb4352260971102dbbd2f2a20e854c57" title="Closes the CBOR container (array or map) provided by containerEncoder and updates the CBOR stream pro...">cbor_encoder_close_container()</a> or <a class="el" href="a00018.html#gaa597ba3b072473a41448e131ca20a66b">cbor_encoder_close_container_checked()</a> with the same <em>encoder</em> and <em>mapEncoder</em> parameters.</p>
<p>The number of pair of items inserted into the map must be exactly <em>length</em> items, otherwise the stream is invalid. If the number of items is not known when creating the map, the constant <a class="el" href="a00017.html#gadc05d7725df5c9a2995580e2be0e5b57">CborIndefiniteLength</a> may be passed as length instead.</p>
<p><b></b>{Implementation limitation:} TinyCBOR cannot encode more than SIZE_MAX/2 key-value pairs in the stream. If the length <em>length</em> is larger than this value, this function returns error CborErrorDataTooLarge.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga97b4d15feaa128ed900704523979bd3f" title="Creates a CBOR array in the CBOR stream provided by encoder and initializes arrayEncoder so that item...">cbor_encoder_create_array</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga753c2f9e09db7fa9317f1c1f19a16342"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">size_t cbor_encoder_get_buffer_size </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const uint8_t *&#160;</td>
<td class="paramname"><em>buffer</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the total size of the buffer starting at <em>buffer</em> after the encoding finished without errors. </p>
<p>The <em>encoder</em> and <em>buffer</em> arguments must be the same as supplied to <a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2" title="Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size...">cbor_encoder_init()</a>.</p>
<p>If the encoding process had errors, the return value of this function is meaningless. If the only errors were CborErrorOutOfMemory, instead use <a class="el" href="a00018.html#gafc9abf6503d40787c3fd637a86bc0fb6" title="Returns how many more bytes the original buffer supplied to cbor_encoder_init() needs to be extended ...">cbor_encoder_get_extra_bytes_needed()</a> to find out by how much to grow the buffer before encoding again.</p>
<p>See <a class="el" href="a00018.html">Encoding to CBOR</a> for an example of using this function.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2" title="Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size...">cbor_encoder_init()</a>, <a class="el" href="a00018.html#gafc9abf6503d40787c3fd637a86bc0fb6" title="Returns how many more bytes the original buffer supplied to cbor_encoder_init() needs to be extended ...">cbor_encoder_get_extra_bytes_needed()</a>, <a class="el" href="a00018.html" title="Group of functions used to encode data to CBOR. ">Encoding to CBOR</a> </dd></dl>
</div>
</div>
<a class="anchor" id="gafc9abf6503d40787c3fd637a86bc0fb6"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">size_t cbor_encoder_get_extra_bytes_needed </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns how many more bytes the original buffer supplied to <a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2" title="Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size...">cbor_encoder_init()</a> needs to be extended by so that no CborErrorOutOfMemory condition will happen for the encoding. </p>
<p>If the buffer was big enough, this function returns 0. The <em>encoder</em> must be the original argument as passed to <a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2" title="Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size...">cbor_encoder_init()</a>.</p>
<p>This function is usually called after an encoding sequence ended with one or more CborErrorOutOfMemory errors, but no other error. If any other error happened, the return value of this function is meaningless.</p>
<p>See <a class="el" href="a00018.html">Encoding to CBOR</a> for an example of using this function.</p>
<dl class="section see"><dt>See Also</dt><dd><a class="el" href="a00018.html#ga257051966d907f88af804f30f2e9d8e2" title="Initializes a CborEncoder structure encoder by pointing it to buffer buffer of size size...">cbor_encoder_init()</a>, <a class="el" href="a00018.html#ga753c2f9e09db7fa9317f1c1f19a16342" title="Returns the total size of the buffer starting at buffer after the encoding finished without errors...">cbor_encoder_get_buffer_size()</a>, <a class="el" href="a00018.html" title="Group of functions used to encode data to CBOR. ">Encoding to CBOR</a> </dd></dl>
</div>
</div>
<a class="anchor" id="ga257051966d907f88af804f30f2e9d8e2"></a>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void cbor_encoder_init </td>
<td>(</td>
<td class="paramtype"><a class="el" href="a00001.html">CborEncoder</a> *&#160;</td>
<td class="paramname"><em>encoder</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *&#160;</td>
<td class="paramname"><em>buffer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&#160;</td>
<td class="paramname"><em>size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>flags</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Initializes a <a class="el" href="a00001.html" title="Structure used to encode to CBOR. ">CborEncoder</a> structure <em>encoder</em> by pointing it to buffer <em>buffer</em> of size <em>size</em>. </p>
<p>The <em>flags</em> field is currently unused and must be zero. </p>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>