boost serialization: toString/fromString methods

Dear group,
I am trying to provide generic toString/fromString methods (to provide
an interface to SWIG/Python serialization), which I'd like to implement
in a base class CSGObject (from which all other classes are derived),
such that the correct serialization code is called each time.
After a bit of fiddling around (and with the help of the archive of this
mailing list) I've got the toString method to work. However, things
don't seem to be as straight for the fromString method.
The following code illustrates what I'd like to do:
virtual std::string toString() const
{
std::ostringstream s;
boost::archive::text_oarchive oa(s);
oa << this;
return s.str();
}
virtual void fromString(std::string str)
{
std::istringstream is(str);
boost::archive::text_iarchive ia(is);
//cast away constness
CSGObject* tmp = const_cast
participants (1)
-
Christian Widmer