Custom class Serialization of classes, C ++ and msgpack


I am brand new trying msgpack. I need to serialize an object (an instance of a user-defined class) that contains pointers (internal tree, hashes, etc.) and some basic attribute types.

So far, I can do what is done in the wiki msgpack.org short example, just serialize the class in msgpack::sbuffer, and then read the buffer for unserialize.

But now I want to send this buffer to a file or the serialization result to a file, and then non-esterize it.
Can someone give me some tips on how to do this? I browse and read enough to get tired of it :)

My code looks like this:

msgpack::sbuffer sbuf;
msgpack::pack(sbuf, cluster); //cluster is the instance of my class clustering

//HERE I SHOULD SEND THE BUFFER TO A STREAM FILE, AND THEN LOAD IT IN THE UNPACK;

msgpack::unpacked msg;
msgpack::unpack(&msg, sbuf.data(), sbuf.size()); 
msgpack::object obj = msg.get();
clustering clustUnser
obj.convert(&clustUnser);

Thanks everyone!
Bests,
Luchux.

+5
1

:

http://wiki.msgpack.org/pages/viewpage.action?pageId=1081387

, sbuf.data() , sbuf.size() , .

, msgpack:: unpack.

+3

All Articles