将数据结构写入文件 [英] Writing a data structure to a file
问题描述
我是这个话题的新手。我对此的理解来自这个主题:
在C ++中创建与文件扩展名相关联的自定义数据结构 [ ^ ]
解决了我对文件扩展名与内部数据结构的混淆文件。有些延伸无关。
我想要做的是,为很多文件创建一个容器,以便根据负载动态加载/卸载到内存中。
现在,我处于可以创建数据结构的阶段,然后必须嵌入容器中。我是这个主题的新手。一个小例子或者算法可以帮助我开始。
任何帮助表示感谢!
我尝试了什么:
浏览文章:
http://www.cplusplus.com/doc/tutorial/files/
http://www.ocoudert.com/blog/2011/07/09/a-practical-guide-to-c-serialization/
I am new to this topic. My understanding about this came from this thread :
Creating a custom data structure associated with a file extension in C++[^]
Resolved my confusion about file extension vs data structure inside the file. To some extend unrelated.
What I want to do is, Create a container for a lot of files, so that they are loaded/unloaded into the memory dynamically based on the load.
For now, I am at the stage where I can create a data structure, then have to embed inside a container. I am a novice in this topic. A small example or perhaps an algorithm will help me get started.
Any help appreciated !
What I have tried:
Going through articles :
http://www.cplusplus.com/doc/tutorial/files/
http://www.ocoudert.com/blog/2011/07/09/a-practical-guide-to-c-serialization/
推荐答案
一种强有力的方法由boost提供:
序列化 [ ^ ] ,
序列化 - 教程 [< a href =http://www.boost.org/doc/libs/1_60_0/libs/serialization/doc/tutorial.html\"target =_ blanktitle =New Window> ^ ]。
另见本指南: C ++序列化实用指南 [ ^ ]。
参见:
标准C ++ [ ^ ],
C ++中数据序列化技术的概述RubénTorresBonet [ ^ ],
所有你需要的是C ++ 11:我对C ++序列化的看法(第一部分:get_size) [ ^ ]。
-SA
One robust approach is offered by boost:
Serialization[^],
Serialization — Tutorial[^].
See also this guide: A Practical Guide To C++ Serialization[^].
See also:
Standard C++[^],
An overview of data serialization techniques in C++ | Rubén Torres Bonet[^],
All You Need is C++11: My take on C++ serialization (Part I: get_size)[^].
—SA
这篇关于将数据结构写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!