I am looking for a sample how to pack ext types with msgpack in C++ as I am not sure about how to do this.
The only information I found is located in this section https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_packer#pack-manually.
Assumed I want to pack an object of type Foo as a msgpack ext type with an adaptor class template. How to use pack_ext
and pack_ext_body
? Do I have to create a "sub packer" within the template, pack my Foo data manually and then pass size of the binary data and the data itself to pack_ext
and pack_ext_body
? It would be create if some C++ expert could give me a minimal example.
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
namespace adaptor {
template<>
struct pack<Foo> {
template <typename Stream>
packer<Stream>& operator()(msgpack::packer<Stream>& o, Foo const& v) const {
// how to use ?
o.pack_ext(size_t l, int8_t type);
o.pack_ext_body(const char* b, size_t l);
}
}
}
}
Thanks in advance!