-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
27 lines (22 loc) · 741 Bytes
/
test.cpp
File metadata and controls
27 lines (22 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* @Author : mark
* @Date : 2020-07-02
* @copyleft Apache 2.0
*/
#include <msgpack.hpp>
#include <string>
#include <iostream>
#include <sstream>
int main() {
msgpack::type::tuple<bool, char, std::string> src(true, 'i', "mark");
std::stringstream buffer;
msgpack::pack(buffer, src);
std::string str(buffer.str());
msgpack::object_handle oh = msgpack::unpack(str.data(), str.size());
msgpack::object deserialized = oh.get();
std::cout << deserialized << std::endl;
msgpack::type::tuple<bool, char, std::string>dst;
deserialized.convert(dst);
msgpack::type::tuple<bool, char, std::string> dst2 = deserialized.as<msgpack::type::tuple<bool, char, std::string> >();
return 0;
}