简体   繁体   English

boost :: serialization - 有一种可移植的方式来二进制序列化std :: wstrings吗?

[英]boost::serialization - is there a portable way to binary-serialize 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. 我想用boost :: serialization在同一台Windows机器上序列化32位进程和64位进程之间的一些数据结构。

This answer suggests using eos::portable_iarchive, but when I tried that, I got a STATIC_ASSERT failure: 这个答案建议使用eos :: portable_iarchive,但是当我尝试使用它时,我遇到了STATIC_ASSERT故障:

// 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? 是否有不同的方法来执行此操作(除了text_iarchive我不想用于性能考虑因素),它还支持std :: wstrings?

From what I've read, the standard approach to serializing wide-character strings is to first encode them as UTF-8 narrow-character strings. 根据我的阅读,序列化宽字符串的标准方法是首先将它们编码为UTF-8窄字符串。 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. 在Boost.Serialization示例目录中有可移植二进制存档的替代实现。 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. Boost.Serialization文档听起来像它最大的缺点是缺乏便携式浮点支持和缺乏严格的测试,因此如果您不需要便携式浮动,它可能满足您的需求。

I don't know if you've looked at other serialization libraries or not, but there are several alternatives, including libs11n and Protocol Buffers . 我不知道你是否看过其他序列化库,但有几种选择,包括libs11nProtocol Buffers (Personally, having used both Boost.Serialization and Protocol Buffers, I prefer Protocol Buffers.) (就个人而言,使用了Boost.Serialization和Protocol Buffers,我更喜欢Protocol Buffers。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM