blob: f15b27e030afb7222f141379d8a0324cddfc2192 [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Binary Big Endianness Generators</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.0">
<link rel="home" href="../../../../index.html" title="Spirit 2.4.1">
<link rel="up" href="../binary.html" title="Binary">
<link rel="prev" href="binary_little.html" title="Binary Little Endianness Generators">
<link rel="next" href="../char.html" title="Char">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binary_little.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../binary.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../char.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="spirit.karma.reference.binary.binary_big"></a><a class="link" href="binary_big.html" title="Binary Big Endianness Generators">Binary
Big Endianness Generators</a>
</h5></div></div></div>
<a name="spirit.karma.reference.binary.binary_big.description"></a><h6>
<a name="id1022199"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.description">Description</a>
</h6>
<p>
The big native endianness generators described in this section are used
to emit binary byte streams laid out conforming to the big endianness
byte order.
</p>
<a name="spirit.karma.reference.binary.binary_big.header"></a><h6>
<a name="id1022216"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.header">Header</a>
</h6>
<pre class="programlisting"><span class="comment">// forwards to &lt;boost/spirit/home/karma/binary.hpp&gt;
</span><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma_binary</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
</p>
<a name="spirit.karma.reference.binary.binary_big.namespace"></a><h6>
<a name="id1022290"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.namespace">Namespace</a>
</h6>
<div class="informaltable"><table class="table">
<colgroup><col></colgroup>
<thead><tr><th>
<p>
Name
</p>
</th></tr></thead>
<tbody>
<tr><td>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">big_word</span> <span class="comment">//
alias: boost::spirit::karma::big_word</span></code>
</p>
</td></tr>
<tr><td>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">big_dword</span> <span class="comment">//
alias: boost::spirit::karma::big_dword</span></code>
</p>
</td></tr>
<tr><td>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">big_qword</span> <span class="comment">//
alias: boost::spirit::karma::big_qword</span></code>
</p>
</td></tr>
</tbody>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
The generators <code class="computeroutput"><span class="identifier">big_qword</span></code>
and <code class="computeroutput"><span class="identifier">big_qword</span><span class="special">(</span><span class="identifier">qw</span><span class="special">)</span></code>
are only available on platforms where the preprocessor constant <code class="computeroutput"><span class="identifier">BOOST_HAS_LONG_LONG</span></code> is defined (i.e.
on platforms having native support for <code class="computeroutput"><span class="keyword">unsigned</span>
<span class="keyword">long</span> <span class="keyword">long</span></code>
(64 bit) integer types).
</p></td></tr>
</table></div>
<a name="spirit.karma.reference.binary.binary_big.model_of"></a><h6>
<a name="id1022502"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.model_of">Model
of</a>
</h6>
<div class="blockquote"><blockquote class="blockquote"><p>
<a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>
</p></blockquote></div>
<div class="variablelist">
<p class="title"><b>Notation</b></p>
<dl>
<dt><span class="term"><code class="computeroutput"><span class="identifier">w</span></code></span></dt>
<dd><p>
A 16 bit binary value or a <a class="link" href="../karma_basics.html#spirit.karma.reference.karma_basics.lazy_argument">Lazy
Argument</a> that evaluates to a 16 bit binary value. This value
is always interpreted using native endianness.
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">dw</span></code></span></dt>
<dd><p>
A 32 bit binary value or a <a class="link" href="../karma_basics.html#spirit.karma.reference.karma_basics.lazy_argument">Lazy
Argument</a> that evaluates to a 32 bit binary value. This value
is always interpreted using native endianness.
</p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">qw</span></code></span></dt>
<dd><p>
A 64 bit binary value or a <a class="link" href="../karma_basics.html#spirit.karma.reference.karma_basics.lazy_argument">Lazy
Argument</a> that evaluates to a 64 bit binary value. This value
is always interpreted using native endianness.
</p></dd>
</dl>
</div>
<a name="spirit.karma.reference.binary.binary_big.expression_semantics"></a><h6>
<a name="id1022616"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.expression_semantics">Expression
Semantics</a>
</h6>
<p>
Semantics of an expression is defined only where it differs from, or
is not defined in <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>.
</p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Description
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_word</span></code>
</p>
</td>
<td>
<p>
Output the binary representation of the least significant 16
bits of the mandatory attribute in big endian representation.
This generator never fails (unless the underlying output stream
reports an error).
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_dword</span></code>
</p>
</td>
<td>
<p>
Output the binary representation of the least significant 32
bits of the mandatory attribute in big endian representation.
This generator never fails (unless the underlying output stream
reports an error).
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_qword</span></code>
</p>
</td>
<td>
<p>
Output the binary representation of the least significant 64
bits of the mandatory attribute in big endian representation.
This generator never fails (unless the underlying output stream
reports an error).
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_word</span><span class="special">(</span><span class="identifier">w</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
Output the binary representation of the least significant 16
bits of the immediate parameter in big endian representation.
This generator never fails (unless the underlying output stream
reports an error).
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_dword</span><span class="special">(</span><span class="identifier">dw</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
Output the binary representation of the least significant 32
bits of the immediate parameter in big endian representation.
This generator never fails (unless the underlying output stream
reports an error).
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_qword</span><span class="special">(</span><span class="identifier">qw</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
Output the binary representation of the least significant 64
bits of the immediate parameter in big endian representation.
This generator never fails (unless the underlying output stream
reports an error).
</p>
</td>
</tr>
</tbody>
</table></div>
<a name="spirit.karma.reference.binary.binary_big.attributes"></a><h6>
<a name="id1022866"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.attributes">Attributes</a>
</h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
<p>
Expression
</p>
</th>
<th>
<p>
Attribute
</p>
</th>
</tr></thead>
<tbody>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_word</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_least16_t</span></code>, attribute
is mandatory (otherwise compilation will fail)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_dword</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_least32_t</span></code>, attribute
is mandatory (otherwise compilation will fail)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_qword</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_least64_t</span></code>, attribute
is mandatory (otherwise compilation will fail)
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_word</span><span class="special">(</span><span class="identifier">w</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">unused</span></code>
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_dword</span><span class="special">(</span><span class="identifier">dw</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">unused</span></code>
</p>
</td>
</tr>
<tr>
<td>
<p>
<code class="computeroutput"><span class="identifier">big_qword</span><span class="special">(</span><span class="identifier">qw</span><span class="special">)</span></code>
</p>
</td>
<td>
<p>
<code class="computeroutput"><span class="identifier">unused</span></code>
</p>
</td>
</tr>
</tbody>
</table></div>
<a name="spirit.karma.reference.binary.binary_big.complexity"></a><h6>
<a name="id1023162"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.complexity">Complexity</a>
</h6>
<div class="blockquote"><blockquote class="blockquote"><p>
O(N), where N is the number of bytes emitted by the binary generator
</p></blockquote></div>
<a name="spirit.karma.reference.binary.binary_big.example"></a><h6>
<a name="id1023183"></a>
<a class="link" href="binary_big.html#spirit.karma.reference.binary.binary_big.example">Example</a>
</h6>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
The test harness for the example(s) below is presented in the <a class="link" href="../karma_basics.html#spirit.karma.reference.karma_basics.examples">Basics Examples</a>
section.
</p></td></tr>
</table></div>
<p>
Some includes:
</p>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">phoenix_core</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">phoenix_operator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">std_pair</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span>
</pre>
<p>
</p>
<p>
Some using declarations:
</p>
<p>
</p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">big_word</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">big_dword</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">big_qword</span><span class="special">;</span>
</pre>
<p>
</p>
<p>
Basic usage of the big binary generators:
</p>
<p>
</p>
<pre class="programlisting"><span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x02\x01"</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">big_word</span><span class="special">(</span><span class="number">0x0201</span><span class="special">));</span>
<span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x04\x03\x02\x01"</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">big_dword</span><span class="special">(</span><span class="number">0x04030201</span><span class="special">));</span>
<span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x08\x07\x06\x05\x04\x03\x02\x01"</span><span class="special">,</span> <span class="number">8</span><span class="special">,</span> <span class="identifier">big_qword</span><span class="special">(</span><span class="number">0</span><span class="identifier">x0807060504030201LL</span><span class="special">));</span>
<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x02\x01"</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">big_word</span><span class="special">,</span> <span class="number">0x0201</span><span class="special">);</span>
<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x04\x03\x02\x01"</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">big_dword</span><span class="special">,</span> <span class="number">0x04030201</span><span class="special">);</span>
<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x08\x07\x06\x05\x04\x03\x02\x01"</span><span class="special">,</span> <span class="number">8</span><span class="special">,</span> <span class="identifier">big_qword</span><span class="special">,</span> <span class="number">0</span><span class="identifier">x0807060504030201LL</span><span class="special">);</span>
</pre>
<p>
</p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2001-2010 Joel de Guzman, Hartmut Kaiser<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="binary_little.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../binary.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../char.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>