C++支持部分序列化的序列化库?

发布于 2024-08-13 11:49:11 字数 1539 浏览 5 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深海夜未眠 2024-08-20 11:49:11

您显然不是在这里寻找序列化。

序列化是保存一个对象,然后从字节流中重新创建它。想想视频游戏保存或网络服务器的会话上下文。

这里你需要的是消息传递。 Google 的 FlatBuffers 对此非常有用。指定一条消息,其中包含每个可选字段,收到消息后,使用确实存在的字段更新您的对象,并保持其他字段不变。

FlatBuffers 的伟大之处在于,除了零成本解析步骤之外,它还可以很好地处理向前和向后兼容性,以及文本和二进制编码(文本非常适合调试,二进制更适合纯性能)。

如果您将消息保存在某个地方并且想要拼凑一个 html gui 来检查它,您甚至可以使用另一种语言(例如 python 或 ruby​​)来解码消息!

You're clearly not looking for serialization here.

Serialization is about saving an object and then recreating it from the stream of bytes. Think video games saves or the session context for a webserver.

Here what you need is messaging. Google's FlatBuffers is nice for that. Specify a message that will contain every single field as optional, upon reception of the message, update your object with the fields that do exist and leave the others untouched.

The great thing with FlatBuffers is that it handles forward and backward compatibility nicely, as well as text and binary encoding (text being great for debugging and binary being better for pure performance), on top of a zero-cost parsing step.

And you can even decode the messages with another language (say python or ruby) if you save them somewhere and want to throw together a html gui to inspect it!

秋叶绚丽 2024-08-20 11:49:11

虽然我对它们不熟悉,但您也可以查看 Google 的 Protocol Buffers

Although I'm not familiar with them, you could also check out Google's Protocol Buffers
.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文