From 16c453069f7b44ba7328a178b4b9ce99a150813e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 15 Feb 2022 11:48:32 +0100 Subject: [PATCH] QtBase: eradicate QT_STRINGVIEW_LEVEL uses It's not used and not useful. The macro itself has to stay, for now, because Qt5Compat uses it, too. Task-number: QTBUG-100861 Pick-to: 6.4 6.3 6.2 Change-Id: I5d0557a6c959d6facf6e47f26786a9d365339e95 Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne --- src/corelib/io/qdebug.h | 2 -- src/corelib/serialization/qcborvalue.cpp | 2 -- src/corelib/serialization/qcborvalue.h | 2 -- src/corelib/serialization/qcborvalue_p.h | 2 -- src/corelib/serialization/qjsondocument.cpp | 2 -- src/corelib/serialization/qjsondocument.h | 2 -- src/corelib/serialization/qjsonobject.cpp | 20 ----------------- src/corelib/serialization/qjsonobject.h | 6 ------ src/corelib/serialization/qjsonvalue.cpp | 2 -- src/corelib/serialization/qjsonvalue.h | 2 -- src/corelib/text/qcollator.cpp | 3 +-- src/corelib/text/qcollator.h | 2 -- src/corelib/text/qlocale.cpp | 6 ------ src/corelib/text/qlocale.h | 6 ------ src/corelib/text/qstring.cpp | 14 ------------ src/corelib/text/qstring.h | 24 --------------------- src/corelib/text/qstringlist.cpp | 8 ------- src/corelib/text/qstringlist.h | 4 ---- src/corelib/text/qstringview.h | 9 +------- src/corelib/time/qdatetime.h | 12 ----------- src/corelib/tools/qhashfunctions.h | 2 -- 21 files changed, 2 insertions(+), 130 deletions(-) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 22328e7c85..64b4ac37c9 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -110,9 +110,7 @@ public: inline QDebug &operator<<(double t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(const char* t) { stream->ts << QString::fromUtf8(t); return maybeSpace(); } inline QDebug &operator<<(const char16_t *t) { stream->ts << QStringView(t); return maybeSpace(); } -#if QT_STRINGVIEW_LEVEL < 2 inline QDebug &operator<<(const QString & t) { putString(t.constData(), uint(t.length())); return maybeSpace(); } -#endif inline QDebug &operator<<(QStringView s) { putString(s.data(), size_t(s.size())); return maybeSpace(); } inline QDebug &operator<<(QUtf8StringView s) { putByteArray(reinterpret_cast(s.data()), s.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(QLatin1StringView t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); } diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index d233c1b01e..056e8c07b6 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -1715,7 +1715,6 @@ QCborValue::QCborValue(const QByteArray &ba) container->ref.storeRelaxed(1); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Creates a QCborValue with string value \a s. The value can later be retrieved using toString(). @@ -1723,7 +1722,6 @@ QCborValue::QCborValue(const QByteArray &ba) \sa toString(), isString(), isByteArray() */ QCborValue::QCborValue(const QString &s) : QCborValue(qToStringViewIgnoringNull(s)) {} -#endif /*! Creates a QCborValue with string value \a s. The value can later be diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index 9f80b5e9bd..a83a36a3d8 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -110,9 +110,7 @@ public: QCborValue(QCborSimpleType st) : t(type_helper(st)) {} QCborValue(const QByteArray &ba); -#if QT_STRINGVIEW_LEVEL < 2 QCborValue(const QString &s); -#endif QCborValue(QStringView s); QCborValue(QLatin1StringView s); #ifndef QT_NO_CAST_FROM_ASCII diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h index 4e2bb425db..c5cc6c6f0b 100644 --- a/src/corelib/serialization/qcborvalue_p.h +++ b/src/corelib/serialization/qcborvalue_p.h @@ -225,12 +225,10 @@ public: } void appendAsciiString(QStringView s); -#if QT_STRINGVIEW_LEVEL < 2 void append(const QString &s) { append(qToStringViewIgnoringNull(s)); } -#endif void append(QStringView s) { diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index 59ce496d1b..814033610f 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -391,7 +391,6 @@ void QJsonDocument::setArray(const QJsonArray &array) d->value = QCborValue::fromJsonValue(array); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns a QJsonValue representing the value for the key \a key. @@ -408,7 +407,6 @@ const QJsonValue QJsonDocument::operator[](const QString &key) const { return (*this)[QStringView(key)]; } -#endif /*! \overload diff --git a/src/corelib/serialization/qjsondocument.h b/src/corelib/serialization/qjsondocument.h index 72e1b9a5c2..e580c0122d 100644 --- a/src/corelib/serialization/qjsondocument.h +++ b/src/corelib/serialization/qjsondocument.h @@ -94,9 +94,7 @@ public: void setObject(const QJsonObject &object); void setArray(const QJsonArray &array); -#if QT_STRINGVIEW_LEVEL < 2 const QJsonValue operator[](const QString &key) const; -#endif const QJsonValue operator[](QStringView key) const; const QJsonValue operator[](QLatin1StringView key) const; const QJsonValue operator[](qsizetype i) const; diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index a3e5bd695e..0a5bafd1cb 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -278,7 +278,6 @@ static qsizetype indexOf(const QExplicitlySharedDataPointervalueAt(i + 1)); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns a QJsonValue representing the value for the key \a key. @@ -340,7 +337,6 @@ QJsonValue QJsonObject::operator [](const QString &key) const { return (*this)[QStringView(key)]; } -#endif /*! \fn QJsonValue QJsonObject::operator [](QStringView key) const @@ -356,7 +352,6 @@ QJsonValue QJsonObject::operator [](const QString &key) const \since 5.7 */ -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns a reference to the value for \a key. If there is no value with key \a key in the object, one is created with a QJsonValue::Null value and then @@ -374,7 +369,6 @@ QJsonValueRef QJsonObject::operator [](const QString &key) { return (*this)[QStringView(key)]; } -#endif /*! \overload @@ -414,7 +408,6 @@ QJsonValueRef QJsonObject::atImpl(T key) return QJsonValueRef(this, index / 2); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Inserts a new item with the key \a key and a value of \a value. @@ -432,7 +425,6 @@ QJsonObject::iterator QJsonObject::insert(const QString &key, const QJsonValue & { return insert(QStringView(key), value); } -#endif /*! \overload @@ -487,7 +479,6 @@ QJsonObject::iterator QJsonObject::insertAt(qsizetype pos, T key, const QJsonVal return {this, pos / 2}; } -#if QT_STRINGVIEW_LEVEL < 2 /*! Removes \a key from the object. @@ -497,7 +488,6 @@ void QJsonObject::remove(const QString &key) { remove(QStringView(key)); } -#endif /*! \overload @@ -534,7 +524,6 @@ void QJsonObject::removeImpl(T key) removeAt(index); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Removes \a key from the object. @@ -548,7 +537,6 @@ QJsonValue QJsonObject::take(const QString &key) { return take(QStringView(key)); } -#endif /*! \overload @@ -588,7 +576,6 @@ QJsonValue QJsonObject::takeImpl(T key) return v; } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns \c true if the object contains key \a key. @@ -598,7 +585,6 @@ bool QJsonObject::contains(const QString &key) const { return contains(QStringView(key)); } -#endif /*! \overload @@ -680,7 +666,6 @@ QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it) return { this, qsizetype(it.item.index) }; } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns an iterator pointing to the item with key \a key in the map. @@ -692,7 +677,6 @@ QJsonObject::iterator QJsonObject::find(const QString &key) { return find(QStringView(key)); } -#endif /*! \overload @@ -726,12 +710,10 @@ QJsonObject::iterator QJsonObject::findImpl(T key) return {this, index / 2}; } -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QJsonObject::const_iterator QJsonObject::find(const QString &key) const \overload */ -#endif /*! \fn QJsonObject::const_iterator QJsonObject::find(QStringView key) const @@ -745,7 +727,6 @@ QJsonObject::iterator QJsonObject::findImpl(T key) \since 5.7 */ -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns a const iterator pointing to the item with key \a key in the map. @@ -757,7 +738,6 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const { return constFind(QStringView(key)); } -#endif /*! \overload diff --git a/src/corelib/serialization/qjsonobject.h b/src/corelib/serialization/qjsonobject.h index 5d7fb227a7..f5f4d1f47e 100644 --- a/src/corelib/serialization/qjsonobject.h +++ b/src/corelib/serialization/qjsonobject.h @@ -52,11 +52,9 @@ public: inline qsizetype length() const { return size(); } bool isEmpty() const; -#if QT_STRINGVIEW_LEVEL < 2 QJsonValue value(const QString &key) const; QJsonValue operator[] (const QString &key) const; QJsonValueRef operator[] (const QString &key); -#endif QJsonValue value(QStringView key) const; QJsonValue value(QLatin1StringView key) const; QJsonValue operator[] (QStringView key) const { return value(key); } @@ -64,11 +62,9 @@ public: QJsonValueRef operator[] (QStringView key); QJsonValueRef operator[] (QLatin1StringView key); -#if QT_STRINGVIEW_LEVEL < 2 void remove(const QString &key); QJsonValue take(const QString &key); bool contains(const QString &key) const; -#endif void remove(QStringView key); void remove(QLatin1StringView key); QJsonValue take(QStringView key); @@ -219,12 +215,10 @@ public: // more Qt typedef iterator Iterator; typedef const_iterator ConstIterator; -#if QT_STRINGVIEW_LEVEL < 2 iterator find(const QString &key); const_iterator find(const QString &key) const { return constFind(key); } const_iterator constFind(const QString &key) const; iterator insert(const QString &key, const QJsonValue &value); -#endif iterator find(QStringView key); iterator find(QLatin1StringView key); const_iterator find(QStringView key) const { return constFind(key); } diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp index a92677d19d..ef07dcdc3b 100644 --- a/src/corelib/serialization/qjsonvalue.cpp +++ b/src/corelib/serialization/qjsonvalue.cpp @@ -761,7 +761,6 @@ QJsonObject QJsonValue::toObject() const return toObject(QJsonObject()); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns a QJsonValue representing the value for the key \a key. @@ -778,7 +777,6 @@ const QJsonValue QJsonValue::operator[](const QString &key) const { return (*this)[QStringView(key)]; } -#endif /*! \overload diff --git a/src/corelib/serialization/qjsonvalue.h b/src/corelib/serialization/qjsonvalue.h index d8ea5e441e..4bb4930690 100644 --- a/src/corelib/serialization/qjsonvalue.h +++ b/src/corelib/serialization/qjsonvalue.h @@ -87,9 +87,7 @@ public: QJsonObject toObject() const; QJsonObject toObject(const QJsonObject &defaultValue) const; -#if QT_STRINGVIEW_LEVEL < 2 const QJsonValue operator[](const QString &key) const; -#endif const QJsonValue operator[](QStringView key) const; const QJsonValue operator[](QLatin1StringView key) const; const QJsonValue operator[](qsizetype i) const; diff --git a/src/corelib/text/qcollator.cpp b/src/corelib/text/qcollator.cpp index 20a8f1372e..f21df33af4 100644 --- a/src/corelib/text/qcollator.cpp +++ b/src/corelib/text/qcollator.cpp @@ -306,7 +306,7 @@ bool QCollator::ignorePunctuation() const Returns an integer less than, equal to, or greater than zero depending on whether \a s1 sorts before, with or after \a s2. */ -#if QT_STRINGVIEW_LEVEL < 2 + /*! \fn bool QCollator::operator()(const QString &s1, const QString &s2) const \overload @@ -330,7 +330,6 @@ bool QCollator::ignorePunctuation() const Returns an integer less than, equal to, or greater than zero depending on whether \a s1 sorts before, with or after \a s2. */ -#endif // QT_STRINGVIEW_LEVEL < 2 /*! \since 6.3 diff --git a/src/corelib/text/qcollator.h b/src/corelib/text/qcollator.h index 315ce43e9b..76a453c6ae 100644 --- a/src/corelib/text/qcollator.h +++ b/src/corelib/text/qcollator.h @@ -65,7 +65,6 @@ public: void setIgnorePunctuation(bool on); bool ignorePunctuation() const; -#if QT_STRINGVIEW_LEVEL < 2 int compare(const QString &s1, const QString &s2) const { return compare(QStringView(s1), QStringView(s2)); } int compare(const QChar *s1, int len1, const QChar *s2, int len2) const @@ -73,7 +72,6 @@ public: bool operator()(const QString &s1, const QString &s2) const { return compare(s1, s2) < 0; } -#endif int compare(QStringView s1, QStringView s2) const; bool operator()(QStringView s1, QStringView s2) const diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 0b229c97b4..536c5c3be5 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -1007,12 +1007,10 @@ QLocale::QLocale(QStringView name) { } -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QLocale::QLocale(const QString &name) \overload */ -#endif /*! Constructs a QLocale object initialized with the default locale. @@ -1582,7 +1580,6 @@ QString QLocale::scriptToString(QLocale::Script script) return QLatin1StringView(script_name_list + script_name_index[script]); } -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn short QLocale::toShort(const QString &s, bool *ok) const @@ -1745,7 +1742,6 @@ QString QLocale::scriptToString(QLocale::Script script) \sa toFloat(), toInt(), toString() */ -#endif // QT_STRINGVIEW_LEVEL < 2 /*! Returns the short int represented by the localized string \a s. @@ -1987,7 +1983,6 @@ QString QLocale::toString(qulonglong i) const return d->m_data->unsLongLongToString(i, -1, 10, -1, flags); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns a localized string representation of the given \a date in the specified \a format. @@ -2024,7 +2019,6 @@ QString QLocale::toString(QTime time, const QString &format) const \sa QDateTime::toString(), QDate::toString(), QTime::toString() */ -#endif /*! \since 5.14 diff --git a/src/corelib/text/qlocale.h b/src/corelib/text/qlocale.h index b9880496f1..599cd79232 100644 --- a/src/corelib/text/qlocale.h +++ b/src/corelib/text/qlocale.h @@ -891,10 +891,8 @@ public: Q_FLAG(DataSizeFormats) QLocale(); -#if QT_STRINGVIEW_LEVEL < 2 QT_CORE_INLINE_SINCE(6, 4) explicit QLocale(const QString &name); -#endif explicit QLocale(QStringView name); QLocale(Language language, Territory territory); QLocale(Language language, Script script = AnyScript, Territory territory = AnyTerritory); @@ -922,7 +920,6 @@ public: QString nativeCountryName() const; #endif -#if QT_STRINGVIEW_LEVEL < 2 short toShort(const QString &s, bool *ok = nullptr) const { return toShort(qToStringViewIgnoringNull(s), ok); } ushort toUShort(const QString &s, bool *ok = nullptr) const @@ -943,7 +940,6 @@ public: { return toFloat(qToStringViewIgnoringNull(s), ok); } double toDouble(const QString &s, bool *ok = nullptr) const { return toDouble(qToStringViewIgnoringNull(s), ok); } -#endif short toShort(QStringView s, bool *ok = nullptr) const; ushort toUShort(QStringView s, bool *ok = nullptr) const; @@ -968,13 +964,11 @@ public: QString toString(float f, char format = 'g', int precision = 6) const { return toString(double(f), format, precision); } -#if QT_STRINGVIEW_LEVEL < 2 // (Can't inline first two: passing by value doesn't work when only forward-declared.) QString toString(QDate date, const QString &format) const; QString toString(QTime time, const QString &format) const; QString toString(const QDateTime &dateTime, const QString &format) const { return toString(dateTime, qToStringViewIgnoringNull(format)); } -#endif QString toString(QDate date, QStringView format) const; QString toString(QTime time, QStringView format) const; QString toString(const QDateTime &dateTime, QStringView format) const; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index c569bf627d..1a78c1d0cd 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -4079,7 +4079,6 @@ QString &QString::replace(QChar c, QLatin1StringView after, Qt::CaseSensitivity go through QObject::tr(), for example. */ -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns the index position of the first occurrence of the string \a str in this string, searching forward from index position \a @@ -4101,7 +4100,6 @@ qsizetype QString::indexOf(const QString &str, qsizetype from, Qt::CaseSensitivi { return QtPrivate::findString(QStringView(unicode(), length()), from, QStringView(str.unicode(), str.length()), cs); } -#endif // QT_STRINGVIEW_LEVEL < 2 /*! \fn qsizetype QString::indexOf(QStringView str, qsizetype from, Qt::CaseSensitivity cs) const @@ -4157,7 +4155,6 @@ qsizetype QString::indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) con return qFindChar(QStringView(unicode(), length()), ch, from, cs); } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns the index position of the last occurrence of the string \a str in this string, searching backward from index position \a @@ -4204,7 +4201,6 @@ qsizetype QString::lastIndexOf(const QString &str, qsizetype from, Qt::CaseSensi \sa indexOf(), contains(), count() */ -#endif // QT_STRINGVIEW_LEVEL < 2 /*! \since 4.5 @@ -4496,7 +4492,6 @@ qsizetype QString::count(QStringView str, Qt::CaseSensitivity cs) const return QtPrivate::count(*this, str, cs); } -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn bool QString::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Returns \c true if this string contains an occurrence of the string @@ -4510,7 +4505,6 @@ qsizetype QString::count(QStringView str, Qt::CaseSensitivity cs) const \sa indexOf(), count() */ -#endif // QT_STRINGVIEW_LEVEL < 2 /*! \fn bool QString::contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const \since 5.3 @@ -5036,7 +5030,6 @@ QString QString::mid(qsizetype position, qsizetype n) const \sa endsWith(), first(), last(), sliced(), chop(), truncate() */ -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns \c true if the string starts with \a s; otherwise returns \c false. @@ -5052,7 +5045,6 @@ bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const { return qt_starts_with_impl(QStringView(*this), QStringView(s), cs); } -#endif /*! \overload startsWith() @@ -5091,7 +5083,6 @@ bool QString::startsWith(QChar c, Qt::CaseSensitivity cs) const \sa endsWith() */ -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns \c true if the string ends with \a s; otherwise returns \c false. @@ -5107,7 +5098,6 @@ bool QString::endsWith(const QString &s, Qt::CaseSensitivity cs) const { return qt_ends_with_impl(QStringView(*this), QStringView(s), cs); } -#endif // QT_STRINGVIEW_LEVEL < 2 /*! \fn bool QString::endsWith(QStringView str, Qt::CaseSensitivity cs) const @@ -6215,7 +6205,6 @@ QString& QString::fill(QChar ch, qsizetype size) sensitivity setting \a cs. */ -#if QT_STRINGVIEW_LEVEL < 2 /*! \overload compare() \since 4.2 @@ -6231,7 +6220,6 @@ int QString::compare(const QString &other, Qt::CaseSensitivity cs) const noexcep { return QtPrivate::compareStrings(*this, other, cs); } -#endif /*! \internal @@ -8108,7 +8096,6 @@ static QString replaceArgEscapes(QStringView s, const ArgEscapeData &d, qsizetyp return result; } -#if QT_STRINGVIEW_LEVEL < 2 /*! Returns a copy of this string with the lowest numbered place marker replaced by string \a a, i.e., \c %1, \c %2, ..., \c %99. @@ -8142,7 +8129,6 @@ QString QString::arg(const QString &a, int fieldWidth, QChar fillChar) const { return arg(qToStringViewIgnoringNull(a), fieldWidth, fillChar); } -#endif // QT_STRINGVIEW_LEVEL < 2 /*! \overload diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h index a176cae038..3f15001ff8 100644 --- a/src/corelib/text/qstring.h +++ b/src/corelib/text/qstring.h @@ -517,10 +517,8 @@ public: QChar fillChar = u' ') const; [[nodiscard]] QString arg(QChar a, int fieldWidth = 0, QChar fillChar = u' ') const; -#if QT_STRINGVIEW_LEVEL < 2 [[nodiscard]] QString arg(const QString &a, int fieldWidth = 0, QChar fillChar = u' ') const; -#endif [[nodiscard]] QString arg(QStringView a, int fieldWidth = 0, QChar fillChar = u' ') const; [[nodiscard]] QString arg(QLatin1StringView a, int fieldWidth = 0, @@ -557,9 +555,7 @@ public: [[nodiscard]] qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; [[nodiscard]] qsizetype indexOf(QLatin1StringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#if QT_STRINGVIEW_LEVEL < 2 [[nodiscard]] qsizetype indexOf(const QString &s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#endif [[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::findString(*this, from, s, cs); } [[nodiscard]] qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept @@ -568,11 +564,9 @@ public: [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return lastIndexOf(s, size(), cs); } [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#if QT_STRINGVIEW_LEVEL < 2 [[nodiscard]] qsizetype lastIndexOf(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const { return lastIndexOf(s, size(), cs); } [[nodiscard]] qsizetype lastIndexOf(const QString &s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#endif [[nodiscard]] qsizetype lastIndexOf(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return lastIndexOf(s, size(), cs); } @@ -580,9 +574,7 @@ public: { return QtPrivate::lastIndexOf(*this, from, s, cs); } [[nodiscard]] inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#if QT_STRINGVIEW_LEVEL < 2 [[nodiscard]] inline bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#endif [[nodiscard]] inline bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; [[nodiscard]] inline bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -636,17 +628,13 @@ public: { Q_ASSERT(n >= 0); Q_ASSERT(n <= size()); return first(size() - n); } -#if QT_STRINGVIEW_LEVEL < 2 bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#endif [[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::startsWith(*this, s, cs); } bool startsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#if QT_STRINGVIEW_LEVEL < 2 bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; -#endif [[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::endsWith(*this, s, cs); } bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -690,33 +678,25 @@ public: QString &insert(qsizetype i, QChar c); QString &insert(qsizetype i, const QChar *uc, qsizetype len); -#if QT_STRINGVIEW_LEVEL < 2 inline QString &insert(qsizetype i, const QString &s) { return insert(i, s.constData(), s.length()); } -#endif inline QString &insert(qsizetype i, QStringView v) { return insert(i, v.data(), v.length()); } QString &insert(qsizetype i, QLatin1StringView s); QString &append(QChar c); QString &append(const QChar *uc, qsizetype len); -#if QT_STRINGVIEW_LEVEL < 2 QString &append(const QString &s); -#endif inline QString &append(QStringView v) { return append(v.data(), v.length()); } QString &append(QLatin1StringView s); inline QString &prepend(QChar c) { return insert(0, c); } inline QString &prepend(const QChar *uc, qsizetype len) { return insert(0, uc, len); } -#if QT_STRINGVIEW_LEVEL < 2 inline QString &prepend(const QString &s) { return insert(0, s); } -#endif inline QString &prepend(QStringView v) { return prepend(v.data(), v.length()); } inline QString &prepend(QLatin1StringView s) { return insert(0, s); } inline QString &operator+=(QChar c) { return append(c); } -#if QT_STRINGVIEW_LEVEL < 2 inline QString &operator+=(const QString &s) { return append(s); } -#endif inline QString &operator+=(QStringView v) { return append(v); } inline QString &operator+=(QLatin1StringView s) { return append(s); } @@ -862,9 +842,7 @@ public: QString &setUnicode(const QChar *unicode, qsizetype size); inline QString &setUtf16(const ushort *utf16, qsizetype size); // ### Qt 7 char16_t -#if QT_STRINGVIEW_LEVEL < 2 int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; -#endif int compare(QLatin1StringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; inline int compare(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; int compare(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept @@ -1395,10 +1373,8 @@ inline QString::const_iterator QString::cend() const { return reinterpret_cast(d.data() + d.size); } inline QString::const_iterator QString::constEnd() const { return reinterpret_cast(d.data() + d.size); } -#if QT_STRINGVIEW_LEVEL < 2 inline bool QString::contains(const QString &s, Qt::CaseSensitivity cs) const { return indexOf(s, 0, cs) != -1; } -#endif inline bool QString::contains(QLatin1StringView s, Qt::CaseSensitivity cs) const { return indexOf(s, 0, cs) != -1; } inline bool QString::contains(QChar c, Qt::CaseSensitivity cs) const diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp index d157270018..8eb730ee02 100644 --- a/src/corelib/text/qstringlist.cpp +++ b/src/corelib/text/qstringlist.cpp @@ -240,7 +240,6 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs) } -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QStringList QStringList::filter(const QString &str, Qt::CaseSensitivity cs) const @@ -260,7 +259,6 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs) \sa contains() */ -#endif /*! \fn QStringList QStringList::filter(QStringView str, Qt::CaseSensitivity cs) const @@ -289,7 +287,6 @@ static bool stringList_contains(const QStringList &stringList, const T &str, Qt: } -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn bool QStringList::contains(const QString &str, Qt::CaseSensitivity cs) const @@ -299,7 +296,6 @@ static bool stringList_contains(const QStringList &stringList, const T &str, Qt: \sa indexOf(), lastIndexOf(), QString::contains() */ -#endif /*! \fn bool QStringList::contains(QStringView str, Qt::CaseSensitivity cs) const @@ -354,7 +350,6 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula } #endif // QT_CONFIG(regularexpression) -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QStringList &QStringList::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs) @@ -382,7 +377,6 @@ QStringList QtPrivate::QStringList_filter(const QStringList *that, const QRegula \overload \since 5.14 */ -#endif /*! \fn QStringList &QStringList::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs) @@ -438,7 +432,6 @@ static qsizetype accumulatedSize(const QStringList &list, qsizetype seplen) return result; } -#if QT_STRINGVIEW_LEVEL < 2 /*! \fn QString QStringList::join(const QString &separator) const @@ -448,7 +441,6 @@ static qsizetype accumulatedSize(const QStringList &list, qsizetype seplen) \sa QString::split() */ -#endif /*! \fn QString QStringList::join(QChar separator) const diff --git a/src/corelib/text/qstringlist.h b/src/corelib/text/qstringlist.h index f4502570dd..079f156479 100644 --- a/src/corelib/text/qstringlist.h +++ b/src/corelib/text/qstringlist.h @@ -86,7 +86,6 @@ public: return *self(); } -#if QT_STRINGVIEW_LEVEL < 2 inline QString join(const QString &sep) const { return QtPrivate::QStringList_join(self(), sep.constData(), sep.length()); } inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const @@ -106,7 +105,6 @@ public: QtPrivate::QStringList_replaceInStrings(self(), before, after, cs); return *self(); } -#endif using QListSpecialMethodsBase::contains; using QListSpecialMethodsBase::indexOf; using QListSpecialMethodsBase::lastIndexOf; @@ -116,14 +114,12 @@ public: inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::QStringList_contains(self(), str, cs); } -#if QT_STRINGVIEW_LEVEL < 2 inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept { return QtPrivate::QStringList_contains(self(), str, cs); } qsizetype indexOf(const QString &str, qsizetype from = 0) const noexcept { return indexOf(QStringView(str), from); } qsizetype lastIndexOf(const QString &str, qsizetype from = -1) const noexcept { return lastIndexOf(QStringView(str), from); } -#endif #if QT_CONFIG(regularexpression) inline QStringList filter(const QRegularExpression &re) const diff --git a/src/corelib/text/qstringview.h b/src/corelib/text/qstringview.h index ba7cb30c5b..3f0812e2e7 100644 --- a/src/corelib/text/qstringview.h +++ b/src/corelib/text/qstringview.h @@ -5,14 +5,7 @@ #define QSTRINGVIEW_H /* - This macro enables three "levels" of QStringView support: - - 1. offer QStringView, overload some functions taking QString with - QStringView - - 2. Obsolete: QStringRef and its overloads have been removed. - - 3. like 2, but replace functions taking QString, too. + Obsolete. */ #ifndef QT_STRINGVIEW_LEVEL # define QT_STRINGVIEW_LEVEL 1 diff --git a/src/corelib/time/qdatetime.h b/src/corelib/time/qdatetime.h index 08f0a1a533..58dff850db 100644 --- a/src/corelib/time/qdatetime.h +++ b/src/corelib/time/qdatetime.h @@ -114,10 +114,8 @@ public: #if QT_CONFIG(datestring) QString toString(Qt::DateFormat format = Qt::TextDate) const; -# if QT_STRINGVIEW_LEVEL < 2 QString toString(const QString &format, QCalendar cal = QCalendar()) const { return toString(qToStringViewIgnoringNull(format), cal); } -# endif QString toString(QStringView format, QCalendar cal = QCalendar()) const; #endif bool setDate(int year, int month, int day); // Gregorian-optimized @@ -146,13 +144,11 @@ public: static QDate fromString(QStringView string, QStringView format, QCalendar cal = QCalendar()) { return fromString(string.toString(), format, cal); } static QDate fromString(const QString &string, QStringView format, QCalendar cal = QCalendar()); -# if QT_STRINGVIEW_LEVEL < 2 static QDate fromString(const QString &string, Qt::DateFormat format = Qt::TextDate) { return fromString(qToStringViewIgnoringNull(string), format); } static QDate fromString(const QString &string, const QString &format, QCalendar cal = QCalendar()) { return fromString(string, qToStringViewIgnoringNull(format), cal); } -# endif #endif static bool isValid(int y, int m, int d); static bool isLeapYear(int year); @@ -204,10 +200,8 @@ public: int msec() const; #if QT_CONFIG(datestring) QString toString(Qt::DateFormat f = Qt::TextDate) const; -#if QT_STRINGVIEW_LEVEL < 2 QString toString(const QString &format) const { return toString(qToStringViewIgnoringNull(format)); } -#endif QString toString(QStringView format) const; #endif bool setHMS(int h, int m, int s, int ms = 0); @@ -226,12 +220,10 @@ public: static QTime fromString(QStringView string, QStringView format) { return fromString(string.toString(), format); } static QTime fromString(const QString &string, QStringView format); -# if QT_STRINGVIEW_LEVEL < 2 static QTime fromString(const QString &string, Qt::DateFormat format = Qt::TextDate) { return fromString(qToStringViewIgnoringNull(string), format); } static QTime fromString(const QString &string, const QString &format) { return fromString(string, qToStringViewIgnoringNull(format)); } -# endif #endif static bool isValid(int h, int m, int s, int ms = 0); @@ -348,10 +340,8 @@ public: #if QT_CONFIG(datestring) QString toString(Qt::DateFormat format = Qt::TextDate) const; -# if QT_STRINGVIEW_LEVEL < 2 QString toString(const QString &format, QCalendar cal = QCalendar()) const { return toString(qToStringViewIgnoringNull(format), cal); } -# endif QString toString(QStringView format, QCalendar cal = QCalendar()) const; #endif [[nodiscard]] QDateTime addDays(qint64 days) const; @@ -385,13 +375,11 @@ public: { return fromString(string.toString(), format, cal); } static QDateTime fromString(const QString &string, QStringView format, QCalendar cal = QCalendar()); -# if QT_STRINGVIEW_LEVEL < 2 static QDateTime fromString(const QString &string, Qt::DateFormat format = Qt::TextDate) { return fromString(qToStringViewIgnoringNull(string), format); } static QDateTime fromString(const QString &string, const QString &format, QCalendar cal = QCalendar()) { return fromString(string, qToStringViewIgnoringNull(format), cal); } -# endif #endif static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec = Qt::LocalTime, diff --git a/src/corelib/tools/qhashfunctions.h b/src/corelib/tools/qhashfunctions.h index e9da071803..c946cc61bc 100644 --- a/src/corelib/tools/qhashfunctions.h +++ b/src/corelib/tools/qhashfunctions.h @@ -156,10 +156,8 @@ inline Q_DECL_PURE_FUNCTION size_t qHash(const QByteArray &key, size_t seed = 0 #endif Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QStringView key, size_t seed = 0) noexcept; -#if QT_STRINGVIEW_LEVEL < 2 inline Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) noexcept { return qHash(QStringView{key}, seed); } -#endif Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1StringView key, size_t seed = 0) noexcept; Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(QKeyCombination key, size_t seed = 0) noexcept