Skip to content

Latest commit

 

History

History
39 lines (30 loc) · 1.08 KB

README.md

File metadata and controls

39 lines (30 loc) · 1.08 KB

Project-U-

coming soon #include <msgpack.hpp> #include #include #include

int main(void) { msgpack::type::tuple<int, bool, std::string> src(1, true, "example");

// serialize the object into the buffer.
// any classes that implements write(const char*,size_t) can be a buffer.
std::stringstream buffer;
msgpack::pack(buffer, src);

// send the buffer ...
buffer.seekg(0);

// deserialize the buffer into msgpack::object instance.
std::string str(buffer.str());

msgpack::object_handle oh =
    msgpack::unpack(str.data(), str.size());

// deserialized object is valid during the msgpack::object_handle instance is alive.
msgpack::object deserialized = oh.get();

// msgpack::object supports ostream.
std::cout << deserialized << std::endl;

// convert msgpack::object instance into the original type.
// if the type is mismatched, it throws msgpack::type_error exception.
msgpack::type::tuple<int, bool, std::string> dst;
deserialized.convert(dst);

return 0;

} why tf are you reading this