如何在序列化期间插入字符串流的中间
How to insert in middle of stringstream during serialisation?
std::ostringstream oss;
boost::archive::text_oarchive oa(oss);
我向这个oa添加了可变数量的内容,就像这样
oa & int1;
oa &int2;
--------------------> insert number of matrices here
oa & matrix1;
..//do some processing
oa & matrix2;
...//do some more
....
oa & matrixn;
矩阵参考 - http://robot.kaist.ac.kr/haptics/chai3d-2.0.0_Doc/resources/html/structc_matrix3d.html
现在,当我完成时,我想在 udp 发送之前插入我添加到此存档的矩阵数量,然后再开始添加矩阵。但我也知道在将它们添加到流之后,我添加了多少矩阵
我应该怎么做?
你不能做
oa & matrix1.
为此,矩阵必须是一个简单的类型(它不是(或实现函数序列化。您可以重写矩阵实现序列化,然后使用它。
这是一个很好的参考: http://www.boost.org/doc/libs/1_54_0/libs/serialization/doc/tutorial.html
你实际上可以从OSS <<(int(0;然后在你写完所有东西之后,都找回开头,用你添加的项目数重写前 4 个字节。
相关文章:
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- 递归形成字符串中所有数字字符的中间和?
- 如何组合一个宽字符字符串,中间插入一些空字符
- C++ 我想将两个字符串写入管道,中间有一小段延迟
- 在 txt 文件中搜索中间子字符串未被选中的字符串
- 如何从字符串中间开始的子字符串
- 从中间器转换字符串不起作用,出了什么问题?
- 在std::字符串或字符数组中间包含NULL字符的UPDATE
- 如何分辨 boost::split_iterator 从字符串中间开始
- 如何打印在中间包含0个字符的字符串
- 矢量字符串字符替换在字符串c++的中间
- 我怎么能在C++中的文件名中间使用字符串值呢
- 如何在序列化期间插入字符串流的中间
- 如何为字符串分配一个从数组中间开始的char数组
- 如何使用c++解析文本文件从中间到特定字符串
- 如何清除包含C函数声明的字符串中的注释和中间空白
- Ispunct()不删除字符串中间的逗号
- 在文本文件中间附加字符串
- 从文件中读取整数,中间有一个字符串
- 如何以特定格式将数字打印到字符串的中间