1 [/==============================================================================
2 Copyright (C) 2001-2011 Joel de Guzman
3 Copyright (C) 2001-2011 Hartmut Kaiser
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ===============================================================================/]
9 [section:binary Binary Parsers]
11 This module includes different parsers for parsing binary data in
12 various __endianness__. It includes parsers for default (native),
13 little, and big endian binary input.
15 [heading Module Header]
17 // forwards to <boost/spirit/home/qi/binary.hpp>
18 #include <boost/spirit/include/qi_binary.hpp>
20 Also, see __include_structure__.
22 [/////////////////////////////////////////////////////////////////////////////]
23 [section:binary_native Binary Native Endianness Parsers]
27 Binary native endian parsers are designed to parse binary byte streams
28 that are laid out in the native __endianness__ of the target
33 // forwards to <boost/spirit/home/qi/binary.hpp>
34 #include <boost/spirit/include/qi_binary.hpp>
36 Also, see __include_structure__.
42 [[`boost::spirit::byte_ // alias: boost::spirit::qi::byte_`]]
43 [[`boost::spirit::word // alias: boost::spirit::qi::word`]]
44 [[`boost::spirit::dword // alias: boost::spirit::qi::dword`]]
45 [[`boost::spirit::qword // alias: boost::spirit::qi::qword`]]
46 [[`boost::spirit::bin_float // alias: boost::spirit::qi::bin_float`]]
47 [[`boost::spirit::bin_double // alias: boost::spirit::qi::bin_double`]]
50 [note `qword` is only available on platforms where the preprocessor
51 constant `BOOST_HAS_LONG_LONG` is defined (i.e. on platforms having
52 native support for `unsigned long long` (64 bit) integer types).]
56 [:__primitive_parser_concept__]
58 [variablelist Notation
59 [[`b`] [A single byte (8 bit binary value) or a __qi_lazy_argument__
60 that evaluates to a single byte. This value is always
62 [[`w`] [A 16 bit binary value or a __qi_lazy_argument__ that
63 evaluates to a 16 bit binary value. This value is always
65 [[`dw`] [A 32 bit binary value or a __qi_lazy_argument__ that
66 evaluates to a 32 bit binary value. This value is always
68 [[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
69 evaluates to a 64 bit binary value. This value is always
71 [[`f`] [A float binary value or a __qi_lazy_argument__ that
72 evaluates to a float binary value. This value is always
74 [[`d`] [A double binary value or a __qi_lazy_argument__ that
75 evaluates to a double binary value. This value is always
79 [heading Expression Semantics]
81 Semantics of an expression is defined only where it differs from, or is
82 not defined in __primitive_parser_concept__.
85 [[Expression] [Description]]
86 [[`byte_`] [Matches any 8 bit native endian binary.]]
87 [[`word`] [Matches any 16 bit native endian binary.]]
88 [[`dword`] [Matches any 32 bit native endian binary.]]
89 [[`qword`] [Matches any 64 bit native endian binary.]]
90 [[`bin_float`] [Matches any float native endian binary.]]
91 [[`bin_double`] [Matches any double native endian binary.]]
92 [[`byte_(b)`] [Matches an exact 8 bit native endian binary.]]
93 [[`word(w)`] [Matches an exact 16 bit native endian binary.]]
94 [[`dword(dw)`] [Matches an exact 32 bit native endian binary.]]
95 [[`qword(qw)`] [Matches an exact 64 bit native endian binary.]]
96 [[`bin_float(f)`] [Matches an exact float native endian binary.]]
97 [[`bin_double(d)`] [Matches an exact double native endian binary.]]
103 [[Expression] [Attribute]]
104 [[`byte_`] [`boost::uint_least8_t`]]
105 [[`word`] [`boost::uint_least16_t`]]
106 [[`dword`] [`boost::uint_least32_t`]]
107 [[`qword`] [`boost::uint_least64_t`]]
108 [[`bin_float`] [`float`]]
109 [[`bin_double`] [`double`]]
110 [[`byte_(b)`] [__unused__]]
111 [[`word(w)`] [__unused__]]
112 [[`dword(dw)`] [__unused__]]
113 [[`qword(qw)`] [__unused__]]
114 [[`bin_float(f)`] [__unused__]]
115 [[`bin_double(d)`] [__unused__]]
120 [:O(N), where N is the number of bytes parsed]
124 [note The test harness for the example(s) below is presented in the
125 __qi_basics_examples__ section.]
127 [reference_qi_native_binary]
131 [/////////////////////////////////////////////////////////////////////////////]
132 [section:binary_little Binary Little Endianness Parser]
134 [heading Description]
136 Binary little endian parsers are designed to parse binary byte streams
137 that are laid out in little endian.
141 // forwards to <boost/spirit/home/qi/binary.hpp>
142 #include <boost/spirit/include/qi_binary.hpp>
144 Also, see __include_structure__.
150 [[`boost::spirit::little_word // alias: boost::spirit::qi::little_word` ]]
151 [[`boost::spirit::little_dword // alias: boost::spirit::qi::little_dword` ]]
152 [[`boost::spirit::little_qword // alias: boost::spirit::qi::little_qword` ]]
153 [[`boost::spirit::little_bin_float // alias: boost::spirit::qi::little_bin_float` ]]
154 [[`boost::spirit::little_bin_double // alias: boost::spirit::qi::little_bin_double` ]]
157 [note `little_qword` is only available on platforms where the
158 preprocessor constant `BOOST_HAS_LONG_LONG` is defined (i.e. on
159 platforms having native support for `unsigned long long` (64 bit)
164 [:__primitive_parser_concept__]
166 [variablelist Notation
167 [[`w`] [A 16 bit binary value or a __qi_lazy_argument__ that
168 evaluates to a 16 bit binary value. This value is always
170 [[`dw`] [A 32 bit binary value or a __qi_lazy_argument__ that
171 evaluates to a 32 bit binary value. This value is always
173 [[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
174 evaluates to a 64 bit binary value. This value is always
176 [[`f`] [A float binary value or a __qi_lazy_argument__ that
177 evaluates to a float binary value. This value is always
179 [[`d`] [A double binary value or a __qi_lazy_argument__ that
180 evaluates to a double binary value. This value is always
184 [heading Expression Semantics]
186 Semantics of an expression is defined only where it differs from, or is
187 not defined in __primitive_parser_concept__.
190 [[Expression] [Description]]
191 [[`little_word`] [Matches any 16 bit little endian binary.]]
192 [[`little_dword`] [Matches any 32 bit little endian binary.]]
193 [[`little_qword`] [Matches any 64 bit little endian binary.]]
194 [[`little_bin_float`] [Matches any float little endian binary.]]
195 [[`little_bin_double`] [Matches any double little endian binary.]]
196 [[`little_word(w)`] [Matches an exact 16 bit little endian binary.]]
197 [[`little_dword(dw)`] [Matches an exact 32 bit little endian binary.]]
198 [[`little_qword(qw)`] [Matches an exact 32 bit little endian binary.]]
199 [[`little_bin_float(f)`] [Matches an exact float little endian binary.]]
200 [[`little_bin_double(d)`] [Matches an exact double little endian binary.]]
206 [[Expression] [Attribute]]
207 [[`little_word`] [`boost::uint_least16_t`]]
208 [[`little_dword`] [`boost::uint_least32_t`]]
209 [[`little_qword`] [`boost::uint_least64_t`]]
210 [[`little_bin_float`] [`float`]]
211 [[`little_bin_double`] [`double`]]
212 [[`little_word(w)`] [__unused__]]
213 [[`little_dword(dw)`] [__unused__]]
214 [[`little_qword(qw)`] [__unused__]]
215 [[`little_bin_float(f)`] [__unused__]]
216 [[`little_bin_double(d)`] [__unused__]]
221 [:O(N), where N is the number of bytes parsed]
225 [note The test harness for the example(s) below is presented in the
226 __qi_basics_examples__ section.]
228 [reference_qi_little_binary]
232 [/////////////////////////////////////////////////////////////////////////////]
233 [section:binary_big Binary Big Endianness Parsers]
235 [heading Description]
237 Binary big endian parsers are designed to parse binary byte streams that
238 are laid out in big endian.
242 // forwards to <boost/spirit/home/qi/binary.hpp>
243 #include <boost/spirit/include/qi_binary.hpp>
245 Also, see __include_structure__.
251 [[`boost::spirit::big_word // alias: boost::spirit::qi::big_word` ]]
252 [[`boost::spirit::big_dword // alias: boost::spirit::qi::big_dword` ]]
253 [[`boost::spirit::big_qword // alias: boost::spirit::qi::big_qword` ]]
254 [[`boost::spirit::big_bin_float // alias: boost::spirit::qi::big_bin_float` ]]
255 [[`boost::spirit::big_bin_double // alias: boost::spirit::qi::big_bin_double` ]]
258 [note `big_qword` is only available on platforms where the
259 preprocessor constant `BOOST_HAS_LONG_LONG` is defined (i.e. on
260 platforms having native support for `unsigned long long` (64 bit)
265 [:__primitive_parser_concept__]
267 [variablelist Notation
268 [[`w`] [A 16 bit binary value or a __qi_lazy_argument__ that
269 evaluates to a 16 bit binary value. This value is always
271 [[`dw`] [A 32 bit binary value or a __qi_lazy_argument__ that
272 evaluates to a 32 bit binary value. This value is always
274 [[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
275 evaluates to a 64 bit binary value. This value is always
277 [[`f`] [A float binary value or a __qi_lazy_argument__ that
278 evaluates to a float binary value. This value is always
280 [[`d`] [A double binary value or a __qi_lazy_argument__ that
281 evaluates to a double binary value. This value is always
285 [heading Expression Semantics]
287 Semantics of an expression is defined only where it differs from, or is
288 not defined in __primitive_parser_concept__.
291 [[Expression] [Description]]
292 [[`big_word`] [Matches any 16 bit big endian binary.]]
293 [[`big_dword`] [Matches any 32 bit big endian binary.]]
294 [[`big_qword`] [Matches any 64 bit big endian binary.]]
295 [[`big_bin_float`] [Matches any float big endian binary.]]
296 [[`big_bin_double`] [Matches any double big endian binary.]]
297 [[`big_word(w)`] [Matches an exact 16 bit big endian binary.]]
298 [[`big_dword(dw)`] [Matches an exact 32 bit big endian binary.]]
299 [[`big_qword(qw)`] [Matches an exact 32 bit big endian binary.]]
300 [[`big_bin_float(f)`] [Matches an exact float big endian binary.]]
301 [[`big_bin_double(d)`] [Matches an exact double big endian binary.]]
307 [[Expression] [Attribute]]
308 [[`big_word`] [`boost::uint_least16_t`]]
309 [[`big_dword`] [`boost::uint_least32_t`]]
310 [[`big_qword`] [`boost::uint_least64_t`]]
311 [[`big_bin_float`] [`float`]]
312 [[`big_bin_double`] [`double`]]
313 [[`big_word(w)`] [__unused__]]
314 [[`big_dword(dw)`] [__unused__]]
315 [[`big_qword(qw)`] [__unused__]]
316 [[`big_bin_float(f)`] [__unused__]]
317 [[`big_bin_double(d)`] [__unused__]]
322 [:O(N), where N is the number of bytes parsed]
326 [note The test harness for the example(s) below is presented in the
327 __qi_basics_examples__ section.]
329 [reference_qi_big_binary]