C ++对象持久性库类似于永恒 [英] C++ object persistence library similar to eternity
问题描述
我正在寻找一个C ++对象持久性库来替换永久库,我已经原型化了大约一天。
我有一个 std :: list
的 ArchiveJob *
,我想坚持并以XML格式恢复。每个 ArchiveJob
有各种子对象,一些分配在堆栈上,一些在堆上。
永恒
(对于熟悉Eternity的用户,以下还原操作无法从XML中读取任何数据文件)
xml_read(sequence< pointers>(),* pList,pList-> begin(),xml,ScheduleList );
此调用为 ArchiveJob
对象分配内存
有人可以推荐对象层次结构持久化解决方案:
- 可以保留/恢复STL容器
- 是Windows开发人员友好的(例如,如果需要构建,是否有VS200x解决方案文件)
- 可以处理复杂的对象层次结构
我应该花时间学习 XML序列化与boost ?如何处理存储在STL容器中的主对象中的复杂对象层次结构?
Boost序列化是您需要的:
其实我错了,它包括 VS7.1解决方案文件
I'm looking for a C++ object persistence library to replace the Eternity library that I've been prototyping with for about a day. The Eternity library came up short.
I've created an object hierarchy similar to this:
I have an std::list
of ArchiveJob*
's that I'd like to persist and restore in XML format. Each ArchiveJob
has various child objects, some allocated on the stack, some on the heap.
Eternity did a good job of persisting these objects correctly, but it failed when restoring them.
(for those familiar with Eternity, the following "restore" operation failed to read any data from the XML file)
xml_read( sequence<pointers>(), *pList, pList->begin(), xml, "ScheduleList" );
This call allocated memory for the ArchiveJob
object, but all its children were uninitialized.
Can someone recommend an object hierarchy persistence solution that:
- Can persist / restore STL containers
- Is windows developer friendly (e.g. if it needs built, does it have a VS200x solution file)
- Can handle complex object hierarchies
Should I spend time learning XML serialization with boost? How does it handle complex object hierarchies stored in a master object in an STL container?
Boost Serialization is what you need:
- serializing containers
- it's cross-platform and windows-friendly despite the fact that it doesn't have VS2008 solution file
- serializing derived class
[EDIT] actually I was wrong, it includes VS7.1 solution file
这篇关于C ++对象持久性库类似于永恒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!