• Advertisement
Sign in to follow this  

A way to wrap the boost::serialization library

This topic is 3970 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

/* std::string language("CPP"); */ Hi everyone, I'm building a game engine (actually a framework is a better definition of it), and i'm exporting it for use in python with the help of boost::python library. I'm using boost::serialization in the engine (for saves/loads primarily), and because the library can't be used natively in python I've created a wrapper for it. I have to classes: ArchiveIn and ArchiveOut, both of SerializeArchive abstract type. I have a Serializable abstract class which classes that implement serialization inherit from, and it contains two functions to manage calls from boost::serialization and direct the calls to a virtual function that uses one of the archives mentioned above to serialize themselves. All works nicely so far, except for when it comes to serializing a base class, and registering a derived class, both of them using templates which I can't use through python AFAIK. to serialize a base class i need to call
ar & boost::serialization::base_object<base_class>(*this);


from the derived class (ar being one of the archives). Note that boost strongly advices against calling the serializing function of the base class directly. and to register a derived class (to be able to serialize/unserialize an derived object from a base class pointer) i can use either a macro in the class definition (which i prefer) :
BOOST_CLASS_EXPORT_GUID(derived, "derived")


or a function to register the type:
ar.template register_type<derived_one>();


I can't figure out a way to export these functions safely to python. Can anyone help? thanks !!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement