message pack - how to find the represented string?

8 views
Skip to first unread message

yanivmvp

unread,
Jul 9, 2015, 10:08:52 AM7/9/15
to msg...@googlegroups.com

in the message pack website :

Message Pack

there is "Try" link above where it shows me how long is the representing string for the data.

I have a small script that is based on the examples presented in the message pack git hub

#include <msgpack.hpp>
#include <vector>
#include <string>
#include <iostream>

int main(void) {
    using namespace std;

    msgpack::sbuffer buffer;

    msgpack::packer<msgpack::sbuffer> pk(&buffer);
    pk.pack_map(2);
    pk.pack(string("SerialNumber"));
    pk.pack(123456789);
    pk.pack(string("Date"));
    pk.pack("1.4.14");



    //deserialize

    msgpack::unpacker pac;
    pac.reserve_buffer(buffer.size());
    memcpy(pac.buffer(),buffer.data(),buffer.size());
    pac.buffer_consumed(buffer.size());


    msgpack::unpacked result;
    while(pac.next(&result))
    {
        cout<<result.get()<<endl<<endl;

    }

works great but I want to retrive the String that is represented behind the packed data. just like in the "Try!" link. how can I find it ?

thank you

Reply all
Reply to author
Forward
0 new messages