I made my own test program similar to test_no_rtti.cpp, only simpler. I have one base class and two classes that derive from it. All three classes are registered using BOOST_CLASS_EXPORT. I create an instance of each derived class and serialize them to an xml file. I then reload the file and try to serialize to a base class pointer and an "unregistered class" exception is thrown. I have stepped through my code and most of the boost serialization code and can not find a problem. The xml file looks good after creation but for some reason boost can not serialize it in properly. I have attached my short program. Can someone please tell me what I am doing wrong? Many thanks, Daniel Roberts
AMDG Daniel Roberts wrote:
I made my own test program similar to test_no_rtti.cpp, only simpler. I have one base class and two classes that derive from it. All three classes are registered using BOOST_CLASS_EXPORT. I create an instance of each derived class and serialize them to an xml file. I then reload the file and try to serialize to a base class pointer and an "unregistered class" exception is thrown. I have stepped through my code and most of the boost serialization code and can not find a problem. The xml file looks good after creation but for some reason boost can not serialize it in properly. I have attached my short program. Can someone please tell me what I am doing wrong? Many thanks,
You're trying to write with testOutXML << boost::serialization::make_nvp("TestType1", pT1); and read with testInXML >> boost::serialization::make_nvp("TestBase", pTB); The names need to be the same. e.g. testOutXML << boost::serialization::make_nvp("TestBase", pT1); testInXML >> boost::serialization::make_nvp("TestBase", pTB); In Christ, Steven Watanabe
Only polymophic types can be serialized through a base class pointer.
Robert Ramey
"Daniel Roberts"
participants (3)
-
Daniel Roberts
-
Robert Ramey
-
Steven Watanabe