summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-10-14 15:12:02 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-10-16 12:16:04 +0200
commit85ed676dff68b4d5cfa62112d758d80fb050594c (patch)
treee39e925a532f887cb407071f4ae56901aaa734f9
parent821c2eb1310e72a1123eac69ef2aab8fc52dd0aa (diff)
Provide a feature for CBOR stream I/O
We need to turn it off in bootstrap code. Change-Id: I826e49fbc5f6128e56f84b58d29358dd7b0b9dc5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/corelib/configure.json8
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h1
-rw-r--r--src/corelib/serialization/qcborstream.h2
-rw-r--r--src/corelib/serialization/qcborvalue.cpp9
-rw-r--r--src/corelib/serialization/qcborvalue.h4
-rw-r--r--src/corelib/serialization/serialization.pri10
6 files changed, 32 insertions, 2 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index ae360239c6..b4b7c4eec3 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -1086,6 +1086,14 @@ Mozilla License) is included. The data is then also used in QNetworkCookieJar::v
"win32_system_libs": {
"label": "Windows System Libraries",
"condition": "config.win32 && libs.advapi32 && libs.gdi32 && libs.kernel32 && libs.netapi32 && libs.ole32 && libs.shell32 && libs.uuid && libs.user32 && libs.winmm && libs.ws2_32"
+ },
+ "cborstream": {
+ "label": "CBOR stream I/O",
+ "purpose": "Provides support for reading and writing the CBOR binary format.
+
+Note that this is required for plugin loading. Qt GUI needs QPA plugins for basic operation.",
+ "section": "Utilities",
+ "output": [ "publicFeature" ]
}
},
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index e6ad80525a..e9383ca68b 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -74,6 +74,7 @@
#else
# define QT_FEATURE_alloca_malloc_h -1
#endif
+#define QT_FEATURE_cborstream -1
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
#define QT_FEATURE_cxx11_random (QT_HAS_INCLUDE(<random>) ? 1 : -1)
#define QT_NO_DATASTREAM
diff --git a/src/corelib/serialization/qcborstream.h b/src/corelib/serialization/qcborstream.h
index 7a451e63ac..08bf680cca 100644
--- a/src/corelib/serialization/qcborstream.h
+++ b/src/corelib/serialization/qcborstream.h
@@ -47,6 +47,8 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringview.h>
+QT_REQUIRE_CONFIG(cborstream);
+
// See qcborcommon.h for why we check
#if defined(QT_X11_DEFINES_FOUND)
# undef True
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp
index 1b170739d2..b77cfd5c70 100644
--- a/src/corelib/serialization/qcborvalue.cpp
+++ b/src/corelib/serialization/qcborvalue.cpp
@@ -42,7 +42,10 @@
#include "qdatastream.h"
#include "qcborarray.h"
#include "qcbormap.h"
+
+#if QT_CONFIG(cborstream)
#include "qcborstream.h"
+#endif
#include <qendian.h>
#include <qlocale.h>
@@ -758,6 +761,7 @@ QT_BEGIN_NAMESPACE
using namespace QtCbor;
+#if QT_CONFIG(cborstream)
// in qcborstream.cpp
extern void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error);
@@ -799,6 +803,7 @@ static void writeDoubleToCbor(QCborStreamWriter &writer, double d, QCborValue::E
writer.append(d);
}
+#endif // QT_CONFIG(cborstream)
static inline int typeOrder(Element e1, Element e2)
{
@@ -1221,6 +1226,7 @@ int QCborMap::compare(const QCborMap &other) const noexcept
return compareContainer(d.data(), other.d.data());
}
+#if QT_CONFIG(cborstream)
static void encodeToCbor(QCborStreamWriter &writer, const QCborContainerPrivate *d, qsizetype idx,
QCborValue::EncodingOptions opt)
{
@@ -1632,6 +1638,7 @@ void QCborContainerPrivate::decodeFromCbor(QCborStreamReader &reader)
if (reader.lastError() == QCborError::NoError)
reader.leaveContainer();
}
+#endif // QT_CONFIG(cborstream)
/*!
Creates a QCborValue with byte array value \a ba. The value can later be
@@ -2330,6 +2337,7 @@ QCborValueRef QCborValue::operator[](qint64 key)
return { container, index };
}
+#if QT_CONFIG(cborstream)
/*!
Decodes one item from the CBOR stream found in \a reader and returns the
equivalent representation. This function is recursive: if the item is a map
@@ -2567,6 +2575,7 @@ void QCborValueRef::toCbor(QCborStreamWriter &writer, QCborValue::EncodingOption
{
concrete().toCbor(writer, opt);
}
+#endif // QT_CONFIG(cborstream)
void QCborValueRef::assign(QCborValueRef that, const QCborValue &other)
{
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index 3c325b59e7..accd0fae8a 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -285,6 +285,7 @@ public:
static QCborValue fromJsonValue(const QJsonValue &v);
QJsonValue toJsonValue() const;
+#if QT_CONFIG(cborstream)
static QCborValue fromCbor(QCborStreamReader &reader);
static QCborValue fromCbor(const QByteArray &ba, QCborParserError *error = nullptr);
static QCborValue fromCbor(const char *data, qsizetype len, QCborParserError *error = nullptr)
@@ -293,6 +294,7 @@ public:
{ return fromCbor(QByteArray(reinterpret_cast<const char *>(data), int(len)), error); }
QByteArray toCbor(EncodingOptions opt = NoTransformation);
void toCbor(QCborStreamWriter &writer, EncodingOptions opt = NoTransformation);
+#endif
QString toDiagnosticNotation(DiagnosticNotationOptions opts = Compact) const;
@@ -435,9 +437,11 @@ public:
QVariant toVariant() const { return concrete().toVariant(); }
QJsonValue toJsonValue() const;
+#if QT_CONFIG(cborstream)
QByteArray toCbor(QCborValue::EncodingOptions opt = QCborValue::NoTransformation)
{ return concrete().toCbor(opt); }
void toCbor(QCborStreamWriter &writer, QCborValue::EncodingOptions opt = QCborValue::NoTransformation);
+#endif
QString toDiagnosticNotation(QCborValue::DiagnosticNotationOptions opt = QCborValue::Compact)
{ return concrete().toDiagnosticNotation(opt); }
diff --git a/src/corelib/serialization/serialization.pri b/src/corelib/serialization/serialization.pri
index 4f2dc64e4f..5310fddd67 100644
--- a/src/corelib/serialization/serialization.pri
+++ b/src/corelib/serialization/serialization.pri
@@ -6,7 +6,6 @@ HEADERS += \
serialization/qcbormap.h \
serialization/qcborvalue.h \
serialization/qcborvalue_p.h \
- serialization/qcborstream.h \
serialization/qdatastream.h \
serialization/qdatastream_p.h \
serialization/qjson_p.h \
@@ -23,7 +22,6 @@ HEADERS += \
serialization/qxmlutils_p.h
SOURCES += \
- serialization/qcborstream.cpp \
serialization/qcbordiagnostic.cpp \
serialization/qcborvalue.cpp \
serialization/qdatastream.cpp \
@@ -39,6 +37,14 @@ SOURCES += \
serialization/qxmlstream.cpp \
serialization/qxmlutils.cpp
+qtConfig(cborstream): {
+ SOURCES += \
+ serialization/qcborstream.cpp
+
+ HEADERS += \
+ serialization/qcborstream.h
+}
+
false: SOURCES += \
serialization/qcborarray.cpp \
serialization/qcbormap.cpp