|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2002-12-18 01:17:51
From: brangdon_at_[hidden] (Dave Harris)
>Will it be able to load files from existing 3rd party formats?
>For example, I currently have a lot of data stored in Microsoft's MFC
>archive format. This includes very little metadata beyond the version
>number. The meaning of fields is defined by their order in the archive,
>and they have a particular system for mapping class names onto object
>factories. Much of this is moderately lame - eg it doesn't support
>namespaces. It will be much easier to switch to the new boost framework if
>archives in the old format can still be loaded (without having 2 lots of
>code).
>Is this a reasonable design objective?
I believe that it is more than reasonable.
The latest submission could handle this pretty easily:
When loading
a) Add the new serialization declarations to your current MFC classes
b) Derive from CArchive to read the first few bytes of data
c) if it looks like the new serialization preamble, seek to 0 and invoke
ar >> doc; where doc is the highest level object - usually derived from
CDocument.
When Saving
a) create a new boost::archive leaving the file name the same.
b) ar << doc
your done.
Eventually when all your old files have been processed, you can
remove the old MFC serialization code from your classes.
I don't think it would be too much harder than that.
To summarize, if one already has a method to build objects from a file
then the serialization scheme doesn't have to re-implement it. The
serialization scheme is not dependent on the file format but just
the class structure once its loaded.
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk