2#ifdef MSGPACK_DEFINE_MAP
3#error "webcface/common/internal/pack.h must be included first"
13#ifdef WEBCFACE_COMPILER_IS_GCC
14#pragma GCC diagnostic push
15#pragma GCC diagnostic ignored "-Wabi"
17#include <spdlog/logger.h>
18#ifdef WEBCFACE_COMPILER_IS_GCC
19#pragma GCC diagnostic pop
39std::vector<std::pair<int, std::shared_ptr<void>>>
40unpack(
const std::string &message,
41 const std::shared_ptr<spdlog::logger> &logger);
49 msgpack::type::tuple<int, T> src(
static_cast<int>(T::kind), obj);
50 std::stringstream buffer;
51 msgpack::pack(buffer, src);
60void pack(std::stringstream &buffer,
int &len,
const T &obj) {
61 msgpack::pack(buffer,
static_cast<int>(T::kind));
62 msgpack::pack(buffer, obj);
66inline std::string
packDone(std::stringstream &buffer,
int len) {
67 std::stringstream buffer2;
68 msgpack::packer packer(buffer2);
69 packer.pack_array(len);
70 buffer2 << buffer.rdbuf();
78MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
82 struct convert<
webcface::SharedString> {
83 msgpack::object
const &operator()(msgpack::object
const &o,
86 std::string(o.via.bin.ptr, o.via.bin.size)));
92 template <
typename Stream>
93 msgpack::packer<Stream> &operator()(msgpack::packer<Stream> &o,
102 msgpack::object
const &operator()(msgpack::object
const &o,
105 case msgpack::type::FLOAT32:
106 case msgpack::type::FLOAT64:
109 case msgpack::type::POSITIVE_INTEGER:
112 case msgpack::type::NEGATIVE_INTEGER:
115 case msgpack::type::BOOLEAN:
118 case msgpack::type::BIN:
119 case msgpack::type::STR:
121 std::string(o.via.bin.ptr, o.via.bin.size)));
124 throw msgpack::type_error();
131 template <
typename Stream>
132 msgpack::packer<Stream> &operator()(msgpack::packer<Stream> &o,
136 o.pack(
static_cast<bool>(v));
139 o.pack(
static_cast<std::int64_t
>(v));
142 o.pack(
static_cast<double>(v));
153 template <
typename T>
154 struct EmptyConvert {
155 msgpack::object
const &operator()(msgpack::object
const &o, T &)
const {
159 template <
typename T>
161 template <
typename Stream>
162 msgpack::packer<Stream> &operator()(msgpack::packer<Stream> &o,
169 struct convert<
webcface::message::Ping>
170 :
public EmptyConvert<webcface::message::Ping> {};
172 struct convert<
webcface::message::PingStatusReq>
173 :
public EmptyConvert<webcface::message::PingStatusReq> {};
176 :
public EmptyPack<webcface::message::Ping> {};
179 :
public EmptyPack<webcface::message::PingStatusReq> {};
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:67
const std::string & u8String() const
Definition encoding.cc:104
static SharedString fromU8String(std::string_view u8s)
Definition encoding.cc:63
数値、文字列などの値を相互変換するクラス
Definition val_adaptor.h:87
const std::string & asU8StringRef() const
Definition val_adaptor.cc:94
ValType valType() const
Definition val_adaptor.h:166
webcface::ValAdaptor ValAdaptor
Definition val_adaptor.h:350
webcface::SharedString SharedString
Definition encoding.h:121
std::string packDone(std::stringstream &buffer, int len)
Definition pack.h:66
void pack(std::stringstream &buffer, int &len, const T &obj)
メッセージをシリアル化しbufferに追加
Definition pack.h:60
std::vector< std::pair< int, std::shared_ptr< void > > > unpack(const std::string &message, const std::shared_ptr< spdlog::logger > &logger)
msgpackのメッセージをパースし返す
Definition message.cc:53
std::string packSingle(const T &obj)
メッセージ1つを要素数2の配列としてシリアル化
Definition pack.h:48
std::string messageTrace(const std::string &message)
バイナリを16進数の文字列に変換
Definition message.cc:16
ValType
引数や戻り値の型を表すenum
Definition val_adaptor.h:21
#define WEBCFACE_NS_END
Definition webcface-config.h:118
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:117