diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-26 22:18:40 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-07-29 11:17:28 +0300 |
commit | adab531771a1ddce7df6652449b7977f340ebfc7 (patch) | |
tree | e4373c2c618af1c0bd54178cf502f6ca2fd1be5c | |
parent | eb39185acba01250240c289b1b3e64892f615357 (diff) |
Port from QStringViewLiteral to u""
Now that all our supported compilers know char16_t, we no longer need
QStringViewLiteral, whose only purpose in life was to turn u"" into
L"" for MSVC < 2015.
Change-Id: I25a094fe7992d9d5dbeb4a524d9e99e043dcb8ce
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/corelib/io/qtldurl.cpp | 6 | ||||
-rw-r--r-- | src/corelib/serialization/qxmlstream.cpp | 4 | ||||
-rw-r--r-- | src/corelib/time/qdatetime.cpp | 8 | ||||
-rw-r--r-- | src/network/access/qnetworkrequest.cpp | 2 | ||||
-rw-r--r-- | src/plugins/sqldrivers/psql/qsql_psql.cpp | 4 | ||||
-rw-r--r-- | src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp | 2 | ||||
-rw-r--r-- | src/plugins/sqldrivers/tds/qsql_tds.cpp | 2 | ||||
-rw-r--r-- | src/printsupport/kernel/qcups.cpp | 2 | ||||
-rw-r--r-- | src/testlib/qtest.h | 6 | ||||
-rw-r--r-- | tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/io/qdebug/tst_qdebug.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp | 2 | ||||
-rw-r--r-- | tests/auto/corelib/text/qlocale/tst_qlocale.cpp | 4 | ||||
-rw-r--r-- | tests/auto/corelib/text/qstring/tst_qstring.cpp | 6 | ||||
-rw-r--r-- | tests/auto/corelib/text/qstringview/tst_qstringview.cpp | 12 |
16 files changed, 33 insertions, 33 deletions
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp index a934d19fa2..912609ec91 100644 --- a/src/corelib/io/qtldurl.cpp +++ b/src/corelib/io/qtldurl.cpp @@ -59,9 +59,9 @@ enum TLDMatchType { static bool containsTLDEntry(QStringView entry, TLDMatchType match) { const QStringView matchSymbols[] = { - QStringViewLiteral(""), - QStringViewLiteral("*"), - QStringViewLiteral("!"), + u"", + u"*", + u"!", }; const auto symbol = matchSymbols[match]; int index = qt_hash(entry, qt_hash(symbol)) % tldCount; diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 27a5137fc9..500e0aa6be 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -782,8 +782,8 @@ QXmlStreamPrivateTagStack::QXmlStreamPrivateTagStack() tagStackStringStorage.reserve(32); tagStackStringStorageSize = 0; NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push(); - namespaceDeclaration.prefix = addToStringStorage(QStringViewLiteral("xml")); - namespaceDeclaration.namespaceUri = addToStringStorage(QStringViewLiteral("http://www.w3.org/XML/1998/namespace")); + namespaceDeclaration.prefix = addToStringStorage(u"xml"); + namespaceDeclaration.namespaceUri = addToStringStorage(u"http://www.w3.org/XML/1998/namespace"); initialTagStackStringStorageSize = tagStackStringStorageSize; } diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 5142d2442c..64943bdaaf 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -1129,7 +1129,7 @@ QString QDate::toString(Qt::DateFormat format) const case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat); case Qt::RFC2822Date: - return QLocale::c().toString(*this, QStringViewLiteral("dd MMM yyyy")); + return QLocale::c().toString(*this, u"dd MMM yyyy"); default: #if QT_CONFIG(textdate) case Qt::TextDate: @@ -4122,7 +4122,7 @@ QString QDateTime::toString(Qt::DateFormat format) const case Qt::DefaultLocaleLongDate: return QLocale().toString(*this, QLocale::LongFormat); case Qt::RFC2822Date: { - buf = QLocale::c().toString(*this, QStringViewLiteral("dd MMM yyyy hh:mm:ss ")); + buf = QLocale::c().toString(*this, u"dd MMM yyyy hh:mm:ss "); buf += toOffsetString(Qt::TextDate, offsetFromUtc()); return buf; } @@ -5622,7 +5622,7 @@ QDebug operator<<(QDebug dbg, const QTime &time) QDebugStateSaver saver(dbg); dbg.nospace() << "QTime("; if (time.isValid()) - dbg.nospace() << time.toString(QStringViewLiteral("HH:mm:ss.zzz")); + dbg.nospace() << time.toString(u"HH:mm:ss.zzz"); else dbg.nospace() << "Invalid"; dbg.nospace() << ')'; @@ -5635,7 +5635,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) dbg.nospace() << "QDateTime("; if (date.isValid()) { const Qt::TimeSpec ts = date.timeSpec(); - dbg.noquote() << date.toString(QStringViewLiteral("yyyy-MM-dd HH:mm:ss.zzz t")) + dbg.noquote() << date.toString(u"yyyy-MM-dd HH:mm:ss.zzz t") << ' ' << ts; switch (ts) { case Qt::UTC: diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index c82eb8fe9f..37f64c3f52 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -1355,7 +1355,7 @@ QDateTime QNetworkHeadersPrivate::fromHttpDate(const QByteArray &value) QByteArray QNetworkHeadersPrivate::toHttpDate(const QDateTime &dt) { - return QLocale::c().toString(dt, QStringViewLiteral("ddd, dd MMM yyyy hh:mm:ss 'GMT'")) + return QLocale::c().toString(dt, u"ddd, dd MMM yyyy hh:mm:ss 'GMT'") .toLatin1(); } diff --git a/src/plugins/sqldrivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp index bf9424897d..0bae45382d 100644 --- a/src/plugins/sqldrivers/psql/qsql_psql.cpp +++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp @@ -1506,7 +1506,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const // this is safe since postgresql stores only the UTC value and not the timezone offset (only used // while parsing), so we have correct behavior in both case of with timezone and without tz r = QStringLiteral("TIMESTAMP WITH TIME ZONE ") + QLatin1Char('\'') + - QLocale::c().toString(field.value().toDateTime().toUTC(), QStringViewLiteral("yyyy-MM-ddThh:mm:ss.zzz")) + + QLocale::c().toString(field.value().toDateTime().toUTC(), u"yyyy-MM-ddThh:mm:ss.zzz") + QLatin1Char('Z') + QLatin1Char('\''); } else { r = nullStr(); @@ -1518,7 +1518,7 @@ QString QPSQLDriver::formatValue(const QSqlField &field, bool trimStrings) const case QVariant::Time: #if QT_CONFIG(datestring) if (field.value().toTime().isValid()) { - r = QLatin1Char('\'') + field.value().toTime().toString(QStringViewLiteral("hh:mm:ss.zzz")) + QLatin1Char('\''); + r = QLatin1Char('\'') + field.value().toTime().toString(u"hh:mm:ss.zzz") + QLatin1Char('\''); } else #endif { diff --git a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp index f1a003ddcd..001bd673fc 100644 --- a/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp +++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp @@ -531,7 +531,7 @@ bool QSQLiteResult::exec() } case QVariant::Time: { const QTime time = value.toTime(); - const QString str = time.toString(QStringViewLiteral("hh:mm:ss.zzz")); + const QString str = time.toString(u"hh:mm:ss.zzz"); res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), str.size() * sizeof(ushort), SQLITE_TRANSIENT); break; diff --git a/src/plugins/sqldrivers/tds/qsql_tds.cpp b/src/plugins/sqldrivers/tds/qsql_tds.cpp index 603372230d..9c8d242028 100644 --- a/src/plugins/sqldrivers/tds/qsql_tds.cpp +++ b/src/plugins/sqldrivers/tds/qsql_tds.cpp @@ -813,7 +813,7 @@ QString QTDSDriver::formatValue(const QSqlField &field, r = QLatin1String("NULL"); else if (field.type() == QVariant::DateTime) { if (field.value().toDateTime().isValid()){ - r = field.value().toDateTime().toString(QStringViewLiteral("yyyyMMdd hh:mm:ss")); + r = field.value().toDateTime().toString(u"yyyyMMdd hh:mm:ss"); r.prepend(QLatin1String("'")); r.append(QLatin1String("'")); } else diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 5236b8c8fa..2fc4621960 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -106,7 +106,7 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, if (holdUntilTime < localDateTime.time()) localDateTime = localDateTime.addDays(1); localDateTime.setTime(holdUntilTime); - return localDateTime.toUTC().time().toString(QStringViewLiteral("HH:mm")); + return localDateTime.toUTC().time().toString(u"HH:mm"); } // else fall through: Q_FALLTHROUGH(); diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 7affdcb8b4..bff8f292a5 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -95,21 +95,21 @@ template<> inline char *toString(const QByteArray &ba) template<> inline char *toString(const QTime &time) { return time.isValid() - ? qstrdup(qPrintable(time.toString(QStringViewLiteral("hh:mm:ss.zzz")))) + ? qstrdup(qPrintable(time.toString(u"hh:mm:ss.zzz"))) : qstrdup("Invalid QTime"); } template<> inline char *toString(const QDate &date) { return date.isValid() - ? qstrdup(qPrintable(date.toString(QStringViewLiteral("yyyy/MM/dd")))) + ? qstrdup(qPrintable(date.toString(u"yyyy/MM/dd"))) : qstrdup("Invalid QDate"); } template<> inline char *toString(const QDateTime &dateTime) { return dateTime.isValid() - ? qstrdup(qPrintable(dateTime.toString(QStringViewLiteral("yyyy/MM/dd hh:mm:ss.zzz[t]")))) + ? qstrdup(qPrintable(dateTime.toString(u"yyyy/MM/dd hh:mm:ss.zzz[t]"))) : qstrdup("Invalid QDateTime"); } #endif // datestring diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp index 6cadebfd7f..78b6449a69 100644 --- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp +++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp @@ -263,7 +263,7 @@ void tst_QTextCodec::fromUnicode() If the encoding is a superset of ASCII, test that the byte array is correct (no off by one, no trailing '\0'). */ - QByteArray result = codec->fromUnicode(QStringViewLiteral("abc")); + QByteArray result = codec->fromUnicode(u"abc"); if (result.startsWith('a')) { QCOMPARE(result.size(), 3); QCOMPARE(result, QByteArray("abc")); diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index a818c6c09d..584e66a7db 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -506,7 +506,7 @@ void tst_QDebug::qDebugQStringView() const { QLatin1String file, function; int line = 0; - const QStringView inView = QStringViewLiteral("input"); + const QStringView inView = u"input"; MessageHandlerSetter mhs(myMessageHandler); { qDebug() << inView; } diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp index 569c610e24..b05c89a8bb 100644 --- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp +++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp @@ -65,7 +65,7 @@ void tst_QNoDebug::noDebugOutput() const void tst_QNoDebug::streaming() const { QDateTime dt(QDate(1,2,3),QTime(4,5,6)); - const QByteArray debugString = dt.toString(QStringViewLiteral("yyyy-MM-dd HH:mm:ss.zzz t")).toLatin1(); + const QByteArray debugString = dt.toString(u"yyyy-MM-dd HH:mm:ss.zzz t").toLatin1(); const QByteArray message = "QDateTime(" + debugString + " Qt::LocalTime)"; QTest::ignoreMessage(QtWarningMsg, message.constData()); qWarning() << dt; diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index 32306e8003..6381ce5ed0 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -2586,7 +2586,7 @@ void tst_QTextStream::stringview_write_operator_ToDevice() QBuffer buf; buf.open(QBuffer::WriteOnly); QTextStream stream(&buf); - const QStringView expected = QStringViewLiteral("expectedStringView"); + const QStringView expected = u"expectedStringView"; stream << expected; stream.flush(); QCOMPARE(buf.buffer().constData(), "expectedStringView"); diff --git a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp index ec8f2fc047..676c66df3e 100644 --- a/tests/auto/corelib/text/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/text/qlocale/tst_qlocale.cpp @@ -1459,8 +1459,8 @@ void tst_QLocale::dayOfWeek() QCOMPARE(QLocale::c().toString(date, "ddd"), shortName); QCOMPARE(QLocale::c().toString(date, "dddd"), longName); - QCOMPARE(QLocale::c().toString(date, QStringViewLiteral("ddd")), shortName); - QCOMPARE(QLocale::c().toString(date, QStringViewLiteral("dddd")), longName); + QCOMPARE(QLocale::c().toString(date, u"ddd"), shortName); + QCOMPARE(QLocale::c().toString(date, u"dddd"), longName); } void tst_QLocale::formatDate_data() diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index e4aa00f500..cce3e601cd 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -4763,7 +4763,7 @@ void tst_QString::arg() QCOMPARE( s4.arg("foo"), QLatin1String("[foo]") ); QCOMPARE( s5.arg(QLatin1String("foo")), QLatin1String("[foo]") ); - QCOMPARE( s6.arg(QStringViewLiteral("foo")), QLatin1String("[foo]") ); + QCOMPARE( s6.arg(u"foo"), QLatin1String("[foo]") ); QCOMPARE( s7.arg("foo"), QLatin1String("[foo]") ); QCOMPARE( s8.arg("foo"), QLatin1String("[foo %1]") ); QCOMPARE( s8.arg("foo").arg("bar"), QLatin1String("[foo bar]") ); @@ -4825,10 +4825,10 @@ void tst_QString::arg() QCOMPARE( QString("%1").arg("hello", -10), QLatin1String("hello ") ); QCOMPARE( QString("%1").arg(QLatin1String("hello"), -5), QLatin1String("hello") ); - QCOMPARE( QString("%1").arg(QStringViewLiteral("hello"), -2), QLatin1String("hello") ); + QCOMPARE( QString("%1").arg(u"hello", -2), QLatin1String("hello") ); QCOMPARE( QString("%1").arg("hello", 0), QLatin1String("hello") ); QCOMPARE( QString("%1").arg(QLatin1String("hello"), 2), QLatin1String("hello") ); - QCOMPARE( QString("%1").arg(QStringViewLiteral("hello"), 5), QLatin1String("hello") ); + QCOMPARE( QString("%1").arg(u"hello", 5), QLatin1String("hello") ); QCOMPARE( QString("%1").arg("hello", 10), QLatin1String(" hello") ); QCOMPARE( QString("%1%1").arg("hello"), QLatin1String("hellohello") ); QCOMPARE( QString("%2%1").arg("hello"), QLatin1String("%2hello") ); diff --git a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp index 794f39708a..5d95f43d6a 100644 --- a/tests/auto/corelib/text/qstringview/tst_qstringview.cpp +++ b/tests/auto/corelib/text/qstringview/tst_qstringview.cpp @@ -251,7 +251,7 @@ void tst_QStringView::constExpr() const Q_STATIC_ASSERT(sv2.empty()); } { - constexpr QStringView sv = QStringViewLiteral(""); + constexpr QStringView sv = u""; Q_STATIC_ASSERT(sv.size() == 0); Q_STATIC_ASSERT(!sv.isNull()); Q_STATIC_ASSERT(sv.empty()); @@ -263,7 +263,7 @@ void tst_QStringView::constExpr() const Q_STATIC_ASSERT(sv2.empty()); } { - constexpr QStringView sv = QStringViewLiteral("Hello"); + constexpr QStringView sv = u"Hello"; Q_STATIC_ASSERT(sv.size() == 5); Q_STATIC_ASSERT(!sv.empty()); Q_STATIC_ASSERT(!sv.isEmpty()); @@ -465,7 +465,7 @@ void tst_QStringView::arg() const #undef CHECK2 #undef CHECK1 - QCOMPARE(QStringViewLiteral(" %2 %2 %1 %3 ").arg(QLatin1Char('c'), QChar::CarriageReturn, u'C'), " \r \r c C "); + QCOMPARE(QStringView(u" %2 %2 %1 %3 ").arg(QLatin1Char('c'), QChar::CarriageReturn, u'C'), " \r \r c C "); } void tst_QStringView::fromQString() const @@ -662,9 +662,9 @@ void tst_QStringView::conversion_tests(String string) const void tst_QStringView::comparison() { - const QStringView aa = QStringViewLiteral("aa"); - const QStringView upperAa = QStringViewLiteral("AA"); - const QStringView bb = QStringViewLiteral("bb"); + const QStringView aa = u"aa"; + const QStringView upperAa = u"AA"; + const QStringView bb = u"bb"; QVERIFY(aa == aa); QVERIFY(aa != bb); |