2014-09-07 22:24:14 +04:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <msgpack.h>
|
|
|
|
|
#include <QDebug>
|
2014-09-18 23:47:58 +04:00
|
|
|
#include <QDataStream>
|
|
|
|
|
#include <QPoint>
|
2014-09-07 22:24:14 +04:00
|
|
|
|
2014-09-18 23:47:58 +04:00
|
|
|
quint32 packQPoint(const QVariant &variant, QByteArray &data, bool write)
|
|
|
|
|
{
|
|
|
|
|
if (write) {
|
|
|
|
|
data.resize(8);
|
|
|
|
|
QDataStream out(&data, QIODevice::WriteOnly);
|
|
|
|
|
out.setVersion(QDataStream::Qt_5_3);
|
|
|
|
|
out << variant.toPoint();
|
|
|
|
|
}
|
|
|
|
|
return 8;
|
|
|
|
|
}
|
2014-09-16 22:54:36 +04:00
|
|
|
|
2014-09-07 22:24:14 +04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2014-09-18 22:10:51 +04:00
|
|
|
Q_UNUSED(argc)
|
|
|
|
|
Q_UNUSED(argv)
|
2014-09-16 22:54:36 +04:00
|
|
|
//QCoreApplication a(argc, argv);
|
2014-09-07 22:24:14 +04:00
|
|
|
|
2014-09-18 23:47:58 +04:00
|
|
|
MsgPack::registerPacker(QMetaType::QPoint, 7, packQPoint);
|
2014-09-16 22:54:36 +04:00
|
|
|
|
2014-09-14 23:40:30 +04:00
|
|
|
QVariantList l;
|
2014-09-18 23:47:58 +04:00
|
|
|
|
|
|
|
|
l << QPoint(1, 2);
|
|
|
|
|
QByteArray arr = MsgPack::pack(l);
|
2014-09-16 22:54:36 +04:00
|
|
|
qDebug() << arr.toBase64();
|
2014-09-07 22:24:14 +04:00
|
|
|
|
2014-09-18 22:10:51 +04:00
|
|
|
|
2014-09-16 22:54:36 +04:00
|
|
|
return 0;
|
|
|
|
|
//return a.exec();
|
2014-09-07 22:24:14 +04:00
|
|
|
}
|