在 C 中序列化数据结构 [英] Serialize Data Structures in C

查看:26
本文介绍了在 C 中序列化数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个 C 库,它可以将我的数据结构序列化到磁盘,然后再加载它们.它应该接受任意嵌套的结构,可能带有循环引用.

I'd like a C library that can serialize my data structures to disk, and then load them again later. It should accept arbitrarily nested structures, possibly with circular references.

我认为这个工具需要一个描述我的数据结构的配置文件.该库允许使用代码生成,尽管我很确定没有它也可以做到这一点.

I presume that this tool would need a configuration file describing my data structures. The library is allowed to use code generation, although I'm fairly sure it's possible to do this without it.

注意我对数据可移植性不感兴趣.我想用它作为缓存,这样我就可以依靠环境不变.

Note I'm not interested in data portability. I'd like to use it as a cache, so I can rely on the environment not changing.

谢谢.

结果

有人建议 Tpl 这是一个很棒的库,但我相信它不会做任意对象图,例如一个节点树,每个节点包含两个其他节点.

Someone suggested Tpl which is an awesome library, but I believe that it does not do arbitrary object graphs, such as a tree of Nodes that each contain two other Nodes.

另一个候选对象是 Eet,其中是Enlightenment 窗口管理器的一个项目.看起来很有趣,但同样,似乎没有序列化嵌套结构的能力.

Another candidate is Eet, which is a project of the Enlightenment window manager. Looks interesting but, again, seems not to have the ability to serialize nested structures.

推荐答案

查看 tpl.从概述:

Tpl 是一个用于序列化 C 的库数据.数据存储在其自然的二进制形式.API很小并试图保持不碍事".与使用 XML 相比,tpl 更快并且更容易在 C 程序中使用.TPL可以序列化许多 C 数据类型,包括结构.

Tpl is a library for serializing C data. The data is stored in its natural binary form. The API is small and tries to stay "out of the way". Compared to using XML, tpl is faster and easier to use in C programs. Tpl can serialize many C data types, including structures.

这篇关于在 C 中序列化数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆