Boost logo

Boost Users :

From: Mahesh Venkitachalam (mkvenkit.vc_at_[hidden])
Date: 2007-12-19 10:45:43


On Dec 19, 2007 6:52 PM, Andrei Popa <andrei4popa_at_[hidden]> wrote:

>
> I just discovered the serialization library found it extremely nice and
> useful.
> I appreciate all work of the author.
> I have not yet build any program with the library, I just read the
> documentation.
> There is one think that do not fit to my use: "typeid information is not
> included in archives".
> The reason is "archive portability" and the solution "same sequence by
> save/load".
> But what if I do not know the sequence? What can I do then?
> Think about a CAD program. I do not know what the user will draw, a line,
> circle, rectangle and so on.
> And I have to save them in a file, at the load I need to know what type of
> object do I load.
> For me the "archive portability" is not so important.
> Is there a way to configure/change the library to save the name of the
> class specified by std::type_of::name() in the archive?
>

I am doing something very similar to what you mention above. What I do is
to store pointers to the objects (shared_ptr actually) as base class ptrs
in the archive. When I read the archive in, I do a dynamic_cast, and I get
the original object back - works very well. I haven't used typeid, so it is
possible that I haven't understood your question...

Mahesh



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