mirror of
https://github.com/romixlab/qmsgpack.git
synced 2025-07-30 02:17:15 +02:00
Create msgpack.org.md
This commit is contained in:
42
msgpack.org.md
Normal file
42
msgpack.org.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
MessagePack for Qt
|
||||||
|
==================
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
Clone repository:
|
||||||
|
~~~bash
|
||||||
|
git clone https://github.com/romixlab/qmsgpack.git
|
||||||
|
cd qmsgpack
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make install
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Sample usage
|
||||||
|
------------
|
||||||
|
Packing
|
||||||
|
~~~cpp
|
||||||
|
QVariantList list;
|
||||||
|
list << 1 << 2 << 3;
|
||||||
|
QByteArray array = MsgPack::pack(list);
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Unpacking:
|
||||||
|
~~~cpp
|
||||||
|
QVariantList unpacked = MsgPack::unpack(array).toList();
|
||||||
|
~~~
|
||||||
|
|
||||||
|
Streaming API:
|
||||||
|
~~~cpp
|
||||||
|
// packing
|
||||||
|
MsgPackStream stream(&ba, QIODevice::WriteOnly);
|
||||||
|
stream << 1 << 2.3 << "some string";
|
||||||
|
|
||||||
|
// unpacking
|
||||||
|
MsgPackStream stream(ba);
|
||||||
|
int a;
|
||||||
|
double b;
|
||||||
|
QSting s;
|
||||||
|
stream >> a >> b >> s;
|
||||||
|
~~~
|
Reference in New Issue
Block a user