9#include <rpc/msgpack.hpp>
19 namespace mp = ::clmdep_msgpack;
23 return Buffer(
reinterpret_cast<const unsigned char *
>(sbuf.data()), sbuf.size());
29 namespace mp = ::clmdep_msgpack;
32 return mp::unpack(
reinterpret_cast<const char *
>(buffer.
data()), buffer.
size()).template as<T>();
37 static T
UnPack(
const unsigned char *data,
size_t size) {
38 namespace mp = ::clmdep_msgpack;
41 return mp::unpack(
reinterpret_cast<const char *
>(data), size).template as<T>();
一块原始数据。 请注意,如果需要更多容量,则会分配一个新的内存块,并 删除旧的内存块。这意味着默认情况下,缓冲区只能增长。要释放内存,使用 clear 或 pop。
const value_type * data() const noexcept
直接访问分配的内存,如果没有分配内存则返回 nullptr。
size_type size() const noexcept
static T UnPack(const Buffer &buffer)
static T UnPack(const unsigned char *data, size_t size)
static Buffer Pack(const T &obj)