lundi 5 août 2019

serialize an object in C++ to be deserialized by both C++/python

I'm looking for a good way to serialize an object to disk in C++, and be deserialized by both C++/Python.

Historically, I've been just grabbing an object and writing it to a file using a std::ofstream. Looking back, that seems like a terrible idea.

The first thing that comes to mind is to use protobuf, or the different offsprings like capnproto. The only thing I don't love about it is that it'd require to go back and change all my old files. I'd need to make 1 big job to read all my old files, read in object by object, create the protobuf object, and then write it back out. If I'm going through all the trouble, I want to be super sure that I'm picking the best way.

I also came across this Pickling library -http://www.picklingtools.com/, http://www.picklingtools.com/html/usersguide.html.

But, I don't see how this is better than the protobuf way.

Aucun commentaire:

Enregistrer un commentaire