21template<
typename Arg1,
typename... Args>
23 msgpack::pack(buffer, arg1);
26 if constexpr (
sizeof...(args) > 0) {
32template<
typename Arg1,
typename... Args>
34 static_assert(!std::is_pointer<Arg1>::value,
"Arg1 cannot be a pointer.");
36 msgpack::object_handle oh;
37 if (!unpacker.next(oh))
38 throw std::runtime_error(
"Error during MsgPack unpacking.");
39 arg1 = oh.get().as<Arg1>();
42 if constexpr (
sizeof...(args) > 0) {
51template<
class RetType,
class... Args>
56 virtual std::ostream&
Write(std::ostream& os, Args... args)
override {
58 os.seekp(0, std::ios::beg);
59 msgpack::sbuffer buffer;
61 os.write(buffer.data(), buffer.size());
63 catch (
const std::exception& e) {
64 std::cerr <<
"Serialize error: " << e.what() << std::endl;
71 virtual std::istream&
Read(std::istream& is, Args&... args)
override {
73 std::string buffer_data((std::istreambuf_iterator<char>(is)), std::istreambuf_iterator<char>());
74 msgpack::unpacker unpacker;
75 unpacker.reserve_buffer(buffer_data.size());
76 std::memcpy(unpacker.buffer(), buffer_data.data(), buffer_data.size());
77 unpacker.buffer_consumed(buffer_data.size());
80 catch (
const msgpack::type_error& e) {
81 std::cerr <<
"Deserialize type conversion error: " << e.what() << std::endl;
84 catch (
const std::exception& e) {
85 std::cerr <<
"Deserialize error: " << e.what() << std::endl;
Delegate serializer interface class.
virtual std::istream & Read(std::istream &is, Args &... args) override
Definition msgpack/Serializer.h:71
virtual std::ostream & Write(std::ostream &os, Args... args) override
Definition msgpack/Serializer.h:56
void make_unserialized(msgpack::unpacker &unpacker, Arg1 &arg1, Args &&... args)
Definition msgpack/Serializer.h:33
std::is_const< std::remove_reference_t< T > > is_const_type
Definition msgpack/Serializer.h:18
void make_serialized(msgpack::sbuffer &buffer, Arg1 &arg1, Args... args)
Definition msgpack/Serializer.h:22
Definition msgpack/Serializer.h:48
Definition ISerializer.h:12