From 3ee98d6adfec037b0220fbfbb1cd80614f9e2135 Mon Sep 17 00:00:00 2001 From: Jari Helaakoski Date: Thu, 24 Oct 2024 22:43:19 +0300 Subject: [PATCH] Fix -no-feature-datestring and -no-feature-xmlstreamreader Task-number: QTBUG-112830 Change-Id: I25dad19dee98d64eb5c226cbcc2b628f2a371ea4 Reviewed-by: Thiago Macieira --- src/corelib/io/qfilesystemengine_unix.cpp | 4 ++-- src/corelib/kernel/qmetatype.cpp | 4 ++++ src/corelib/serialization/qcborvalue.cpp | 10 ++++++++++ src/corelib/serialization/qcborvalue.h | 8 ++++++++ src/corelib/serialization/qjsoncbor.cpp | 4 ++++ src/corelib/serialization/qxmlstream.cpp | 4 ++-- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 548525661e9..81e36d43889 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1237,7 +1237,7 @@ bool QFileSystemEngine::createLink(const QFileSystemEntry &source, const QFileSy #ifdef Q_OS_DARWIN // see qfilesystemengine_mac.mm -#elif defined(QT_BOOTSTRAPPED) || !defined(AT_FDCWD) || defined(Q_OS_ANDROID) +#elif defined(QT_BOOTSTRAPPED) || !defined(AT_FDCWD) || defined(Q_OS_ANDROID) || !QT_CONFIG(datestring) // bootstrapped tools don't need this, and we don't want QStorageInfo //static bool QFileSystemEngine::supportsMoveFileToTrash() @@ -1607,7 +1607,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source, newLocation = QFileSystemEntry(op.trashPath + "/files/"_L1 + uniqueTrashedName); return true; } -#endif // !Q_OS_DARWIN && !QT_BOOTSTRAPPED +#endif // !Q_OS_DARWIN && (!QT_BOOTSTRAPPED && AT_FDCWD && !Q_OS_ANDROID && QT_CONFIG(datestring)) //static bool QFileSystemEngine::copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 3de52c154bc..417f3bbc14c 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1392,10 +1392,12 @@ static constexpr struct : QMetaTypeModuleHelper result = QCborArray::fromStringList(source); return true; ); +#if QT_CONFIG(datestring) QMETATYPE_CONVERTER(QCborValue, QDate, result = QCborValue(source.startOfDay()); return true; ); +#endif QMETATYPE_CONVERTER_ASSIGN(QCborValue, QUrl); QMETATYPE_CONVERTER(QCborValue, QJsonValue, result = QCborValue::fromJsonValue(source); @@ -1420,6 +1422,7 @@ static constexpr struct : QMetaTypeModuleHelper QMETATYPE_CONVERTER_ASSIGN(QCborValue, QCborMap); QMETATYPE_CONVERTER_ASSIGN(QCborValue, QCborArray); +#if QT_CONFIG(datestring) QMETATYPE_CONVERTER_ASSIGN(QCborValue, QDateTime); QMETATYPE_CONVERTER(QDateTime, QCborValue, if (source.isDateTime()) { @@ -1428,6 +1431,7 @@ static constexpr struct : QMetaTypeModuleHelper } return false; ); +#endif QMETATYPE_CONVERTER_ASSIGN(QCborValue, QCborSimpleType); QMETATYPE_CONVERTER(QCborSimpleType, QCborValue, diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index e5d041b5e4d..204d030c7c1 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -775,6 +775,7 @@ static QCborValue::Type convertToExtendedType(QCborContainerPrivate *d) }; switch (tag) { +#if QT_CONFIG(datestring) case qint64(QCborKnownTags::DateTimeString): case qint64(QCborKnownTags::UnixTime_t): { QDateTime dt; @@ -814,6 +815,7 @@ static QCborValue::Type convertToExtendedType(QCborContainerPrivate *d) } break; } +#endif #ifndef QT_BOOTSTRAPPED case qint64(QCborKnownTags::Url): @@ -2043,6 +2045,7 @@ QCborValue::QCborValue(const QCborValue &other) noexcept container->ref.ref(); } +#if QT_CONFIG(datestring) /*! Creates a QCborValue object of the date/time extended type and containing the value represented by \a dt. The value can later be retrieved using @@ -2063,6 +2066,7 @@ QCborValue::QCborValue(const QDateTime &dt) t = DateTime; container->elements[1].type = String; } +#endif #ifndef QT_BOOTSTRAPPED /*! @@ -2206,6 +2210,7 @@ QString QCborValue::toString(const QString &defaultValue) const return container->stringAt(n); } +#if QT_CONFIG(datestring) /*! Returns the date/time value stored in this QCborValue, if it is of the date/time extended type. Otherwise, it returns \a defaultValue. @@ -2229,6 +2234,7 @@ QDateTime QCborValue::toDateTime(const QDateTime &defaultValue) const Q_ASSERT((container->elements.at(1).flags & Element::StringIsUtf16) == 0); return QDateTime::fromString(byteData->asLatin1(), Qt::ISODateWithMs); } +#endif #ifndef QT_BOOTSTRAPPED /*! @@ -3173,8 +3179,10 @@ size_t qHash(const QCborValue &value, size_t seed) return seed; case QCborValue::Double: return qHash(value.toDouble(), seed); +#if QT_CONFIG(datestring) case QCborValue::DateTime: return qHash(value.toDateTime(), seed); +#endif #ifndef QT_BOOTSTRAPPED case QCborValue::Url: return qHash(value.toUrl(), seed); @@ -3308,8 +3316,10 @@ static QDebug debugContents(QDebug &dbg, const QCborValue &v) else return dbg << v.toDouble(); } +#if QT_CONFIG(datestring) case QCborValue::DateTime: return dbg << v.toDateTime(); +#endif #ifndef QT_BOOTSTRAPPED case QCborValue::Url: return dbg << v.toUrl(); diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index 93adbec3443..4f4349bee33 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -122,7 +122,9 @@ public: : QCborValue(QCborTag(t_), tv) {} +#if QT_CONFIG(datestring) explicit QCborValue(const QDateTime &dt); +#endif #ifndef QT_BOOTSTRAPPED explicit QCborValue(const QUrl &url); # if QT_CONFIG(regularexpression) @@ -196,7 +198,9 @@ public: QByteArray toByteArray(const QByteArray &defaultValue = {}) const; QString toString(const QString &defaultValue = {}) const; +#if QT_CONFIG(datestring) QDateTime toDateTime(const QDateTime &defaultValue = {}) const; +#endif #ifndef QT_BOOTSTRAPPED QUrl toUrl(const QUrl &defaultValue = {}) const; # if QT_CONFIG(regularexpression) @@ -346,8 +350,10 @@ public: { return concrete().toByteArray(defaultValue); } QString toString(const QString &defaultValue = {}) const { return concrete().toString(defaultValue); } +#if QT_CONFIG(datestring) QDateTime toDateTime(const QDateTime &defaultValue = {}) const { return concrete().toDateTime(defaultValue); } +#endif #ifndef QT_BOOTSTRAPPED QUrl toUrl(const QUrl &defaultValue = {}) const { return concrete().toUrl(defaultValue); } @@ -516,8 +522,10 @@ public: { return concreteByteArray(*this, defaultValue); } QString toString(const QString &defaultValue = {}) const { return concreteString(*this, defaultValue); } +#if QT_CONFIG(datestring) QDateTime toDateTime(const QDateTime &defaultValue = {}) const { return concrete().toDateTime(defaultValue); } +#endif #ifndef QT_BOOTSTRAPPED QUrl toUrl(const QUrl &defaultValue = {}) const { return concrete().toUrl(defaultValue); } diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp index da07eca8a7f..5895ef0a30a 100644 --- a/src/corelib/serialization/qjsoncbor.cpp +++ b/src/corelib/serialization/qjsoncbor.cpp @@ -553,8 +553,10 @@ QVariant QCborValue::toVariant() const // ignore tags return taggedValue().toVariant(); +#if QT_CONFIG(datestring) case DateTime: return toDateTime(); +#endif #ifndef QT_BOOTSTRAPPED case Url: @@ -732,8 +734,10 @@ QCborValue QCborValue::fromVariant(const QVariant &variant) return QCborArray::fromStringList(variant.toStringList()); case QMetaType::QByteArray: return variant.toByteArray(); +#if QT_CONFIG(datestring) case QMetaType::QDateTime: return QCborValue(variant.toDateTime()); +#endif #ifndef QT_BOOTSTRAPPED case QMetaType::QUrl: return QCborValue(variant.toUrl()); diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 0fe8c87779a..1547150a2f6 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -3864,7 +3864,6 @@ void QXmlStreamWriterPrivate::writeStartElement(QAnyStringView namespaceUri, QAn tag.namespaceDeclarationsSize = lastNamespaceDeclaration; } -#if QT_CONFIG(xmlstreamreader) /*! Writes the current state of the \a reader. All possible valid states are supported. @@ -3929,6 +3928,8 @@ void QXmlStreamWriter::writeCurrentToken(const QXmlStreamReader &reader) } } +#endif // feature xmlstreamwriter +#if QT_CONFIG(xmlstreamreader) static constexpr bool isTokenAllowedInContext(QXmlStreamReader::TokenType type, QXmlStreamReaderPrivate::XmlContext ctxt) { @@ -4045,7 +4046,6 @@ void QXmlStreamReaderPrivate::checkToken() */ #endif // feature xmlstreamreader -#endif // feature xmlstreamwriter QT_END_NAMESPACE