forked from romixlab/qmsgpack
Merge pull request #22 from enochc/master
changed QMetaType::Type T to int to allow registration of custom QMet…
This commit is contained in:
@ -28,7 +28,7 @@ QByteArray MsgPack::pack(const QVariant &variant)
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgPack::registerPacker(QMetaType::Type qType, qint8 msgpackType, MsgPack::pack_user_f packer)
|
bool MsgPack::registerPacker(int qType, qint8 msgpackType, MsgPack::pack_user_f packer)
|
||||||
{
|
{
|
||||||
return MsgPackPrivate::register_packer(qType, msgpackType, packer);
|
return MsgPackPrivate::register_packer(qType, msgpackType, packer);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace MsgPack
|
|||||||
MSGPACK_EXPORT bool registerUnpacker(qint8 msgpackType, unpack_user_f unpacker);
|
MSGPACK_EXPORT bool registerUnpacker(qint8 msgpackType, unpack_user_f unpacker);
|
||||||
|
|
||||||
MSGPACK_EXPORT QByteArray pack(const QVariant &variant);
|
MSGPACK_EXPORT QByteArray pack(const QVariant &variant);
|
||||||
MSGPACK_EXPORT bool registerPacker(QMetaType::Type qType, qint8 msgpackType, pack_user_f packer);
|
MSGPACK_EXPORT bool registerPacker(int qType, qint8 msgpackType, pack_user_f packer);
|
||||||
MSGPACK_EXPORT qint8 msgpackType(int qType);
|
MSGPACK_EXPORT qint8 msgpackType(int qType);
|
||||||
|
|
||||||
MSGPACK_EXPORT bool registerType(QMetaType::Type qType, quint8 msgpackType);
|
MSGPACK_EXPORT bool registerType(QMetaType::Type qType, quint8 msgpackType);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <QReadLocker>
|
#include <QReadLocker>
|
||||||
#include <QWriteLocker>
|
#include <QWriteLocker>
|
||||||
|
|
||||||
QHash<QMetaType::Type, MsgPackPrivate::packer_t> MsgPackPrivate::user_packers;
|
QHash<int, MsgPackPrivate::packer_t> MsgPackPrivate::user_packers;
|
||||||
bool MsgPackPrivate::compatibilityMode = false;
|
bool MsgPackPrivate::compatibilityMode = false;
|
||||||
QReadWriteLock MsgPackPrivate::packers_lock;
|
QReadWriteLock MsgPackPrivate::packers_lock;
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ quint8 *MsgPackPrivate::pack_map(const QVariantMap &map, quint8 *p, bool wr, QVe
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MsgPackPrivate::register_packer(QMetaType::Type q_type, qint8 msgpack_type, MsgPack::pack_user_f packer)
|
bool MsgPackPrivate::register_packer(int q_type, qint8 msgpack_type, MsgPack::pack_user_f packer)
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&packers_lock);
|
QWriteLocker locker(&packers_lock);
|
||||||
if (user_packers.contains(q_type)) {
|
if (user_packers.contains(q_type)) {
|
||||||
|
@ -19,9 +19,9 @@ typedef struct {
|
|||||||
MsgPack::pack_user_f packer;
|
MsgPack::pack_user_f packer;
|
||||||
qint8 type;
|
qint8 type;
|
||||||
} packer_t;
|
} packer_t;
|
||||||
bool register_packer(QMetaType::Type q_type, qint8 msgpack_type, MsgPack::pack_user_f packer);
|
bool register_packer(int q_type, qint8 msgpack_type, MsgPack::pack_user_f packer);
|
||||||
qint8 msgpack_type(QMetaType::Type q_type);
|
qint8 msgpack_type(QMetaType::Type q_type);
|
||||||
extern QHash<QMetaType::Type, packer_t> user_packers;
|
extern QHash<int, packer_t> user_packers;
|
||||||
extern QReadWriteLock packers_lock;
|
extern QReadWriteLock packers_lock;
|
||||||
extern bool compatibilityMode;
|
extern bool compatibilityMode;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user