<legend id='jNWgM'><style id='jNWgM'><dir id='jNWgM'><q id='jNWgM'></q></dir></style></legend>
      <bdo id='jNWgM'></bdo><ul id='jNWgM'></ul>

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

      <small id='jNWgM'></small><noframes id='jNWgM'>

      1. <tfoot id='jNWgM'></tfoot>

      2. 直接提升序列化到字符数组

        Direct boost serialization to char array(直接提升序列化到字符数组)
        <i id='hHk69'><tr id='hHk69'><dt id='hHk69'><q id='hHk69'><span id='hHk69'><b id='hHk69'><form id='hHk69'><ins id='hHk69'></ins><ul id='hHk69'></ul><sub id='hHk69'></sub></form><legend id='hHk69'></legend><bdo id='hHk69'><pre id='hHk69'><center id='hHk69'></center></pre></bdo></b><th id='hHk69'></th></span></q></dt></tr></i><div id='hHk69'><tfoot id='hHk69'></tfoot><dl id='hHk69'><fieldset id='hHk69'></fieldset></dl></div>

            <tbody id='hHk69'></tbody>
          <tfoot id='hHk69'></tfoot>

            • <bdo id='hHk69'></bdo><ul id='hHk69'></ul>

              1. <legend id='hHk69'><style id='hHk69'><dir id='hHk69'><q id='hHk69'></q></dir></style></legend>

                  <small id='hHk69'></small><noframes id='hHk69'>

                  本文介绍了直接提升序列化到字符数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Boost 序列化文档断言序列化/反序列化项目的方法是使用二进制/文本存档,并在底层结构上使用流.如果我不想将序列化数据用作 std::string,这可以正常工作,但我的目的是将其直接转换为 char* 缓冲区.如何在不创建临时字符串的情况下实现此目的?

                  Boost serialization doc's assert that the way to serialize/deserialize items is using a binary/text archive with a stream on the underlying structure. This works fine if I wan't to use the serialized data as an std::string, but my intention is to convert it directly to a char* buffer. How can I achieve this without creating a temporary string?

                  解决了!对于那些想要一个例子的人:

                  Solved! For the ones that wanted a example:

                  char buffer[4096];
                  
                  boost::iostreams::basic_array_sink<char> sr(buffer, buffer_size);  
                  boost::iostreams::stream< boost::iostreams::basic_array_sink<char> > source(sr);
                  
                  boost::archive::binary_oarchive oa(source);
                  
                  oa << serializable_object; 
                  

                  推荐答案

                  IIUC,您想写入一个固定大小的预分配数组.

                  IIUC, you would like to write to a preallocated array of fixed size.

                  您可以使用 boost::iostreams::array_sink(用 stream 给它一个 std::ostream 接口).

                  You could use a boost::iostreams::array_sink (wrapped with stream to give it an std::ostream interface) for that.

                  这篇关于直接提升序列化到字符数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)
                  <tfoot id='rhW3N'></tfoot>
                      • <bdo id='rhW3N'></bdo><ul id='rhW3N'></ul>

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

                            <legend id='rhW3N'><style id='rhW3N'><dir id='rhW3N'><q id='rhW3N'></q></dir></style></legend>

                              <tbody id='rhW3N'></tbody>