mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-13 22:50:19 +02:00
Replaced msgpack::unpacked with msgpack::object_handle.
msgpack::unpacked is a typedef of the msgpack::object_handle. I recommend using msgpack::object_handle. It can be used not only holding unpacked msgpack objects but also msgpack::objects that are created by any types. Replaced unpack() APIs in test codes and examples. They used to use old APIs.
This commit is contained in:
@@ -25,8 +25,8 @@ void array() {
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, a);
|
||||
|
||||
msgpack::unpacked und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::object obj = und.get();
|
||||
msgpack::object_handle oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::object obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert((obj.as<std::array<int, 5>>()) == a);
|
||||
@@ -37,8 +37,8 @@ void tuple() {
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, t);
|
||||
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(t)>() == t);
|
||||
@@ -49,8 +49,8 @@ void unordered_map() {
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, m);
|
||||
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::object obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
msgpack::object obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(m)>() == m);
|
||||
@@ -61,8 +61,8 @@ void unordered_set() {
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, s);
|
||||
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(s)>() == s);
|
||||
@@ -74,8 +74,8 @@ void forward_list() {
|
||||
std::stringstream ss;
|
||||
msgpack::pack(ss, f);
|
||||
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size());
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<type>() == f);
|
||||
@@ -98,40 +98,40 @@ void combi() {
|
||||
std::size_t offset = 0;
|
||||
std::cout << "offset: " << offset << std::endl;
|
||||
{
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(a)>() == a);
|
||||
}
|
||||
std::cout << "offset: " << offset << std::endl;
|
||||
{
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(t)>() == t);
|
||||
}
|
||||
std::cout << "offset: " << offset << std::endl;
|
||||
{
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(m)>() == m);
|
||||
}
|
||||
std::cout << "offset: " << offset << std::endl;
|
||||
{
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(s)>() == s);
|
||||
}
|
||||
std::cout << "offset: " << offset << std::endl;
|
||||
{
|
||||
auto und = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = und.get();
|
||||
auto oh = msgpack::unpack(ss.str().data(), ss.str().size(), offset);
|
||||
auto obj = oh.get();
|
||||
|
||||
std::cout << obj << std::endl;
|
||||
assert(obj.as<decltype(f)>() == f);
|
||||
|
Reference in New Issue
Block a user