// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma // de Barcelona (UAB). // // This work is licensed under the terms of the MIT license. // For a copy, see . #pragma once #include "carla/Buffer.h" #include namespace carla { class MsgPack { public: template static Buffer Pack(const T &obj) { namespace mp = ::clmdep_msgpack; mp::sbuffer sbuf; mp::pack(sbuf, obj); return Buffer(reinterpret_cast(sbuf.data()), sbuf.size()); } template static T UnPack(const Buffer &buffer) { namespace mp = ::clmdep_msgpack; return mp::unpack(reinterpret_cast(buffer.data()), buffer.size()).template as(); } template static T UnPack(const unsigned char *data, size_t size) { namespace mp = ::clmdep_msgpack; return mp::unpack(reinterpret_cast(data), size).template as(); } }; } // namespace carla