boost::serialization - 是否有一种可移植的方法来二进制序列化 std::wstrings?
我想使用 boost::serialization 在同一台 Windows 机器上的 32 位进程和 64 位进程之间序列化一些数据结构。
此答案建议使用 eos::portable_iarchive ,但是当我尝试这样做时,我得到了 STATIC_ASSERT 失败:
// implementation only valid for narrow string
BOOST_STATIC_ASSERT(sizeof(C) == sizeof(char));
是否有其他方法可以做到这一点(除了text_iarchive 出于性能考虑我不想使用它)也支持 std::wstrings 吗?
I want to serialize some data-structures between a 32bit process and a 64bit process on the same windows machine with boost::serialization.
This answer suggests using eos::portable_iarchive, but when I tried that, I got a STATIC_ASSERT failure:
// implementation only valid for narrow string
BOOST_STATIC_ASSERT(sizeof(C) == sizeof(char));
Is there a different way to do this (other than text_iarchive what I don't want to use for perf considerations) that supports std::wstrings as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,序列化宽字符字符串的标准方法是首先将它们编码为 UTF-8 窄字符字符串。不过,这可能会比您想要的更多。
Boost.Serialization 示例目录中有可移植二进制存档的替代实现。 Boost.Serialization 文档 使其成为可能听起来它最大的缺点是缺乏便携式浮点支持并且缺乏严格的测试,所以如果你不需要便携式浮点,它可能会满足你的需求。
我不知道您是否看过其他序列化库,但有几种替代方案,包括 libs11n 和协议缓冲区。 (就我个人而言,在使用了 Boost.Serialization 和 Protocol Buffers 后,我更喜欢 Protocol Buffers。)
From what I've read, the standard approach to serializing wide-character strings is to first encode them as UTF-8 narrow-character strings. This may be more overhead than you want, though.
There's an alternative implementation of a portable binary archive in the Boost.Serialization example directory. The Boost.Serialization documentation makes it sound like its biggest shortcomings are lack of portable floating point support and lack of rigorous testing, so if you don't need portable floats, it may meet your needs.
I don't know if you've looked at other serialization libraries or not, but there are several alternatives, including libs11n and Protocol Buffers. (Personally, having used both Boost.Serialization and Protocol Buffers, I prefer Protocol Buffers.)