binary.qbk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. [/==============================================================================
  2. Copyright (C) 2001-2011 Joel de Guzman
  3. Copyright (C) 2001-2011 Hartmut Kaiser
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ===============================================================================/]
  7. [section:binary Binary Parsers]
  8. This module includes different parsers for parsing binary data in
  9. various __endianness__. It includes parsers for default (native),
  10. little, and big endian binary input.
  11. [heading Module Header]
  12. // forwards to <boost/spirit/home/qi/binary.hpp>
  13. #include <boost/spirit/include/qi_binary.hpp>
  14. Also, see __include_structure__.
  15. [/////////////////////////////////////////////////////////////////////////////]
  16. [section:binary_native Binary Native Endianness Parsers]
  17. [heading Description]
  18. Binary native endian parsers are designed to parse binary byte streams
  19. that are laid out in the native __endianness__ of the target
  20. architecture.
  21. [heading Header]
  22. // forwards to <boost/spirit/home/qi/binary.hpp>
  23. #include <boost/spirit/include/qi_binary.hpp>
  24. Also, see __include_structure__.
  25. [heading Namespace]
  26. [table
  27. [[Name]]
  28. [[`boost::spirit::byte_ // alias: boost::spirit::qi::byte_`]]
  29. [[`boost::spirit::word // alias: boost::spirit::qi::word`]]
  30. [[`boost::spirit::dword // alias: boost::spirit::qi::dword`]]
  31. [[`boost::spirit::qword // alias: boost::spirit::qi::qword`]]
  32. [[`boost::spirit::bin_float // alias: boost::spirit::qi::bin_float`]]
  33. [[`boost::spirit::bin_double // alias: boost::spirit::qi::bin_double`]]
  34. ]
  35. [note `qword` is only available on platforms where the preprocessor
  36. constant `BOOST_HAS_LONG_LONG` is defined (i.e. on platforms having
  37. native support for `unsigned long long` (64 bit) integer types).]
  38. [heading Model of]
  39. [:__primitive_parser_concept__]
  40. [variablelist Notation
  41. [[`b`] [A single byte (8 bit binary value) or a __qi_lazy_argument__
  42. that evaluates to a single byte. This value is always
  43. in native endian.]]
  44. [[`w`] [A 16 bit binary value or a __qi_lazy_argument__ that
  45. evaluates to a 16 bit binary value. This value is always
  46. in native endian.]]
  47. [[`dw`] [A 32 bit binary value or a __qi_lazy_argument__ that
  48. evaluates to a 32 bit binary value. This value is always
  49. in native endian.]]
  50. [[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
  51. evaluates to a 64 bit binary value. This value is always
  52. in native endian.]]
  53. [[`f`] [A float binary value or a __qi_lazy_argument__ that
  54. evaluates to a float binary value. This value is always
  55. in native endian.]]
  56. [[`d`] [A double binary value or a __qi_lazy_argument__ that
  57. evaluates to a double binary value. This value is always
  58. in native endian.]]
  59. ]
  60. [heading Expression Semantics]
  61. Semantics of an expression is defined only where it differs from, or is
  62. not defined in __primitive_parser_concept__.
  63. [table
  64. [[Expression] [Description]]
  65. [[`byte_`] [Matches any 8 bit native endian binary.]]
  66. [[`word`] [Matches any 16 bit native endian binary.]]
  67. [[`dword`] [Matches any 32 bit native endian binary.]]
  68. [[`qword`] [Matches any 64 bit native endian binary.]]
  69. [[`bin_float`] [Matches any float native endian binary.]]
  70. [[`bin_double`] [Matches any double native endian binary.]]
  71. [[`byte_(b)`] [Matches an exact 8 bit native endian binary.]]
  72. [[`word(w)`] [Matches an exact 16 bit native endian binary.]]
  73. [[`dword(dw)`] [Matches an exact 32 bit native endian binary.]]
  74. [[`qword(qw)`] [Matches an exact 64 bit native endian binary.]]
  75. [[`bin_float(f)`] [Matches an exact float native endian binary.]]
  76. [[`bin_double(d)`] [Matches an exact double native endian binary.]]
  77. ]
  78. [heading Attributes]
  79. [table
  80. [[Expression] [Attribute]]
  81. [[`byte_`] [`boost::uint_least8_t`]]
  82. [[`word`] [`boost::uint_least16_t`]]
  83. [[`dword`] [`boost::uint_least32_t`]]
  84. [[`qword`] [`boost::uint_least64_t`]]
  85. [[`bin_float`] [`float`]]
  86. [[`bin_double`] [`double`]]
  87. [[`byte_(b)`] [__unused__]]
  88. [[`word(w)`] [__unused__]]
  89. [[`dword(dw)`] [__unused__]]
  90. [[`qword(qw)`] [__unused__]]
  91. [[`bin_float(f)`] [__unused__]]
  92. [[`bin_double(d)`] [__unused__]]
  93. ]
  94. [heading Complexity]
  95. [:O(N), where N is the number of bytes parsed]
  96. [heading Example]
  97. [note The test harness for the example(s) below is presented in the
  98. __qi_basics_examples__ section.]
  99. [reference_qi_native_binary]
  100. [endsect]
  101. [/////////////////////////////////////////////////////////////////////////////]
  102. [section:binary_little Binary Little Endianness Parser]
  103. [heading Description]
  104. Binary little endian parsers are designed to parse binary byte streams
  105. that are laid out in little endian.
  106. [heading Header]
  107. // forwards to <boost/spirit/home/qi/binary.hpp>
  108. #include <boost/spirit/include/qi_binary.hpp>
  109. Also, see __include_structure__.
  110. [heading Namespace]
  111. [table
  112. [[Name]]
  113. [[`boost::spirit::little_word // alias: boost::spirit::qi::little_word` ]]
  114. [[`boost::spirit::little_dword // alias: boost::spirit::qi::little_dword` ]]
  115. [[`boost::spirit::little_qword // alias: boost::spirit::qi::little_qword` ]]
  116. [[`boost::spirit::little_bin_float // alias: boost::spirit::qi::little_bin_float` ]]
  117. [[`boost::spirit::little_bin_double // alias: boost::spirit::qi::little_bin_double` ]]
  118. ]
  119. [note `little_qword` is only available on platforms where the
  120. preprocessor constant `BOOST_HAS_LONG_LONG` is defined (i.e. on
  121. platforms having native support for `unsigned long long` (64 bit)
  122. integer types).]
  123. [heading Model of]
  124. [:__primitive_parser_concept__]
  125. [variablelist Notation
  126. [[`w`] [A 16 bit binary value or a __qi_lazy_argument__ that
  127. evaluates to a 16 bit binary value. This value is always
  128. in native endian.]]
  129. [[`dw`] [A 32 bit binary value or a __qi_lazy_argument__ that
  130. evaluates to a 32 bit binary value. This value is always
  131. in native endian.]]
  132. [[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
  133. evaluates to a 64 bit binary value. This value is always
  134. in native endian.]]
  135. [[`f`] [A float binary value or a __qi_lazy_argument__ that
  136. evaluates to a float binary value. This value is always
  137. in native endian.]]
  138. [[`d`] [A double binary value or a __qi_lazy_argument__ that
  139. evaluates to a double binary value. This value is always
  140. in native endian.]]
  141. ]
  142. [heading Expression Semantics]
  143. Semantics of an expression is defined only where it differs from, or is
  144. not defined in __primitive_parser_concept__.
  145. [table
  146. [[Expression] [Description]]
  147. [[`little_word`] [Matches any 16 bit little endian binary.]]
  148. [[`little_dword`] [Matches any 32 bit little endian binary.]]
  149. [[`little_qword`] [Matches any 64 bit little endian binary.]]
  150. [[`little_bin_float`] [Matches any float little endian binary.]]
  151. [[`little_bin_double`] [Matches any double little endian binary.]]
  152. [[`little_word(w)`] [Matches an exact 16 bit little endian binary.]]
  153. [[`little_dword(dw)`] [Matches an exact 32 bit little endian binary.]]
  154. [[`little_qword(qw)`] [Matches an exact 32 bit little endian binary.]]
  155. [[`little_bin_float(f)`] [Matches an exact float little endian binary.]]
  156. [[`little_bin_double(d)`] [Matches an exact double little endian binary.]]
  157. ]
  158. [heading Attributes]
  159. [table
  160. [[Expression] [Attribute]]
  161. [[`little_word`] [`boost::uint_least16_t`]]
  162. [[`little_dword`] [`boost::uint_least32_t`]]
  163. [[`little_qword`] [`boost::uint_least64_t`]]
  164. [[`little_bin_float`] [`float`]]
  165. [[`little_bin_double`] [`double`]]
  166. [[`little_word(w)`] [__unused__]]
  167. [[`little_dword(dw)`] [__unused__]]
  168. [[`little_qword(qw)`] [__unused__]]
  169. [[`little_bin_float(f)`] [__unused__]]
  170. [[`little_bin_double(d)`] [__unused__]]
  171. ]
  172. [heading Complexity]
  173. [:O(N), where N is the number of bytes parsed]
  174. [heading Example]
  175. [note The test harness for the example(s) below is presented in the
  176. __qi_basics_examples__ section.]
  177. [reference_qi_little_binary]
  178. [endsect]
  179. [/////////////////////////////////////////////////////////////////////////////]
  180. [section:binary_big Binary Big Endianness Parsers]
  181. [heading Description]
  182. Binary big endian parsers are designed to parse binary byte streams that
  183. are laid out in big endian.
  184. [heading Header]
  185. // forwards to <boost/spirit/home/qi/binary.hpp>
  186. #include <boost/spirit/include/qi_binary.hpp>
  187. Also, see __include_structure__.
  188. [heading Namespace]
  189. [table
  190. [[Name]]
  191. [[`boost::spirit::big_word // alias: boost::spirit::qi::big_word` ]]
  192. [[`boost::spirit::big_dword // alias: boost::spirit::qi::big_dword` ]]
  193. [[`boost::spirit::big_qword // alias: boost::spirit::qi::big_qword` ]]
  194. [[`boost::spirit::big_bin_float // alias: boost::spirit::qi::big_bin_float` ]]
  195. [[`boost::spirit::big_bin_double // alias: boost::spirit::qi::big_bin_double` ]]
  196. ]
  197. [note `big_qword` is only available on platforms where the
  198. preprocessor constant `BOOST_HAS_LONG_LONG` is defined (i.e. on
  199. platforms having native support for `unsigned long long` (64 bit)
  200. integer types).]
  201. [heading Model of]
  202. [:__primitive_parser_concept__]
  203. [variablelist Notation
  204. [[`w`] [A 16 bit binary value or a __qi_lazy_argument__ that
  205. evaluates to a 16 bit binary value. This value is always
  206. in native endian.]]
  207. [[`dw`] [A 32 bit binary value or a __qi_lazy_argument__ that
  208. evaluates to a 32 bit binary value. This value is always
  209. in native endian.]]
  210. [[`qw`] [A 64 bit binary value or a __qi_lazy_argument__ that
  211. evaluates to a 64 bit binary value. This value is always
  212. in native endian.]]
  213. [[`f`] [A float binary value or a __qi_lazy_argument__ that
  214. evaluates to a float binary value. This value is always
  215. in native endian.]]
  216. [[`d`] [A double binary value or a __qi_lazy_argument__ that
  217. evaluates to a double binary value. This value is always
  218. in native endian.]]
  219. ]
  220. [heading Expression Semantics]
  221. Semantics of an expression is defined only where it differs from, or is
  222. not defined in __primitive_parser_concept__.
  223. [table
  224. [[Expression] [Description]]
  225. [[`big_word`] [Matches any 16 bit big endian binary.]]
  226. [[`big_dword`] [Matches any 32 bit big endian binary.]]
  227. [[`big_qword`] [Matches any 64 bit big endian binary.]]
  228. [[`big_bin_float`] [Matches any float big endian binary.]]
  229. [[`big_bin_double`] [Matches any double big endian binary.]]
  230. [[`big_word(w)`] [Matches an exact 16 bit big endian binary.]]
  231. [[`big_dword(dw)`] [Matches an exact 32 bit big endian binary.]]
  232. [[`big_qword(qw)`] [Matches an exact 32 bit big endian binary.]]
  233. [[`big_bin_float(f)`] [Matches an exact float big endian binary.]]
  234. [[`big_bin_double(d)`] [Matches an exact double big endian binary.]]
  235. ]
  236. [heading Attributes]
  237. [table
  238. [[Expression] [Attribute]]
  239. [[`big_word`] [`boost::uint_least16_t`]]
  240. [[`big_dword`] [`boost::uint_least32_t`]]
  241. [[`big_qword`] [`boost::uint_least64_t`]]
  242. [[`big_bin_float`] [`float`]]
  243. [[`big_bin_double`] [`double`]]
  244. [[`big_word(w)`] [__unused__]]
  245. [[`big_dword(dw)`] [__unused__]]
  246. [[`big_qword(qw)`] [__unused__]]
  247. [[`big_bin_float(f)`] [__unused__]]
  248. [[`big_bin_double(d)`] [__unused__]]
  249. ]
  250. [heading Complexity]
  251. [:O(N), where N is the number of bytes parsed]
  252. [heading Example]
  253. [note The test harness for the example(s) below is presented in the
  254. __qi_basics_examples__ section.]
  255. [reference_qi_big_binary]
  256. [endsect]
  257. [endsect]