I have a C++ library that uses Boost.Serialization. I'm creating Python bindings for this library using Boost.Python. It's fairly clear how to make a pickle suite for Boost.Python that uses Boost.Serialization (save to a string using Boost.Serialization, and return that string to Python).
What I want is the reverse: given a boost::python::object
, I want to have a serialize(...)
function that would call Python's pickle.dumps()
function and serialize the resulting string. (Imagine an std::vector<boost::python::object>
. As I serialize this vector, Boost.Serialization would call the auxiliary serialize()
function.) Is this possible? Better yet, is it possible to use cPickle
and bypass giving the control to the Python interpreter?
namespace boost{namespace serialization{ template<class Archive> void serialize(Archive& a, boost::python::object& obj, const unsigned version){ /*...*/; } }}
should do the trick, but before I try... Thanks! – Orchestrion