mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-11-02 14:03:43 +01: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:
@@ -31,11 +31,11 @@ int main(void) {
|
||||
msgpack::pack(sbuf, vec);
|
||||
|
||||
// deserialize it.
|
||||
msgpack::unpacked msg;
|
||||
msgpack::unpack(&msg, sbuf.data(), sbuf.size());
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size());
|
||||
|
||||
// print the deserialized object.
|
||||
msgpack::object obj = msg.get();
|
||||
msgpack::object obj = oh.get();
|
||||
std::cout << obj << std::endl; //=> ["Hello", "MessagePack"]
|
||||
|
||||
// convert it into statically typed object.
|
||||
@@ -79,9 +79,9 @@ int main(void) {
|
||||
pac.buffer_consumed(buffer.size());
|
||||
|
||||
// now starts streaming deserialization.
|
||||
msgpack::unpacked result;
|
||||
while(pac.next(&result)) {
|
||||
std::cout << result.get() << std::endl;
|
||||
msgpack::object_handle oh;
|
||||
while(pac.next(&oh)) {
|
||||
std::cout << oh.get() << std::endl;
|
||||
}
|
||||
|
||||
// results:
|
||||
@@ -151,10 +151,10 @@ int main(void) {
|
||||
msgpack::sbuffer sbuf;
|
||||
msgpack::pack(sbuf, vec);
|
||||
|
||||
msgpack::unpacked msg;
|
||||
msgpack::unpack(&msg, sbuf.data(), sbuf.size());
|
||||
msgpack::object_handle oh =
|
||||
msgpack::unpack(sbuf.data(), sbuf.size());
|
||||
|
||||
msgpack::object obj = msg.get();
|
||||
msgpack::object obj = oh.get();
|
||||
|
||||
// you can convert object to myclass directly
|
||||
std::vector<myclass> rvec;
|
||||
|
||||
Reference in New Issue
Block a user