19template<
typename... Args>
21 (msgpack::pack(buffer, args), ...);
28template<
class RetType,
class... Args>
33 virtual std::ostream&
Write(std::ostream& os, Args... args)
override {
38 os.seekp(0, std::ios::beg);
44 auto* ss =
dynamic_cast<std::ostringstream*
>(&os);
49 msgpack::sbuffer buffer;
51 os.write(buffer.data(), buffer.size());
53 catch (
const std::exception& e) {
54 std::cerr <<
"Serialize error: " << e.what() << std::endl;
61 virtual std::istream&
Read(std::istream& is, Args&... args)
override {
64 std::vector<char> buffer_data((std::istreambuf_iterator<char>(is)), std::istreambuf_iterator<char>());
66 if (buffer_data.empty() &&
sizeof...(Args) > 0) {
73 auto unpack_one = [&](
auto& arg) {
75 msgpack::object_handle oh = msgpack::unpack(buffer_data.data(), buffer_data.size(), offset);
78 arg = oh.get().as<std::decay_t<
decltype(arg)>>();
82 (unpack_one(args), ...);
84 catch (
const msgpack::type_error& e) {
85 std::cerr <<
"Deserialize type conversion error: " << e.what() << std::endl;
88 catch (
const std::exception& e) {
89 std::cerr <<
"Deserialize error: " << e.what() << std::endl;
Interface for custom argument serialization/deserialization.
virtual std::istream & Read(std::istream &is, Args &... args) override
Deserializes data from the input stream into function arguments.
Definition msgpack/Serializer.h:61
virtual std::ostream & Write(std::ostream &os, Args... args) override
Serializes function arguments into the output stream.
Definition msgpack/Serializer.h:33
void make_serialized(msgpack::sbuffer &buffer, Args &&... args)
Definition msgpack/Serializer.h:20
Definition bitsery/Serializer.h:27
Definition ISerializer.h:14