• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Binary Native Endianness Generators</title>
5<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../../index.html" title="Spirit 2.5.8">
8<link rel="up" href="../binary.html" title="Binary Generators">
9<link rel="prev" href="../binary.html" title="Binary Generators">
10<link rel="next" href="binary_little.html" title="Binary Little Endianness Generators">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="../binary.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="binary_little.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h5 class="title">
27<a name="spirit.karma.reference.binary.binary_native"></a><a class="link" href="binary_native.html" title="Binary Native Endianness Generators">Binary
28          Native Endianness Generators</a>
29</h5></div></div></div>
30<h6>
31<a name="spirit.karma.reference.binary.binary_native.h0"></a>
32            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.description"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.description">Description</a>
33          </h6>
34<p>
35            The binary native endianness generators described in this section are
36            used to emit binary byte streams laid out conforming to the native endianness
37            (byte order) of the target architecture.
38          </p>
39<h6>
40<a name="spirit.karma.reference.binary.binary_native.h1"></a>
41            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.header"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.header">Header</a>
42          </h6>
43<pre class="programlisting"><span class="comment">// forwards to &lt;boost/spirit/home/karma/binary.hpp&gt;</span>
44<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>
45</pre>
46<p>
47            Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
48          </p>
49<h6>
50<a name="spirit.karma.reference.binary.binary_native.h2"></a>
51            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.namespace"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.namespace">Namespace</a>
52          </h6>
53<div class="informaltable"><table class="table">
54<colgroup><col></colgroup>
55<thead><tr><th>
56                    <p>
57                      Name
58                    </p>
59                  </th></tr></thead>
60<tbody>
61<tr><td>
62                    <p>
63                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">byte_</span> <span class="comment">//
64                      alias: boost::spirit::karma::byte_</span></code>
65                    </p>
66                  </td></tr>
67<tr><td>
68                    <p>
69                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">word</span> <span class="comment">// alias:
70                      boost::spirit::karma::word</span></code>
71                    </p>
72                  </td></tr>
73<tr><td>
74                    <p>
75                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">dword</span> <span class="comment">//
76                      alias: boost::spirit::karma::dword</span></code>
77                    </p>
78                  </td></tr>
79<tr><td>
80                    <p>
81                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">qword</span> <span class="comment">//
82                      alias: boost::spirit::karma::qword</span></code>
83                    </p>
84                  </td></tr>
85<tr><td>
86                    <p>
87                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">bin_float</span> <span class="comment">//
88                      alias: boost::spirit::karma::bin_float</span></code>
89                    </p>
90                  </td></tr>
91<tr><td>
92                    <p>
93                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">bin_double</span> <span class="comment">//
94                      alias: boost::spirit::karma::bin_double</span></code>
95                    </p>
96                  </td></tr>
97</tbody>
98</table></div>
99<div class="note"><table border="0" summary="Note">
100<tr>
101<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
102<th align="left">Note</th>
103</tr>
104<tr><td align="left" valign="top"><p>
105              The generators <code class="computeroutput"><span class="identifier">qword</span></code>
106              and <code class="computeroutput"><span class="identifier">qword</span><span class="special">(</span><span class="identifier">qw</span><span class="special">)</span></code>
107              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.
108              on platforms having native support for <code class="computeroutput"><span class="keyword">unsigned</span>
109              <span class="keyword">long</span> <span class="keyword">long</span></code>
110              (64 bit) integer types).
111            </p></td></tr>
112</table></div>
113<h6>
114<a name="spirit.karma.reference.binary.binary_native.h3"></a>
115            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.model_of"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.model_of">Model
116            of</a>
117          </h6>
118<div class="blockquote"><blockquote class="blockquote"><p>
119              <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>
120            </p></blockquote></div>
121<div class="variablelist">
122<p class="title"><b>Notation</b></p>
123<dl class="variablelist">
124<dt><span class="term"><code class="computeroutput"><span class="identifier">b</span></code></span></dt>
125<dd><p>
126                  A single byte (8 bit binary value) or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
127                  Argument</a> that evaluates to a single byte
128                </p></dd>
129<dt><span class="term"><code class="computeroutput"><span class="identifier">w</span></code></span></dt>
130<dd><p>
131                  A 16 bit binary value or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
132                  Argument</a> that evaluates to a 16 bit binary value. This value
133                  is always interpreted using native endianness.
134                </p></dd>
135<dt><span class="term"><code class="computeroutput"><span class="identifier">dw</span></code></span></dt>
136<dd><p>
137                  A 32 bit binary value or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
138                  Argument</a> that evaluates to a 32 bit binary value. This value
139                  is always interpreted using native endianness.
140                </p></dd>
141<dt><span class="term"><code class="computeroutput"><span class="identifier">qw</span></code></span></dt>
142<dd><p>
143                  A 64 bit binary value or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
144                  Argument</a> that evaluates to a 64 bit binary value. This value
145                  is always interpreted using native endianness.
146                </p></dd>
147<dt><span class="term"><code class="computeroutput"><span class="identifier">f</span></code></span></dt>
148<dd><p>
149                  A float binary value or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
150                  Argument</a> that evaluates to a float binary value. This value
151                  is always interpreted using native endianness.
152                </p></dd>
153<dt><span class="term"><code class="computeroutput"><span class="identifier">d</span></code></span></dt>
154<dd><p>
155                  A double binary value or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
156                  Argument</a> that evaluates to a double binary value. This value
157                  is always interpreted using native endianness.
158                </p></dd>
159</dl>
160</div>
161<h6>
162<a name="spirit.karma.reference.binary.binary_native.h4"></a>
163            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.expression_semantics"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.expression_semantics">Expression
164            Semantics</a>
165          </h6>
166<p>
167            Semantics of an expression is defined only where it differs from, or
168            is not defined in <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>.
169          </p>
170<div class="informaltable"><table class="table">
171<colgroup>
172<col>
173<col>
174</colgroup>
175<thead><tr>
176<th>
177                    <p>
178                      Expression
179                    </p>
180                  </th>
181<th>
182                    <p>
183                      Description
184                    </p>
185                  </th>
186</tr></thead>
187<tbody>
188<tr>
189<td>
190                    <p>
191                      <code class="computeroutput"><span class="identifier">byte_</span></code>
192                    </p>
193                  </td>
194<td>
195                    <p>
196                      Output the binary representation of the least significant byte
197                      of the mandatory attribute. This generator never fails (unless
198                      the underlying output stream reports an error).
199                    </p>
200                  </td>
201</tr>
202<tr>
203<td>
204                    <p>
205                      <code class="computeroutput"><span class="identifier">word</span></code>
206                    </p>
207                  </td>
208<td>
209                    <p>
210                      Output the binary representation of the least significant 16
211                      bits of the mandatory attribute in native endian representation.
212                      This generator never fails (unless the underlying output stream
213                      reports an error).
214                    </p>
215                  </td>
216</tr>
217<tr>
218<td>
219                    <p>
220                      <code class="computeroutput"><span class="identifier">dword</span></code>
221                    </p>
222                  </td>
223<td>
224                    <p>
225                      Output the binary representation of the least significant 32
226                      bits of the mandatory attribute in native endian representation.
227                      This generator never fails (unless the underlying output stream
228                      reports an error).
229                    </p>
230                  </td>
231</tr>
232<tr>
233<td>
234                    <p>
235                      <code class="computeroutput"><span class="identifier">qword</span></code>
236                    </p>
237                  </td>
238<td>
239                    <p>
240                      Output the binary representation of the least significant 64
241                      bits of the mandatory attribute in native endian representation.
242                      This generator never fails (unless the underlying output stream
243                      reports an error).
244                    </p>
245                  </td>
246</tr>
247<tr>
248<td>
249                    <p>
250                      <code class="computeroutput"><span class="identifier">bin_float</span></code>
251                    </p>
252                  </td>
253<td>
254                    <p>
255                      Output the binary representation of the mandatory float attribute
256                      in native endian representation. This generator never fails
257                      (unless the underlying output stream reports an error).
258                    </p>
259                  </td>
260</tr>
261<tr>
262<td>
263                    <p>
264                      <code class="computeroutput"><span class="identifier">bin_double</span></code>
265                    </p>
266                  </td>
267<td>
268                    <p>
269                      Output the binary representation of the mandatory double attribute
270                      in native endian representation. This generator never fails
271                      (unless the underlying output stream reports an error).
272                    </p>
273                  </td>
274</tr>
275<tr>
276<td>
277                    <p>
278                      <code class="computeroutput"><span class="identifier">byte_</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span></code>
279                    </p>
280                  </td>
281<td>
282                    <p>
283                      Output the binary representation of the least significant byte
284                      of the immediate parameter. This generator never fails (unless
285                      the underlying output stream reports an error).
286                    </p>
287                  </td>
288</tr>
289<tr>
290<td>
291                    <p>
292                      <code class="computeroutput"><span class="identifier">word</span><span class="special">(</span><span class="identifier">w</span><span class="special">)</span></code>
293                    </p>
294                  </td>
295<td>
296                    <p>
297                      Output the binary representation of the least significant 16
298                      bits of the immediate parameter in native endian representation.
299                      This generator never fails (unless the underlying output stream
300                      reports an error).
301                    </p>
302                  </td>
303</tr>
304<tr>
305<td>
306                    <p>
307                      <code class="computeroutput"><span class="identifier">dword</span><span class="special">(</span><span class="identifier">dw</span><span class="special">)</span></code>
308                    </p>
309                  </td>
310<td>
311                    <p>
312                      Output the binary representation of the least significant 32
313                      bits of the immediate parameter in native endian representation.
314                      This generator never fails (unless the underlying output stream
315                      reports an error).
316                    </p>
317                  </td>
318</tr>
319<tr>
320<td>
321                    <p>
322                      <code class="computeroutput"><span class="identifier">qword</span><span class="special">(</span><span class="identifier">qw</span><span class="special">)</span></code>
323                    </p>
324                  </td>
325<td>
326                    <p>
327                      Output the binary representation of the least significant 64
328                      bits of the immediate parameter in native endian representation.
329                      This generator never fails (unless the underlying output stream
330                      reports an error).
331                    </p>
332                  </td>
333</tr>
334<tr>
335<td>
336                    <p>
337                      <code class="computeroutput"><span class="identifier">bin_float</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span></code>
338                    </p>
339                  </td>
340<td>
341                    <p>
342                      Output the binary representation of the immediate float parameter
343                      in native endian representation. This generator never fails
344                      (unless the underlying output stream reports an error).
345                    </p>
346                  </td>
347</tr>
348<tr>
349<td>
350                    <p>
351                      <code class="computeroutput"><span class="identifier">bin_double</span><span class="special">(</span><span class="identifier">d</span><span class="special">)</span></code>
352                    </p>
353                  </td>
354<td>
355                    <p>
356                      Output the binary representation of the immediate double parameter
357                      in native endian representation. This generator never fails
358                      (unless the underlying output stream reports an error).
359                    </p>
360                  </td>
361</tr>
362</tbody>
363</table></div>
364<h6>
365<a name="spirit.karma.reference.binary.binary_native.h5"></a>
366            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.attributes"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.attributes">Attributes</a>
367          </h6>
368<div class="informaltable"><table class="table">
369<colgroup>
370<col>
371<col>
372</colgroup>
373<thead><tr>
374<th>
375                    <p>
376                      Expression
377                    </p>
378                  </th>
379<th>
380                    <p>
381                      Attribute
382                    </p>
383                  </th>
384</tr></thead>
385<tbody>
386<tr>
387<td>
388                    <p>
389                      <code class="computeroutput"><span class="identifier">byte_</span></code>
390                    </p>
391                  </td>
392<td>
393                    <p>
394                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_least8_t</span></code>, attribute
395                      is mandatory (otherwise compilation will fail)
396                    </p>
397                  </td>
398</tr>
399<tr>
400<td>
401                    <p>
402                      <code class="computeroutput"><span class="identifier">word</span></code>
403                    </p>
404                  </td>
405<td>
406                    <p>
407                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_least16_t</span></code>, attribute
408                      is mandatory (otherwise compilation will fail)
409                    </p>
410                  </td>
411</tr>
412<tr>
413<td>
414                    <p>
415                      <code class="computeroutput"><span class="identifier">dword</span></code>
416                    </p>
417                  </td>
418<td>
419                    <p>
420                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_least32_t</span></code>, attribute
421                      is mandatory (otherwise compilation will fail)
422                    </p>
423                  </td>
424</tr>
425<tr>
426<td>
427                    <p>
428                      <code class="computeroutput"><span class="identifier">qword</span></code>
429                    </p>
430                  </td>
431<td>
432                    <p>
433                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">uint_least64_t</span></code>, attribute
434                      is mandatory (otherwise compilation will fail)
435                    </p>
436                  </td>
437</tr>
438<tr>
439<td>
440                    <p>
441                      <code class="computeroutput"><span class="identifier">bin_float</span></code>
442                    </p>
443                  </td>
444<td>
445                    <p>
446                      <code class="computeroutput"><span class="keyword">float</span></code>, attribute
447                      is mandatory (otherwise compilation will fail)
448                    </p>
449                  </td>
450</tr>
451<tr>
452<td>
453                    <p>
454                      <code class="computeroutput"><span class="identifier">bin_double</span></code>
455                    </p>
456                  </td>
457<td>
458                    <p>
459                      <code class="computeroutput"><span class="keyword">double</span></code>, attribute
460                      is mandatory (otherwise compilation will fail)
461                    </p>
462                  </td>
463</tr>
464<tr>
465<td>
466                    <p>
467                      <code class="computeroutput"><span class="identifier">byte_</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span></code>
468                    </p>
469                  </td>
470<td>
471                    <p>
472                      <code class="computeroutput"><span class="identifier">unused</span></code>
473                    </p>
474                  </td>
475</tr>
476<tr>
477<td>
478                    <p>
479                      <code class="computeroutput"><span class="identifier">word</span><span class="special">(</span><span class="identifier">w</span><span class="special">)</span></code>
480                    </p>
481                  </td>
482<td>
483                    <p>
484                      <code class="computeroutput"><span class="identifier">unused</span></code>
485                    </p>
486                  </td>
487</tr>
488<tr>
489<td>
490                    <p>
491                      <code class="computeroutput"><span class="identifier">dword</span><span class="special">(</span><span class="identifier">dw</span><span class="special">)</span></code>
492                    </p>
493                  </td>
494<td>
495                    <p>
496                      <code class="computeroutput"><span class="identifier">unused</span></code>
497                    </p>
498                  </td>
499</tr>
500<tr>
501<td>
502                    <p>
503                      <code class="computeroutput"><span class="identifier">qword</span><span class="special">(</span><span class="identifier">qw</span><span class="special">)</span></code>
504                    </p>
505                  </td>
506<td>
507                    <p>
508                      <code class="computeroutput"><span class="identifier">unused</span></code>
509                    </p>
510                  </td>
511</tr>
512<tr>
513<td>
514                    <p>
515                      <code class="computeroutput"><span class="identifier">bin_float</span><span class="special">(</span><span class="identifier">f</span><span class="special">)</span></code>
516                    </p>
517                  </td>
518<td>
519                    <p>
520                      <code class="computeroutput"><span class="identifier">unused</span></code>
521                    </p>
522                  </td>
523</tr>
524<tr>
525<td>
526                    <p>
527                      <code class="computeroutput"><span class="identifier">bin_double</span><span class="special">(</span><span class="identifier">d</span><span class="special">)</span></code>
528                    </p>
529                  </td>
530<td>
531                    <p>
532                      <code class="computeroutput"><span class="identifier">unused</span></code>
533                    </p>
534                  </td>
535</tr>
536</tbody>
537</table></div>
538<div class="note"><table border="0" summary="Note">
539<tr>
540<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
541<th align="left">Note</th>
542</tr>
543<tr><td align="left" valign="top"><p>
544              In addition to their usual attribute of type <code class="computeroutput"><span class="identifier">Attrib</span></code>
545              all listed generators accept an instance of a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">Attrib</span><span class="special">&gt;</span></code> as well. If the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> is initialized (holds a value)
546              the generators behave as if their attribute was an instance of <code class="computeroutput"><span class="identifier">Attrib</span></code> and emit the value stored
547              in the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code>.
548              Otherwise the generators will fail.
549            </p></td></tr>
550</table></div>
551<h6>
552<a name="spirit.karma.reference.binary.binary_native.h6"></a>
553            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.complexity"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.complexity">Complexity</a>
554          </h6>
555<div class="blockquote"><blockquote class="blockquote"><p>
556              O(N), where N is the number of bytes emitted by the binary generator
557            </p></blockquote></div>
558<h6>
559<a name="spirit.karma.reference.binary.binary_native.h7"></a>
560            <span class="phrase"><a name="spirit.karma.reference.binary.binary_native.example"></a></span><a class="link" href="binary_native.html#spirit.karma.reference.binary.binary_native.example">Example</a>
561          </h6>
562<div class="note"><table border="0" summary="Note">
563<tr>
564<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
565<th align="left">Note</th>
566</tr>
567<tr><td align="left" valign="top"><p>
568              The test harness for the example(s) below is presented in the <a class="link" href="../basics.html#spirit.karma.reference.basics.examples">Basics Examples</a>
569              section.
570            </p></td></tr>
571</table></div>
572<p>
573            Some includes:
574          </p>
575<p>
576</p>
577<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>
578<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">support_utree</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
579<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>
580<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>
581<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>
582<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
583<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span>
584</pre>
585<p>
586          </p>
587<p>
588            Some using declarations:
589          </p>
590<p>
591</p>
592<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">byte_</span><span class="special">;</span>
593<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">word</span><span class="special">;</span>
594<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">dword</span><span class="special">;</span>
595<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">qword</span><span class="special">;</span>
596</pre>
597<p>
598          </p>
599<p>
600            Basic usage of the native binary generators with some results for little
601            endian platforms:
602          </p>
603<p>
604</p>
605<pre class="programlisting"><span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x01"</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">byte_</span><span class="special">(</span><span class="number">0x01</span><span class="special">));</span>
606<span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x01\x02"</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">word</span><span class="special">(</span><span class="number">0x0201</span><span class="special">));</span>
607<span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x01\x02\x03\x04"</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">dword</span><span class="special">(</span><span class="number">0x04030201</span><span class="special">));</span>
608<span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x01\x02\x03\x04\x05\x06\x07\x08"</span><span class="special">,</span> <span class="number">8</span><span class="special">,</span> <span class="identifier">qword</span><span class="special">(</span><span class="number">0</span><span class="identifier">x0807060504030201LL</span><span class="special">));</span>
609
610<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x01"</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">byte_</span><span class="special">,</span> <span class="number">0x01</span><span class="special">);</span>
611<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x01\x02"</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="identifier">word</span><span class="special">,</span> <span class="number">0x0201</span><span class="special">);</span>
612<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x01\x02\x03\x04"</span><span class="special">,</span> <span class="number">4</span><span class="special">,</span> <span class="identifier">dword</span><span class="special">,</span> <span class="number">0x04030201</span><span class="special">);</span>
613<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x01\x02\x03\x04\x05\x06\x07\x08"</span><span class="special">,</span> <span class="number">8</span><span class="special">,</span> <span class="identifier">qword</span><span class="special">,</span> <span class="number">0</span><span class="identifier">x0807060504030201LL</span><span class="special">);</span>
614</pre>
615<p>
616          </p>
617<p>
618            Basic usage of the native binary generators with some results for big
619            endian platforms:
620          </p>
621<p>
622</p>
623<pre class="programlisting"><span class="identifier">test_binary_generator</span><span class="special">(</span><span class="string">"\x01"</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">byte_</span><span class="special">(</span><span class="number">0x01</span><span class="special">));</span>
624<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">word</span><span class="special">(</span><span class="number">0x0201</span><span class="special">));</span>
625<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">dword</span><span class="special">(</span><span class="number">0x04030201</span><span class="special">));</span>
626<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">qword</span><span class="special">(</span><span class="number">0</span><span class="identifier">x0807060504030201LL</span><span class="special">));</span>
627
628<span class="identifier">test_binary_generator_attr</span><span class="special">(</span><span class="string">"\x01"</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span> <span class="identifier">byte_</span><span class="special">,</span> <span class="number">0x01</span><span class="special">);</span>
629<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">word</span><span class="special">,</span> <span class="number">0x0201</span><span class="special">);</span>
630<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">dword</span><span class="special">,</span> <span class="number">0x04030201</span><span class="special">);</span>
631<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">qword</span><span class="special">,</span> <span class="number">0</span><span class="identifier">x0807060504030201LL</span><span class="special">);</span>
632</pre>
633<p>
634          </p>
635</div>
636<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
637<td align="left"></td>
638<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
639        Distributed under the Boost Software License, Version 1.0. (See accompanying
640        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>)
641      </p>
642</div></td>
643</tr></table>
644<hr>
645<div class="spirit-nav">
646<a accesskey="p" href="../binary.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="binary_little.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
647</div>
648</body>
649</html>
650