2016-04-26 22:49:13 +03:00
qmsgpack
2015-06-27 14:50:28 +03:00
========
2016-07-05 16:18:38 +03:00
[](https://travis-ci.org/buzzySmile/qmsgpack)
2016-06-29 12:39:20 +03:00
[](http://qmsgpack.readthedocs.org)
2016-04-26 22:49:13 +03:00
2016-06-29 12:39:20 +03:00
MessagePack for Qt
2016-04-26 22:49:13 +03:00
2015-07-12 22:48:42 +03:00
2014-12-19 22:54:05 +03:00
Installation
------------
Clone repository:
2014-12-19 23:00:24 +03:00
~~~bash
2014-12-19 23:13:13 +03:00
git clone https://github.com/romixlab/qmsgpack.git
2015-06-27 14:50:28 +03:00
~~~
Run cmake:
~~~bash
2014-12-19 23:13:13 +03:00
cd qmsgpack
2014-12-19 22:54:05 +03:00
mkdir build
cd build
cmake ..
2015-06-27 14:50:28 +03:00
~~~
Compile:
~~~bash
make
~~~
Run tests and install
~~~bash
make tests install
2014-12-19 22:54:05 +03:00
~~~
Sample usage
------------
Packing
2014-12-19 23:00:24 +03:00
~~~cpp
2014-12-19 22:54:05 +03:00
QVariantList list;
list << 1 << 2 << 3;
QByteArray array = MsgPack::pack(list);
~~~
Unpacking:
2014-12-19 23:00:24 +03:00
~~~cpp
2014-12-19 22:54:05 +03:00
QVariantList unpacked = MsgPack::unpack(array).toList();
~~~
2015-06-27 14:50:28 +03:00
By default these Qt types are supported: `Int, UInt, LongLong, ULongLong, Double, QByteArray, Bool, QString, QStringList, QVariantList, QVariantMap` .
Also you can provide packer and unpacker functions for any other type (even for user type defined via `Q_DECLARE_METATYPE` ) or MsgPack type.
2015-07-12 22:54:09 +03:00
Qt types and User types
-----------------------
There is packers and unpackers for QColor, QTime, QDate, QDateTime, QPoint, QSize, QRect. Also you can create your own packer/unpacker methods for Qt or your own types. See [docs ](http://msgpack.marsworks.ru/ ) for details.
2015-06-27 14:50:28 +03:00
Thread-safety
-------------
At this time it is not safe to call `MsgPack::registerPacker` , `MsgPack::registerUnpacker` and `MsgPack::setCompatibilityModeEnabled` from different threads.
pack and unpack methods do not use any global data, so should be safe to use from multiple threads.