That works. Some things I notice:

1) The xml file created has an attribute in the object tag called "class_name", containing the name of the derived type. This attribute does not exist in an xml file created using derived type pointers. I guess this is the critical piece of information needed to reconstruct a derived type using a base class pointer.

2) It also works if you create a derived class pointer/object, static_cast the derived type pointer to a base class pointer and pass the base class pointer to the serialization.

3) someInXMLArchive >> boost::serialization::make_nvp("", someTypePtr); works, which is surprising since I am passing an empty string for a tag. It appears serializing in ignores tag names and just processes data until the class is constructed or a stream error occurs.

4) Calling close on the output file stream (e.g. std::ofstream::close) causes the closing boost_serialization tag, </boost_serialization> to NOT be written to the file. Is this an issue that needs to be resolved or am I doing something else wrong?

Thanks a bunch for all the help. Hopefully I'll be running on my own now. Please feel free to comment on my observations above, however.

Regards,
Daniel Roberts




What happens if you try the following:



TestBase * pT1 = new TestType1;

TestBase* pT2 = new TestType2;

testOutXML << boost::serialization::make_
nvp("pT1", pT1);

testOutXML << boost::serialization::make_nvp("pT2", pT2);

testTypeOFS.close();

delete pT1;

delete pT2;

...

testInXML >> boost::serialization::make_nvp("pT1", pTB);

testInXML >> boost::serialization::make_nvp("pT2", pTB);

Robert Ramey