C++ object persistence library similar to eternity

拈花ヽ惹草 提交于 2019-12-10 20:16:51

问题


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?


回答1:


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




回答2:


another alternative is Google Protocol Buffers. It's not XML based if you're bound strictly to XML. It's also a bit more complicated since you need to use special syntax in external files. About hierarchy you can read this discussion



来源:https://stackoverflow.com/questions/4804653/c-object-persistence-library-similar-to-eternity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!