[boost] [serialization] typeid information is not included in archives

Hallo all,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?Best regards,Andrei _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

On Dec 19, 2007 6:52 PM, Andrei Popa <andrei4popa@hotmail.com> 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

Why aren't you just using viritual functions on the base class pointer? Robert Ramey 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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Dec 19, 2007 10:25 PM, Robert Ramey <ramey@rrsd.com> wrote:
Why aren't you just using viritual functions on the base class pointer?
Robert Ramey
I do that, but there are cases where I need to to specialized operations based on the type of object I read back in, and for those I use dynamic_cast. Mahesh

look at the demo in the tutorial and the associated demo. It handles exactly the situation you describe. Look at the documentation under Export Robert Ramey "Andrei Popa" <andrei4popa@hotmail.com> wrote in message news:BAY104-W9813D6D7DBBCD9A35DC0CE05C0@phx.gbl... Hallo all, 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? Best regards, Andrei ------------------------------------------------------------------------------ Express yourself instantly with MSN Messenger! MSN Messenger ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Andrei Popa
-
Mahesh Venkitachalam
-
Robert Ramey