
I'm creating a simple file that is serializing several classes to a file. The problem is the order and the number of the of the objects saved in the file, depending on the options the user selects, 1 or 3 classes can be stored, I'm confused on how to call deserializer process for this case? Maybe use the rtti type and then call the correct deserializer? For example: class baseObj { // Code // serialize code }; class optionObj : public baseObj { //Code // Serial // BOOST_SERIALIZATION_BASE_OBJECT_NVP(baseObj); // etc }; class configObj : public baseObj { //Code // Serial // BOOST_SERIALIZATION_BASE_OBJECT_NVP(baseObj); // etc }; saveData( std::string fileInfo) { // code if (userSaveConfig ) os << saveConfig; if (optionSave) os < saveOptions; } getData(std::string fileInfo) { // clueless.. 1. how to determine the order the class has been saved? }

How about the following? saveData( std::string fileInfo) { os << userSaveConfig; if (userSaveConfig ) os << saveConfig; if (optionSave) os < saveOptions; } getData(std::string fileInfo) { int userSaveConfig; os >> userSaveConfig if (userSaveConfig ) os << saveConfig; if (optionSave) os < saveOptions; } Robert Ramey

Yes, this can work, and is a straight forward implementation. But is there anyway to use the RTTI information? Or some how using the BOOST_CLASS_IMPLEMENTATION(my_class, boost::serialization::object_class_info) to add class name and reference this? Or something like the test_no_rrti.cpp example, but using rtti embedded infromation?
From: "Robert Ramey" <ramey@rrsd.com> Reply-To: boost@lists.boost.org To: boost@lists.boost.org Subject: [boost] Re: Serializing using RTTI Date: Mon, 11 Apr 2005 17:40:04 -0700
How about the following?
saveData( std::string fileInfo) { os << userSaveConfig; if (userSaveConfig ) os << saveConfig; if (optionSave) os < saveOptions; }
getData(std::string fileInfo) { int userSaveConfig; os >> userSaveConfig if (userSaveConfig ) os << saveConfig; if (optionSave) os < saveOptions; }
Robert Ramey
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Maybe - but RTTI strings aren't portable. You might also want to look at variant serialization checked into CVS Robert Ramey Tim Michals wrote:
Yes, this can work, and is a straight forward implementation. But is there anyway to use the RTTI information? Or some how using the BOOST_CLASS_IMPLEMENTATION(my_class, boost::serialization::object_class_info) to add class name and reference this? Or something like the test_no_rrti.cpp example, but using rtti embedded infromation?
From: "Robert Ramey" <ramey@rrsd.com> Reply-To: boost@lists.boost.org To: boost@lists.boost.org Subject: [boost] Re: Serializing using RTTI Date: Mon, 11 Apr 2005 17:40:04 -0700
How about the following?
saveData( std::string fileInfo) { os << userSaveConfig; if (userSaveConfig ) os << saveConfig; if (optionSave) os < saveOptions; }
getData(std::string fileInfo) { int userSaveConfig; os >> userSaveConfig if (userSaveConfig ) os << saveConfig; if (optionSave) os < saveOptions; }
Robert Ramey
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
Robert Ramey
-
tcmichals
-
Tim Michals