2#ifdef MSGPACK_DEFINE_MAP
3#error "webcface/common/internal/pack.h must be included first"
9#include <spdlog/logger.h>
29 unsigned int member_id = 0;
43 unsigned int req_id = 0;
45 MSGPACK_NVP(
"f", field))
55std::vector<std::pair<int, std::shared_ptr<void>>>
56unpack(
const std::string &message,
57 const std::shared_ptr<spdlog::logger> &logger);
65 msgpack::type::tuple<int, T> src(
static_cast<int>(T::kind), obj);
66 std::stringstream buffer;
67 msgpack::pack(buffer, src);
76void pack(std::stringstream &buffer,
int &len,
const T &obj) {
77 msgpack::pack(buffer,
static_cast<int>(T::kind));
78 msgpack::pack(buffer, obj);
82inline std::string
packDone(std::stringstream &buffer,
int len) {
83 std::stringstream buffer2;
84 msgpack::packer packer(buffer2);
85 packer.pack_array(len);
86 buffer2 << buffer.rdbuf();
94MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
98 struct convert<
webcface::SharedString> {
99 msgpack::object
const &operator()(msgpack::object
const &o,
102 std::string(o.via.bin.ptr, o.via.bin.size)));
108 template <
typename Stream>
109 msgpack::packer<Stream> &operator()(msgpack::packer<Stream> &o,
118 msgpack::object
const &operator()(msgpack::object
const &o,
121 case msgpack::type::FLOAT32:
122 case msgpack::type::FLOAT64:
125 case msgpack::type::POSITIVE_INTEGER:
128 case msgpack::type::NEGATIVE_INTEGER:
131 case msgpack::type::BOOLEAN:
134 case msgpack::type::BIN:
135 case msgpack::type::STR:
137 std::string(o.via.bin.ptr, o.via.bin.size)));
140 throw msgpack::type_error();
147 template <
typename Stream>
148 msgpack::packer<Stream> &operator()(msgpack::packer<Stream> &o,
152 o.pack(
static_cast<bool>(v));
155 o.pack(
static_cast<std::int64_t
>(v));
158 o.pack(
static_cast<double>(v));
169 template <
typename T>
170 struct EmptyConvert {
171 msgpack::object
const &operator()(msgpack::object
const &o, T &)
const {
175 template <
typename T>
177 template <
typename Stream>
178 msgpack::packer<Stream> &operator()(msgpack::packer<Stream> &o,
185 struct convert<
webcface::message::Ping>
186 :
public EmptyConvert<webcface::message::Ping> {};
188 struct convert<
webcface::message::PingStatusReq>
189 :
public EmptyConvert<webcface::message::PingStatusReq> {};
192 :
public EmptyPack<webcface::message::Ping> {};
195 :
public EmptyPack<webcface::message::PingStatusReq> {};
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
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
#define MSGPACK_DEFINE_MAP(...)
Definition canvas2d.h:10
webcface::ValAdaptor ValAdaptor
Definition val_adaptor.h:350
webcface::SharedString SharedString
Definition encoding.h:127
std::string packDone(std::stringstream &buffer, int len)
Definition pack.h:82
void pack(std::stringstream &buffer, int &len, const T &obj)
メッセージをシリアル化しbufferに追加
Definition pack.h:76
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:31
std::string packSingle(const T &obj)
メッセージ1つを要素数2の配列としてシリアル化
Definition pack.h:64
ValType
引数や戻り値の型を表すenum
Definition val_adaptor.h:21
server->client 新しいvalueなどの報告
Definition pack.h:28
SharedString field
Definition pack.h:30
型からkindを取得するためだけのベースクラス
Definition base.h:53
client->server 以降Recvを送るようリクエスト
Definition pack.h:40
SharedString field
Definition pack.h:42
SharedString member
Definition pack.h:41
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103