mirror of
https://github.com/romixlab/qmsgpack.git
synced 2025-07-29 18:07:16 +02:00
Make it possible to disable Qt type pack handlers at build time
usable with either qmake DEFINES+=MSGPACK_NO_PACKTYPES or DEFINES += MSGPACK_STATIC MSGPACK_NO_PACKTYPES include(path/to/qmsgpack/qmsgpack.pri)
This commit is contained in:
40
qmsgpack.pri
40
qmsgpack.pri
@ -7,10 +7,7 @@ SOURCES += \
|
|||||||
$$PWD/src/msgpackcommon.cpp \
|
$$PWD/src/msgpackcommon.cpp \
|
||||||
$$PWD/src/private/pack_p.cpp \
|
$$PWD/src/private/pack_p.cpp \
|
||||||
$$PWD/src/private/unpack_p.cpp \
|
$$PWD/src/private/unpack_p.cpp \
|
||||||
$$PWD/src/private/qt_types_p.cpp \
|
$$PWD/src/msgpackstream.cpp
|
||||||
$$PWD/src/msgpackstream.cpp \
|
|
||||||
$$PWD/src/stream/time.cpp \
|
|
||||||
$$PWD/src/stream/geometry.cpp
|
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/src/msgpack.h \
|
$$PWD/src/msgpack.h \
|
||||||
@ -19,18 +16,27 @@ HEADERS += \
|
|||||||
$$PWD/src/endianhelper.h \
|
$$PWD/src/endianhelper.h \
|
||||||
$$PWD/src/msgpackcommon.h \
|
$$PWD/src/msgpackcommon.h \
|
||||||
$$PWD/src/msgpack_export.h \
|
$$PWD/src/msgpack_export.h \
|
||||||
$$PWD/src/private/qt_types_p.h \
|
$$PWD/src/msgpackstream.h
|
||||||
$$PWD/src/msgpackstream.h \
|
|
||||||
$$PWD/src/stream/time.h \
|
|
||||||
$$PWD/src/stream/geometry.h
|
|
||||||
|
|
||||||
qtHaveModule(gui) {
|
!contains(DEFINES, MSGPACK_NO_PACKTYPES) {
|
||||||
QT += gui
|
SOURCES += \
|
||||||
}
|
$$PWD/src/private/qt_types_p.cpp \
|
||||||
|
$$PWD/src/stream/time.cpp \
|
||||||
qtHaveModule(location) {
|
$$PWD/src/stream/geometry.cpp
|
||||||
QT += location
|
|
||||||
|
HEADERS += \
|
||||||
SOURCES += $$PWD/src/stream/location.cpp
|
$$PWD/src/private/qt_types_p.h \
|
||||||
HEADERS += $$PWD/src/stream/location.h
|
$$PWD/src/stream/time.h \
|
||||||
|
$$PWD/src/stream/geometry.h
|
||||||
|
|
||||||
|
qtHaveModule(gui) {
|
||||||
|
QT += gui
|
||||||
|
}
|
||||||
|
|
||||||
|
qtHaveModule(location) {
|
||||||
|
QT += location
|
||||||
|
|
||||||
|
SOURCES += $$PWD/src/stream/location.cpp
|
||||||
|
HEADERS += $$PWD/src/stream/location.h
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,16 @@
|
|||||||
#include "msgpack.h"
|
#include "msgpack.h"
|
||||||
#include "private/unpack_p.h"
|
#include "private/unpack_p.h"
|
||||||
#include "private/pack_p.h"
|
#include "private/pack_p.h"
|
||||||
#include "private/qt_types_p.h"
|
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
|
#ifndef MSGPACK_NO_PACKTYPES
|
||||||
|
#include "private/qt_types_p.h"
|
||||||
|
|
||||||
#ifdef QT_LOCATION_LIB
|
#ifdef QT_LOCATION_LIB
|
||||||
#include <QGeoCoordinate>
|
#include <QGeoCoordinate>
|
||||||
#endif
|
#endif
|
||||||
|
#endif // MSGPACK_NO_PACKTYPES
|
||||||
|
|
||||||
QVariant MsgPack::unpack(const QByteArray &data)
|
QVariant MsgPack::unpack(const QByteArray &data)
|
||||||
{
|
{
|
||||||
@ -51,6 +54,7 @@ qint8 MsgPack::msgpackType(int qType)
|
|||||||
|
|
||||||
bool MsgPack::registerType(QMetaType::Type qType, quint8 msgpackType)
|
bool MsgPack::registerType(QMetaType::Type qType, quint8 msgpackType)
|
||||||
{
|
{
|
||||||
|
#ifndef MSGPACK_NO_PACKTYPES
|
||||||
switch (qType) {
|
switch (qType) {
|
||||||
#ifdef QT_GUI_LIB
|
#ifdef QT_GUI_LIB
|
||||||
case QMetaType::QColor:
|
case QMetaType::QColor:
|
||||||
@ -92,6 +96,9 @@ bool MsgPack::registerType(QMetaType::Type qType, quint8 msgpackType)
|
|||||||
#endif // QT_LOCATION_LIB
|
#endif // QT_LOCATION_LIB
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
Q_UNUSED(msgpackType)
|
||||||
|
#endif // MSGPACK_NO_PACKTYPES
|
||||||
|
|
||||||
qWarning("qmsgpack was built without metatype %d support.", int(qType));
|
qWarning("qmsgpack was built without metatype %d support.", int(qType));
|
||||||
qWarning("Use MsgPack::registerPacker() and MsgPack::registerUnpacker() to register metatype %d manually.", int(qType));
|
qWarning("Use MsgPack::registerPacker() and MsgPack::registerUnpacker() to register metatype %d manually.", int(qType));
|
||||||
|
12
src/src.pro
12
src/src.pro
@ -18,12 +18,14 @@ HEADERS_INSTALL = \
|
|||||||
msgpack_export.h \
|
msgpack_export.h \
|
||||||
msgpackstream.h \
|
msgpackstream.h \
|
||||||
|
|
||||||
STREAM_HEADERS_INSTALL = \
|
!contains(DEFINES, MSGPACK_NO_PACKTYPES) {
|
||||||
stream/geometry.h \
|
STREAM_HEADERS_INSTALL = \
|
||||||
stream/time.h
|
stream/geometry.h \
|
||||||
|
stream/time.h
|
||||||
|
|
||||||
qtHaveModule(location) {
|
qtHaveModule(location) {
|
||||||
STREAM_HEADERS_INSTALL += stream/location.h
|
STREAM_HEADERS_INSTALL += stream/location.h
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unix {
|
unix {
|
||||||
|
@ -3,6 +3,10 @@ TEMPLATE = subdirs
|
|||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
pack \
|
pack \
|
||||||
unpack \
|
unpack \
|
||||||
mixed \
|
mixed
|
||||||
stream \
|
|
||||||
qttypes
|
!contains(DEFINES, MSGPACK_NO_PACKTYPES) {
|
||||||
|
SUBDIRS += \
|
||||||
|
stream \
|
||||||
|
qttypes
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user