c++ - C++ boost 二进制序列化库是否向后/向前兼容?

标签 c++ serialization boost

Possible Duplicate:
Boost Serialization Library upgrade

我正在尝试为 C++ 应用程序寻找序列化解决方案。我真的很想能够使用 boost 二进制序列化。如果我要使用旧版本的 boost 二进制序列化库来序列化一个对象,那么使用新版本的 boost 库的应用程序是否总是能够读取它?反过来呢? boost 对序列化库的向后/兼容性的理念是什么?

最佳答案

他们通过增加标题中的版本来做到这一点。所以是的,从某种意义上说,它是兼容的,如果您尝试读取使用不兼容版本序列化为 1.45.0 release notes 的二进制数据,您将遇到正常的失败。倾向于表示。而且 1.42 和 1.43 中的 bug 会破坏它!

Native binary archives created under versions 1.42 and 1.43 suffer from a serious problem. It's likely they won't be readable by this latest version. This due to the fact that 1.42 made some changes in the binary format of some types. Normally this could be addressed by detecting the library version number written into the archive header. Unfortunately, this library version number was not incremented at 1.42 as it should have been. So now we have two different binary archive versions with the same library version number.

我个人会更相信 Google Protocol Buffers , 它explicitly maintains backwards compatibility :

You can add new fields to your message formats without breaking backwards-compatibility; old binaries simply ignore the new field when parsing.

但是,它需要在构建系统方面付出更多努力,因为它涉及使用自动生成的代码。

关于c++ - C++ boost 二进制序列化库是否向后/向前兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7583216/

相关文章:

java - 意外的 token (END_OBJECT),应为FIELD_NAME : missing property '@type' that is to contain type id

c# - JSONResult 到字符串

c++ - 多个端口的多个线程?

c++ - 使用前导和尾随空格 boost spirit 解析字符串

c++ - boost C++ 序列化/反序列化

c++ - 如何链接到运行时可能不存在的目录?

c++ - gcc 看不到标准头文件

c++ - 在我的函数中删除对 boost::bind 的需要

c++ - 成员对象作为 unique_ptr 或在堆栈上

c++ - 为什么在成员函数中返回对 ostream 对象的引用以进行序列化