protobuf-c/pack.html

75 lines
4.0 KiB
HTML

<!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.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>protobuf-c: Packing and unpacking messages</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="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">protobuf-c
&#160;<span id="projectnumber">1.3.3</span>
</div>
<div id="projectbrief">Protocol Buffers implementation in C</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
</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('pack.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="PageDoc"><div class="header">
<div class="headertitle">
<div class="title">Packing and unpacking messages </div> </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>To pack a message, first compute the packed size of the message with <a class="el" href="group__api.html#ga2c92b130142222b96991ffceb053828d" title="Determine the number of bytes required to store the serialised message.">protobuf_c_message_get_packed_size()</a>, then allocate a buffer of at least that size, then call <a class="el" href="group__api.html#ga704fdc1201b290834095720472090e9d" title="Serialise a message from its in-memory representation.">protobuf_c_message_pack()</a>.</p>
<p>Alternatively, a message can be serialized without calculating the final size first. Use the <a class="el" href="group__api.html#ga0883bacc5a5b0ba927fdd79204f9ad68" title="Serialise a message from its in-memory representation to a virtual buffer.">protobuf_c_message_pack_to_buffer()</a> function and provide a <a class="el" href="structProtobufCBuffer.html" title="Structure for defining a virtual append-only buffer.">ProtobufCBuffer</a> object which implements an "append" method that consumes data.</p>
<p>To unpack a message, call the <a class="el" href="group__api.html#gacc355835c22e19877df07a44f2f5b920" title="Unpack a serialised message into an in-memory representation.">protobuf_c_message_unpack()</a> function. The result can be cast to an object of the type that matches the descriptor for the message.</p>
<p>The result of unpacking a message should be freed with <a class="el" href="group__api.html#gaf1cdf87e9105fb1517d2406a6ca14fbe" title="Free an unpacked message object.">protobuf_c_message_free_unpacked()</a>. </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.png" alt="doxygen"/></a> 1.8.18 </li>
</ul>
</div>
</body>
</html>