C ++对象持久性库类似于永恒 [英] C++ object persistence library similar to eternity

查看:214
本文介绍了C ++对象持久性库类似于永恒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个C ++对象持久性库来替换永久库,我已经原型化了大约一天。



src =http://i.stack.imgur.com/I0djo.pngalt =object heirarchy>



我有一个 std :: list ArchiveJob * ,我想坚持并以XML格式恢复。每个 ArchiveJob 有各种子对象,一些分配在堆栈上,一些在堆上。



永恒



(对于熟悉Eternity的用户,以下还原操作无法从XML中读取任何数据文件)

  xml_read(sequence< pointers>(),* pList,pList-> begin(),xml,ScheduleList ); 

此调用为 ArchiveJob 对象分配内存



有人可以推荐对象层次结构持久化解决方案:


  1. 可以保留/恢复STL容器

  2. 是Windows开发人员友好的(例如,如果需要构建,是否有VS200x解决方案文件)

  3. 可以处理复杂的对象层次结构

我应该花时间学习 XML序列化与boost ?如何处理存储在STL容器中的主对象中的复杂对象层次结构?

解决方案

Boost序列化是您需要的:


  1. 序列化容器

  2. 尽管它没有VS2008解决方案文件,但它仍是跨平台和Windows友好的

  3. 序列化派生类

其实我错了,它包括 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:

  1. Can persist / restore STL containers
  2. Is windows developer friendly (e.g. if it needs built, does it have a VS200x solution file)
  3. 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:

  1. serializing containers
  2. it's cross-platform and windows-friendly despite the fact that it doesn't have VS2008 solution file
  3. serializing derived class

[EDIT] actually I was wrong, it includes VS7.1 solution file

这篇关于C ++对象持久性库类似于永恒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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