<tfoot id='2W6P9'></tfoot>
      <bdo id='2W6P9'></bdo><ul id='2W6P9'></ul>
  1. <i id='2W6P9'><tr id='2W6P9'><dt id='2W6P9'><q id='2W6P9'><span id='2W6P9'><b id='2W6P9'><form id='2W6P9'><ins id='2W6P9'></ins><ul id='2W6P9'></ul><sub id='2W6P9'></sub></form><legend id='2W6P9'></legend><bdo id='2W6P9'><pre id='2W6P9'><center id='2W6P9'></center></pre></bdo></b><th id='2W6P9'></th></span></q></dt></tr></i><div id='2W6P9'><tfoot id='2W6P9'></tfoot><dl id='2W6P9'><fieldset id='2W6P9'></fieldset></dl></div>
  2. <legend id='2W6P9'><style id='2W6P9'><dir id='2W6P9'><q id='2W6P9'></q></dir></style></legend>

      <small id='2W6P9'></small><noframes id='2W6P9'>

      Boost Spirit可以用来解析字节流数据吗?

      Can Boost Spirit be used to parse byte stream data?(Boost Spirit可以用来解析字节流数据吗?)

            <tbody id='6eH0q'></tbody>

          <tfoot id='6eH0q'></tfoot>

          <small id='6eH0q'></small><noframes id='6eH0q'>

          <i id='6eH0q'><tr id='6eH0q'><dt id='6eH0q'><q id='6eH0q'><span id='6eH0q'><b id='6eH0q'><form id='6eH0q'><ins id='6eH0q'></ins><ul id='6eH0q'></ul><sub id='6eH0q'></sub></form><legend id='6eH0q'></legend><bdo id='6eH0q'><pre id='6eH0q'><center id='6eH0q'></center></pre></bdo></b><th id='6eH0q'></th></span></q></dt></tr></i><div id='6eH0q'><tfoot id='6eH0q'></tfoot><dl id='6eH0q'><fieldset id='6eH0q'></fieldset></dl></div>

            1. <legend id='6eH0q'><style id='6eH0q'><dir id='6eH0q'><q id='6eH0q'></q></dir></style></legend>
                <bdo id='6eH0q'></bdo><ul id='6eH0q'></ul>
                本文介绍了Boost Spirit可以用来解析字节流数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                Spirit(Boost C++ 库的一部分)可以用来解析来自流的二进制数据吗?例如,它能否用于将来自套接字的数据解析为结构、字节和单个位标志?谢谢!

                Can Spirit (part of Boost C++ library) be used to parse out binary data coming from a stream? For example, can it be used to parse data coming from a socket into structures, bytes, and individual bit flags? Thanks!

                推荐答案

                Boost Spirit 允许使用 扩展 Backus–Naur 形式 (EBNF) 语法与 模板元编程.它非常灵活,在解析过程的所有阶段都使用抽象类,可以自定义.为了处理二进制数据流,您需要实现自定义扫描器类,因为默认类型是为文本输入量身定制的.您可以在扫描仪和解析部分进一步阅读Spirit 用户指南.

                Boost Spirit allows for a parser to be defined using Extended Backus–Naur Form (EBNF) syntax with template meta-programming. It is very flexible and uses abstract classes in all phases of the parsing process that can be customized. In order to process a binary data stream, you would need to implement custom scanner classes since the default types are tailored for text input. You can read further in The Scanner and Parsing section of the Spirit User's Guide.

                在我看来,二进制数据流最好使用手动序列化代码来处理.Spirit 更适合结构良好的语法,如标记或脚本语言.例如,EBNF 中提供了 Lua 的完整语法.因此,使用 Spirit 构建自定义解析器可能是有意义的.另一方面,如果 上下文无关语法 甚至为此而存在.

                In my humble opinion, binary data streams are best handled with hand rolled serialization code. Spirit is geared more towards well formed grammars like mark-up or scripting languages. For example, The Complete Syntax of Lua is provided in EBNF. So, it might make sense to use Spirit to build a custom parser. On the other hand, a proprietary serial data link with synchronization bytes and CRC bracketing messages would require a lot more work just to define the EBNF if a context-free grammar even exists for it.

                附录

                Boost Spirit 的最新版本包括处理二进制数据的功能.

                这篇关于Boost Spirit可以用来解析字节流数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)
                How should a size-limited stl-like container be implemented?(应该如何实现大小受限的 stl 类容器?)
                Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)
                STL BigInt class implementation(STL BigInt 类实现)
                Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)
                Move list element to the end in STL(在 STL 中将列表元素移动到末尾)
                  <tbody id='tuPSQ'></tbody>

                      <bdo id='tuPSQ'></bdo><ul id='tuPSQ'></ul>

                        <i id='tuPSQ'><tr id='tuPSQ'><dt id='tuPSQ'><q id='tuPSQ'><span id='tuPSQ'><b id='tuPSQ'><form id='tuPSQ'><ins id='tuPSQ'></ins><ul id='tuPSQ'></ul><sub id='tuPSQ'></sub></form><legend id='tuPSQ'></legend><bdo id='tuPSQ'><pre id='tuPSQ'><center id='tuPSQ'></center></pre></bdo></b><th id='tuPSQ'></th></span></q></dt></tr></i><div id='tuPSQ'><tfoot id='tuPSQ'></tfoot><dl id='tuPSQ'><fieldset id='tuPSQ'></fieldset></dl></div>
                      1. <small id='tuPSQ'></small><noframes id='tuPSQ'>

                        • <tfoot id='tuPSQ'></tfoot>

                        • <legend id='tuPSQ'><style id='tuPSQ'><dir id='tuPSQ'><q id='tuPSQ'></q></dir></style></legend>