Boost logo

Boost :

From: Marcin Kalicinski (kalita_at_[hidden])
Date: 2006-04-21 17:10:41


> Use Serialization lib for this.
>
>> But some values are also only human editable (not on the system setup
>> display etc) so simple XML based files work well because they can easily
>> be read/written by a person and the software itself.
>
> There many ways to deal with it. For example you could keep these fields
> as strings in memory or use separate storage for them or teach
> boost::serialization to save/load them.

I have recently tried to do just this. Not subtracting from the great value
of serialization library, it has a nasty habit of polluting XML files it
generates with all sorts of magic id numbers that definitly are not human
editable or creatable. By creating my own archive class I was able to get
rid of most of them, but not all. Some (class-id integers and tracking-id
integers) are so inherently embedded in the library that it would require
quite an effort to hack them out.

To be able to hand-edit XML serialization files, I needed to replace
class-id integers with class names (the ones you specify to
BOOST_SERIALIZATION_EXPORT macros). Initially I thought it will be easy, but
I was wrong. Entire dynamic instantiation mechanism in serialization library
seems to depend heavily on these integer ids. It only uses names when class
is first seen, and there is not id for it yet. I then tried to use sure-fire
method ;-) , which failed as well. Briefly, I made my archive class to
generate fake class-ids from class names (in an effort to predict which id
would be expected now by serialization). It failed for reasons I cannot
recall at the moment - they had something to do with inheritance
hierarchies.

In case of tracking-ids I just wanted them out, because I do not have
duplicate objects in human-created files. On the other hand, I couldn't
disable tracking per-class, because I still wanted other archives to do
tracking on these objects. A couple of days ago I even posted a question for
Robert, and he says that I would need to create my own version of
tracking.hpp.

So as you can see it is not all roses with serialization library and human
readable files.

Best regards,
Marcin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk