Files
qmsgpack/README.md
T

73 lines
1.8 KiB
Markdown
Raw Normal View History

2016-04-26 22:49:13 +03:00
qmsgpack
2015-06-27 14:50:28 +03:00
========
2014-09-07 17:41:02 +04:00
MessagePack for Qt
2014-12-19 22:54:05 +03:00
2016-04-26 22:49:13 +03:00
<p align="center">
<a href="https://travis-ci.org/romixlab/qmsgpack">
<img src="https://travis-ci.org/romixlab/qmsgpack.svg?branch=master"
alt="Build Status">
</a>
2016-05-03 10:31:39 +03:00
<a href="http://qmsgpack.readthedocs.io/en/latest/">
2016-04-26 22:49:13 +03:00
<img src="https://readthedocs.org/projects/qmsgpack/badge/?version=latest"
alt="Doc Status">
</a>
</p>
2015-07-12 22:48:42 +03:00
Documentation
-------------
2016-05-03 10:31:39 +03:00
Complete documentation is available here: [qmsgpack.readthedocs.io](http://qmsgpack.readthedocs.io/en/latest/)
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`.
2014-12-19 22:54:05 +03:00
2015-06-27 14:50:28 +03:00
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.