|
Boost Users : |
Subject: Re: [Boost-users] Developing a new boost archive
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-02-15 15:20:00
Larry Evans wrote:
> Looking at:
>
> http://www.boost.org/doc/libs/1_48_0/libs/serialization/doc/serialization.html#derivedpointers
>
> and reading:
>
> The system "registers" each class in an archive the first time an
> object of that class it is serialized and assigns a sequential
> number to it. Next time an object of that class is serialized in
> that same archive, this number is written in the archive. So every
> class is identified uniquely within the archive. When the archive
> is read back in, each new sequence number is re-associated with the
> class being read. Note that this implies that "registration" has to
> occur during both save and load so that the class-integer table
> built on load is identical to the class-integer table built on
> save. In fact, the key to whole serialization system is that things
> are always saved and loaded in the same sequence. This includes
> "registration".
>
> And paraphrasing part as:
>
> So every class is identified by this uniquely assigned sequential
> number within the archive.
>
> Then I'd infer that this "uniquely assigned sequential number" play
> a role similar to the role of the result of:
>
> abi::__cxa_demangle( typeid( T ).name(), 0, 0, NULL );
>
> in Roberto's post:
>
> http://article.gmane.org/gmane.comp.lib.boost.user/72805
>
> As you mention, Roberto's method is not portable between platforms
> (where, of course, a different compiler or even different version
> of the same compiler would be a different platform).
>
Just a slight clarification.
Both the "registration" method and the "export" method address the exact
same problem:
How does one know what kind to object to create when it is serialized
through a base class?
The library implements two different methods. Each method has it's own
advantages
and disadvantages and I believe that both methods are commonly used.
> OTOH, as you also mention in the above quote, boost serialization
> requires:
>
> things are always saved and loaded in the same sequence.
>
> Roberto, would that be a problem for you?
Note that is a fundamental feature/restriction of this serialization
library.
The archive format is driven by the C++ class data structure. This
is what gives it it's simplicity of use and high performance.
A different library - the closest boost library is spirit - would take
an externally defined syntax and map any file in that syntax to
some C++ data structure. This is an entirely different problem.
It's easy to fall in the trap of confusing these two jobs.
Of course if one had nothing else to do, he could make an
archive class which would generate an archive (data file) along
with spirit karma/qi grammars which would support editing
of that archive. But of course that would be - as they say -
beyond the scope of this course.
Robert Ramey
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net