mirror of
https://github.com/romixlab/qmsgpack.git
synced 2025-06-24 17:11:33 +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/private/pack_p.cpp \
|
||||
$$PWD/src/private/unpack_p.cpp \
|
||||
$$PWD/src/private/qt_types_p.cpp \
|
||||
$$PWD/src/msgpackstream.cpp \
|
||||
$$PWD/src/stream/time.cpp \
|
||||
$$PWD/src/stream/geometry.cpp
|
||||
$$PWD/src/msgpackstream.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/src/msgpack.h \
|
||||
@ -19,18 +16,27 @@ HEADERS += \
|
||||
$$PWD/src/endianhelper.h \
|
||||
$$PWD/src/msgpackcommon.h \
|
||||
$$PWD/src/msgpack_export.h \
|
||||
$$PWD/src/private/qt_types_p.h \
|
||||
$$PWD/src/msgpackstream.h \
|
||||
$$PWD/src/stream/time.h \
|
||||
$$PWD/src/stream/geometry.h
|
||||
$$PWD/src/msgpackstream.h
|
||||
|
||||
qtHaveModule(gui) {
|
||||
QT += gui
|
||||
}
|
||||
|
||||
qtHaveModule(location) {
|
||||
QT += location
|
||||
|
||||
SOURCES += $$PWD/src/stream/location.cpp
|
||||
HEADERS += $$PWD/src/stream/location.h
|
||||
!contains(DEFINES, MSGPACK_NO_PACKTYPES) {
|
||||
SOURCES += \
|
||||
$$PWD/src/private/qt_types_p.cpp \
|
||||
$$PWD/src/stream/time.cpp \
|
||||
$$PWD/src/stream/geometry.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/src/private/qt_types_p.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 "private/unpack_p.h"
|
||||
#include "private/pack_p.h"
|
||||
#include "private/qt_types_p.h"
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#ifndef MSGPACK_NO_PACKTYPES
|
||||
#include "private/qt_types_p.h"
|
||||
|
||||
#ifdef QT_LOCATION_LIB
|
||||
#include <QGeoCoordinate>
|
||||
#endif
|
||||
#endif // MSGPACK_NO_PACKTYPES
|
||||
|
||||
QVariant MsgPack::unpack(const QByteArray &data)
|
||||
{
|
||||
@ -51,6 +54,7 @@ qint8 MsgPack::msgpackType(int qType)
|
||||
|
||||
bool MsgPack::registerType(QMetaType::Type qType, quint8 msgpackType)
|
||||
{
|
||||
#ifndef MSGPACK_NO_PACKTYPES
|
||||
switch (qType) {
|
||||
#ifdef QT_GUI_LIB
|
||||
case QMetaType::QColor:
|
||||
@ -92,6 +96,9 @@ bool MsgPack::registerType(QMetaType::Type qType, quint8 msgpackType)
|
||||
#endif // QT_LOCATION_LIB
|
||||
break;
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(msgpackType)
|
||||
#endif // MSGPACK_NO_PACKTYPES
|
||||
|
||||
qWarning("qmsgpack was built without metatype %d support.", 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 \
|
||||
msgpackstream.h \
|
||||
|
||||
STREAM_HEADERS_INSTALL = \
|
||||
stream/geometry.h \
|
||||
stream/time.h
|
||||
!contains(DEFINES, MSGPACK_NO_PACKTYPES) {
|
||||
STREAM_HEADERS_INSTALL = \
|
||||
stream/geometry.h \
|
||||
stream/time.h
|
||||
|
||||
qtHaveModule(location) {
|
||||
STREAM_HEADERS_INSTALL += stream/location.h
|
||||
qtHaveModule(location) {
|
||||
STREAM_HEADERS_INSTALL += stream/location.h
|
||||
}
|
||||
}
|
||||
|
||||
unix {
|
||||
|
@ -3,6 +3,10 @@ TEMPLATE = subdirs
|
||||
SUBDIRS += \
|
||||
pack \
|
||||
unpack \
|
||||
mixed \
|
||||
stream \
|
||||
qttypes
|
||||
mixed
|
||||
|
||||
!contains(DEFINES, MSGPACK_NO_PACKTYPES) {
|
||||
SUBDIRS += \
|
||||
stream \
|
||||
qttypes
|
||||
}
|
||||
|
Reference in New Issue
Block a user