summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-03-09 19:28:01 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2022-03-23 18:06:51 +0100
commit76db8a0b1b80ae4b6741a72c7e8f5048c155c5b2 (patch)
tree82d4db44b5da744937d8edd076e4172c87b7d6e0
parent4167a920ed36a5756a07668c3993d723ffbc60bf (diff)
Use QLatin1StringView in QString/QLatin1String APIs and docs
- Replaced QLatin1String with QLatin1StringView in QString/QLatin1String APIs and docs (except for QLatin1String class declaration and ctor names). - Made the docs look like QLatin1StringView is "The Real Thing". [ChangeLog][QtCore] Made QLatin1StringView the recommended name for referring to a Latin-1 string view (instead of QLatin1String). Task-number: QTBUG-98434 Change-Id: I6d9a85cc956c6da0c910ad7d23be7956e4bd94ac Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--src/corelib/text/qstring.cpp540
-rw-r--r--src/corelib/text/qstring.h286
-rw-r--r--src/corelib/text/qstringalgorithms.h58
-rw-r--r--src/corelib/text/qstringconverter.cpp2
-rw-r--r--src/corelib/text/qstringconverter_p.h2
-rw-r--r--src/corelib/text/qstringfwd.h2
-rw-r--r--src/corelib/text/qstringview.cpp4
7 files changed, 454 insertions, 440 deletions
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index edc2773707..de4df9fff3 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -79,7 +79,7 @@
#include "qstringalgorithms_p.h"
#include "qthreadstorage.h"
-#include "qbytearraymatcher.h" // Helper for comparison of QLatin1String
+#include "qbytearraymatcher.h" // Helper for comparison of QLatin1StringView
#include <algorithm>
#include <functional>
@@ -732,7 +732,7 @@ bool qt_is_ascii(const char *&ptr, const char *end) noexcept
return true;
}
-bool QtPrivate::isAscii(QLatin1String s) noexcept
+bool QtPrivate::isAscii(QLatin1StringView s) noexcept
{
const char *ptr = s.begin();
const char *end = s.end();
@@ -1053,7 +1053,7 @@ Q_NEVER_INLINE static int ucstricmp(qsizetype alen, const char16_t *a, qsizetype
return 1;
}
-// Case-insensitive comparison between a QStringView and a QLatin1String
+// Case-insensitive comparison between a QStringView and a QLatin1StringView
// (argument order matches those types)
Q_NEVER_INLINE static int ucstricmp(qsizetype alen, const char16_t *a, qsizetype blen, const char *b)
{
@@ -1398,7 +1398,7 @@ static constexpr uchar latin1Lower[256] = {
};
static int latin1nicmp(const char *lhsChar, qsizetype lSize, const char *rhsChar, qsizetype rSize)
{
- // We're called with QLatin1String's .data() and .size():
+ // We're called with QLatin1StringView's .data() and .size():
Q_ASSERT(lSize >= 0 && rSize >= 0);
if (!lSize)
return rSize ? -1 : 0;
@@ -1420,17 +1420,17 @@ bool QtPrivate::equalStrings(QStringView lhs, QStringView rhs) noexcept
return ucstreq(lhs.utf16(), lhs.size(), rhs.utf16(), rhs.size());
}
-bool QtPrivate::equalStrings(QStringView lhs, QLatin1String rhs) noexcept
+bool QtPrivate::equalStrings(QStringView lhs, QLatin1StringView rhs) noexcept
{
return ucstreq(lhs.utf16(), lhs.size(), rhs.latin1(), rhs.size());
}
-bool QtPrivate::equalStrings(QLatin1String lhs, QStringView rhs) noexcept
+bool QtPrivate::equalStrings(QLatin1StringView lhs, QStringView rhs) noexcept
{
return QtPrivate::equalStrings(rhs, lhs);
}
-bool QtPrivate::equalStrings(QLatin1String lhs, QLatin1String rhs) noexcept
+bool QtPrivate::equalStrings(QLatin1StringView lhs, QLatin1StringView rhs) noexcept
{
return lhs.size() == rhs.size() && (!lhs.size() || memcmp(lhs.data(), rhs.data(), lhs.size()) == 0);
}
@@ -1445,13 +1445,13 @@ bool QtPrivate::equalStrings(QStringView lhs, QBasicUtf8StringView<false> rhs) n
return QtPrivate::equalStrings(rhs, lhs);
}
-bool QtPrivate::equalStrings(QLatin1String lhs, QBasicUtf8StringView<false> rhs) noexcept
+bool QtPrivate::equalStrings(QLatin1StringView lhs, QBasicUtf8StringView<false> rhs) noexcept
{
QString r = rhs.toString();
return QtPrivate::equalStrings(lhs, r); // ### optimize!
}
-bool QtPrivate::equalStrings(QBasicUtf8StringView<false> lhs, QLatin1String rhs) noexcept
+bool QtPrivate::equalStrings(QBasicUtf8StringView<false> lhs, QLatin1StringView rhs) noexcept
{
return QtPrivate::equalStrings(rhs, lhs);
}
@@ -1512,7 +1512,7 @@ int QtPrivate::compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitiv
\sa {Comparing Strings}
*/
-int QtPrivate::compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept
+int QtPrivate::compareStrings(QStringView lhs, QLatin1StringView rhs, Qt::CaseSensitivity cs) noexcept
{
if (cs == Qt::CaseSensitive)
return ucstrcmp(lhs.utf16(), lhs.size(), rhs.latin1(), rhs.size());
@@ -1536,7 +1536,7 @@ int QtPrivate::compareStrings(QStringView lhs, QBasicUtf8StringView<false> rhs,
\since 5.10
\overload
*/
-int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept
+int QtPrivate::compareStrings(QLatin1StringView lhs, QStringView rhs, Qt::CaseSensitivity cs) noexcept
{
return -compareStrings(rhs, lhs, cs);
}
@@ -1558,7 +1558,7 @@ int QtPrivate::compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensit
\sa {Comparing Strings}
*/
-int QtPrivate::compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept
+int QtPrivate::compareStrings(QLatin1StringView lhs, QLatin1StringView rhs, Qt::CaseSensitivity cs) noexcept
{
if (lhs.isEmpty())
return lencmp(qsizetype(0), rhs.size());
@@ -1575,7 +1575,7 @@ int QtPrivate::compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSens
\since 6.0
\overload
*/
-int QtPrivate::compareStrings(QLatin1String lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs) noexcept
+int QtPrivate::compareStrings(QLatin1StringView lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs) noexcept
{
return compareStrings(lhs, rhs.toString(), cs); // ### optimize!
}
@@ -1599,7 +1599,7 @@ int QtPrivate::compareStrings(QBasicUtf8StringView<false> lhs, QStringView rhs,
\since 6.0
\overload
*/
-int QtPrivate::compareStrings(QBasicUtf8StringView<false> lhs, QLatin1String rhs, Qt::CaseSensitivity cs) noexcept
+int QtPrivate::compareStrings(QBasicUtf8StringView<false> lhs, QLatin1StringView rhs, Qt::CaseSensitivity cs) noexcept
{
return -compareStrings(rhs, lhs, cs);
}
@@ -1679,7 +1679,7 @@ void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *whe
and the \c{QString::operator=(const char (&ch)[N])} assignment operator.
This gives most of the type-safety benefits of \l QT_NO_CAST_FROM_ASCII
but does not require user code to wrap character and string literals
- with QLatin1Char, QLatin1String or similar.
+ with QLatin1Char, QLatin1StringView or similar.
Using this macro together with source strings outside the 7-bit range,
non-literals, or literals with embedded NUL characters is undefined.
@@ -1984,7 +1984,7 @@ void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *whe
You then need to explicitly call fromUtf8(), fromLatin1(),
or fromLocal8Bit() to construct a QString from an
- 8-bit string, or use the lightweight QLatin1String class, for
+ 8-bit string, or use the lightweight QLatin1StringView class, for
example:
\snippet code/src_corelib_text_qstring.cpp 1
@@ -2066,7 +2066,7 @@ void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *whe
time. Constructing a QString out of the literal does then not cause
any overhead at runtime.
- A slightly less efficient way is to use QLatin1String. This class wraps
+ A slightly less efficient way is to use QLatin1StringView. This class wraps
a C string literal, precalculates it length at compile time and can
then be used for faster comparison with QStrings and conversion to
QStrings than a regular C string literal.
@@ -2145,7 +2145,7 @@ void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *whe
Such considerations, the configuration of such behavior or any mitigation
are outside the scope of the Qt API.
- \sa fromRawData(), QChar, QStringView, QLatin1String, QByteArray
+ \sa fromRawData(), QChar, QStringView, QLatin1StringView, QByteArray
*/
/*! \typedef QString::ConstIterator
@@ -2552,7 +2552,7 @@ QString::QString(qsizetype size, Qt::Initialization)
}
}
-/*! \fn QString::QString(QLatin1String str)
+/*! \fn QString::QString(QLatin1StringView str)
Constructs a copy of the Latin-1 string \a str.
@@ -2825,13 +2825,13 @@ QString &QString::operator=(const QString &other) noexcept
\since 5.2
*/
-/*! \fn QString &QString::operator=(QLatin1String str)
+/*! \fn QString &QString::operator=(QLatin1StringView str)
\overload operator=()
Assigns the Latin-1 string \a str to this string.
*/
-QString &QString::operator=(QLatin1String other)
+QString &QString::operator=(QLatin1StringView other)
{
const qsizetype capacityAtEnd = capacity() - d.freeSpaceAtBegin();
if (isDetached() && other.size() <= capacityAtEnd) { // assumes d->alloc == 0 -> !isDetached() (sharedNull)
@@ -2951,14 +2951,14 @@ QString &QString::operator=(QChar ch)
*/
/*!
- \fn QString &QString::insert(qsizetype position, QLatin1String str)
+ \fn QString &QString::insert(qsizetype position, QLatin1StringView str)
\overload insert()
Inserts the Latin-1 string \a str at the given index \a position.
\include qstring.cpp string-grow-at-insertion
*/
-QString &QString::insert(qsizetype i, QLatin1String str)
+QString &QString::insert(qsizetype i, QLatin1StringView str)
{
const char *s = str.latin1();
if (i < 0 || !s || !(*s))
@@ -3092,7 +3092,7 @@ QString &QString::append(const QChar *str, qsizetype len)
Appends the Latin-1 string \a str to this string.
*/
-QString &QString::append(QLatin1String str)
+QString &QString::append(QLatin1StringView str)
{
const char *s = str.latin1();
const qsizetype len = str.size();
@@ -3165,7 +3165,7 @@ QString &QString::append(QChar ch)
\sa append(), insert()
*/
-/*! \fn QString &QString::prepend(QLatin1String str)
+/*! \fn QString &QString::prepend(QLatin1StringView str)
\overload prepend()
@@ -3325,7 +3325,7 @@ QString &QString::remove(const QString &str, Qt::CaseSensitivity cs)
\sa replace()
*/
-QString &QString::remove(QLatin1String str, Qt::CaseSensitivity cs)
+QString &QString::remove(QLatin1StringView str, Qt::CaseSensitivity cs)
{
removeStringImpl(*this, str, cs);
return *this;
@@ -3723,7 +3723,7 @@ QString& QString::replace(QChar before, QChar after, Qt::CaseSensitivity cs)
\note The text is not rescanned after a replacement.
*/
-QString &QString::replace(QLatin1String before, QLatin1String after, Qt::CaseSensitivity cs)
+QString &QString::replace(QLatin1StringView before, QLatin1StringView after, Qt::CaseSensitivity cs)
{
qsizetype alen = after.size();
qsizetype blen = before.size();
@@ -3746,7 +3746,7 @@ QString &QString::replace(QLatin1String before, QLatin1String after, Qt::CaseSen
\note The text is not rescanned after a replacement.
*/
-QString &QString::replace(QLatin1String before, const QString &after, Qt::CaseSensitivity cs)
+QString &QString::replace(QLatin1StringView before, const QString &after, Qt::CaseSensitivity cs)
{
qsizetype blen = before.size();
QVarLengthArray<char16_t> b(blen);
@@ -3766,7 +3766,7 @@ QString &QString::replace(QLatin1String before, const QString &after, Qt::CaseSe
\note The text is not rescanned after a replacement.
*/
-QString &QString::replace(const QString &before, QLatin1String after, Qt::CaseSensitivity cs)
+QString &QString::replace(const QString &before, QLatin1StringView after, Qt::CaseSensitivity cs)
{
qsizetype alen = after.size();
QVarLengthArray<char16_t> a(alen);
@@ -3786,7 +3786,7 @@ QString &QString::replace(const QString &before, QLatin1String after, Qt::CaseSe
\note The text is not rescanned after a replacement.
*/
-QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
+QString &QString::replace(QChar c, QLatin1StringView after, Qt::CaseSensitivity cs)
{
qsizetype alen = after.size();
QVarLengthArray<char16_t> a(alen);
@@ -3806,7 +3806,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator==(const QString &s1, QLatin1String s2)
+ \fn bool QString::operator==(const QString &s1, QLatin1StringView s2)
\overload operator==()
@@ -3815,7 +3815,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator==(QLatin1String s1, const QString &s2)
+ \fn bool QString::operator==(QLatin1StringView s1, const QString &s2)
\overload operator==()
@@ -3864,7 +3864,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator<(const QString &s1, QLatin1String s2)
+ \fn bool QString::operator<(const QString &s1, QLatin1StringView s2)
\overload operator<()
@@ -3873,7 +3873,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator<(QLatin1String s1, const QString &s2)
+ \fn bool QString::operator<(QLatin1StringView s1, const QString &s2)
\overload operator<()
@@ -3920,7 +3920,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator<=(const QString &s1, QLatin1String s2)
+ \fn bool QString::operator<=(const QString &s1, QLatin1StringView s2)
\overload operator<=()
@@ -3929,7 +3929,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator<=(QLatin1String s1, const QString &s2)
+ \fn bool QString::operator<=(QLatin1StringView s1, const QString &s2)
\overload operator<=()
@@ -3973,7 +3973,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator>(const QString &s1, QLatin1String s2)
+ \fn bool QString::operator>(const QString &s1, QLatin1StringView s2)
\overload operator>()
@@ -3982,7 +3982,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator>(QLatin1String s1, const QString &s2)
+ \fn bool QString::operator>(QLatin1StringView s1, const QString &s2)
\overload operator>()
@@ -4026,7 +4026,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator>=(const QString &s1, QLatin1String s2)
+ \fn bool QString::operator>=(const QString &s1, QLatin1StringView s2)
\overload operator>=()
@@ -4035,7 +4035,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
*/
/*!
- \fn bool QString::operator>=(QLatin1String s1, const QString &s2)
+ \fn bool QString::operator>=(QLatin1StringView s1, const QString &s2)
\overload operator>=()
@@ -4078,7 +4078,7 @@ QString &QString::replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs)
\sa {Comparing Strings}
*/
-/*! \fn bool QString::operator!=(const QString &s1, QLatin1String s2)
+/*! \fn bool QString::operator!=(const QString &s1, QLatin1StringView s2)
Returns \c true if string \a s1 is not equal to string \a s2.
Otherwise returns \c false.
@@ -4174,7 +4174,7 @@ qsizetype QString::indexOf(const QString &str, qsizetype from, Qt::CaseSensitivi
\sa lastIndexOf(), contains(), count()
*/
-qsizetype QString::indexOf(QLatin1String str, qsizetype from, Qt::CaseSensitivity cs) const
+qsizetype QString::indexOf(QLatin1StringView str, qsizetype from, Qt::CaseSensitivity cs) const
{
return QtPrivate::findString(QStringView(unicode(), size()), from, str, cs);
}
@@ -4266,13 +4266,13 @@ qsizetype QString::lastIndexOf(const QString &str, qsizetype from, Qt::CaseSensi
\sa indexOf(), contains(), count()
*/
-qsizetype QString::lastIndexOf(QLatin1String str, qsizetype from, Qt::CaseSensitivity cs) const
+qsizetype QString::lastIndexOf(QLatin1StringView str, qsizetype from, Qt::CaseSensitivity cs) const
{
return QtPrivate::lastIndexOf(*this, from, str, cs);
}
/*!
- \fn qsizetype QString::lastIndexOf(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \fn qsizetype QString::lastIndexOf(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\since 6.2
\overload lastIndexOf()
@@ -4546,7 +4546,7 @@ qsizetype QString::count(QStringView str, Qt::CaseSensitivity cs) const
*/
#endif // QT_STRINGVIEW_LEVEL < 2
-/*! \fn bool QString::contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+/*! \fn bool QString::contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\since 5.3
\overload contains()
@@ -5091,7 +5091,7 @@ bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const
/*!
\overload startsWith()
*/
-bool QString::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const
+bool QString::startsWith(QLatin1StringView s, Qt::CaseSensitivity cs) const
{
return qt_starts_with_impl(QStringView(*this), s, cs);
}
@@ -5159,7 +5159,7 @@ bool QString::endsWith(const QString &s, Qt::CaseSensitivity cs) const
/*!
\overload endsWith()
*/
-bool QString::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const
+bool QString::endsWith(QLatin1StringView s, Qt::CaseSensitivity cs) const
{
return qt_ends_with_impl(QStringView(*this), s, cs);
}
@@ -5774,7 +5774,7 @@ namespace {
/*!
\fn QStringView QtPrivate::trimmed(QStringView s)
- \fn QLatin1String QtPrivate::trimmed(QLatin1String s)
+ \fn QLatin1StringView QtPrivate::trimmed(QLatin1StringView s)
\internal
\relates QStringView
\since 5.10
@@ -5785,14 +5785,14 @@ namespace {
\c true. This includes the ASCII characters '\\t', '\\n', '\\v',
'\\f', '\\r', and ' '.
- \sa QString::trimmed(), QStringView::trimmed(), QLatin1String::trimmed()
+ \sa QString::trimmed(), QStringView::trimmed(), QLatin1StringView::trimmed()
*/
QStringView QtPrivate::trimmed(QStringView s) noexcept
{
return qt_trimmed(s);
}
-QLatin1String QtPrivate::trimmed(QLatin1String s) noexcept
+QLatin1StringView QtPrivate::trimmed(QLatin1StringView s) noexcept
{
return qt_trimmed(s);
}
@@ -6050,7 +6050,7 @@ QString& QString::fill(QChar ch, qsizetype size)
\sa append(), prepend()
*/
-/*! \fn QString &QString::operator+=(QLatin1String str)
+/*! \fn QString &QString::operator+=(QLatin1StringView str)
\overload operator+=()
@@ -6211,7 +6211,7 @@ QString& QString::fill(QChar ch, qsizetype size)
*/
/*!
- \fn int QString::compare(const QString &s1, QLatin1String s2, Qt::CaseSensitivity cs)
+ \fn int QString::compare(const QString &s1, QLatin1StringView s2, Qt::CaseSensitivity cs)
\since 4.2
\overload compare()
@@ -6220,7 +6220,7 @@ QString& QString::fill(QChar ch, qsizetype size)
*/
/*!
- \fn int QString::compare(QLatin1String s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
+ \fn int QString::compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive)
\since 4.2
\overload compare()
@@ -6287,7 +6287,7 @@ int QString::compare_helper(const QChar *data1, qsizetype length1, const QChar *
Same as compare(*this, \a other, \a cs).
*/
-int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const noexcept
+int QString::compare(QLatin1StringView other, Qt::CaseSensitivity cs) const noexcept
{
return QtPrivate::compareStrings(*this, other, cs);
}
@@ -6323,8 +6323,8 @@ int QString::compare_helper(const QChar *data1, qsizetype length1, const char *d
\internal
\since 4.5
*/
-int QLatin1String::compare_helper(const QChar *data1, qsizetype length1, QLatin1String s2,
- Qt::CaseSensitivity cs) noexcept
+int QLatin1StringView::compare_helper(const QChar *data1, qsizetype length1, QLatin1StringView s2,
+ Qt::CaseSensitivity cs) noexcept
{
Q_ASSERT(length1 >= 0);
Q_ASSERT(data1 || length1 == 0);
@@ -6890,7 +6890,7 @@ QString QString::vasprintf(const char *cformat, va_list ap)
uint flags = parse_flag_characters(c);
if (*c == '\0') {
- result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
+ result.append(QLatin1StringView(escape_start)); // incomplete escape, treat as non-escape text
break;
}
@@ -6906,7 +6906,7 @@ QString QString::vasprintf(const char *cformat, va_list ap)
}
if (*c == '\0') {
- result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
+ result.append(QLatin1StringView(escape_start)); // incomplete escape, treat as non-escape text
break;
}
@@ -6925,14 +6925,14 @@ QString QString::vasprintf(const char *cformat, va_list ap)
}
if (*c == '\0') {
- result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
+ result.append(QLatin1StringView(escape_start)); // incomplete escape, treat as non-escape text
break;
}
const LengthMod length_mod = parse_length_modifier(c);
if (*c == '\0') {
- result.append(QLatin1String(escape_start)); // incomplete escape, treat as non-escape text
+ result.append(QLatin1StringView(escape_start)); // incomplete escape, treat as non-escape text
break;
}
@@ -8222,7 +8222,7 @@ QString QString::arg(QStringView a, int fieldWidth, QChar fillChar) const
is printed and the result is undefined. Place-marker numbers must be
in the range 1 to 99.
*/
-QString QString::arg(QLatin1String a, int fieldWidth, QChar fillChar) const
+QString QString::arg(QLatin1StringView a, int fieldWidth, QChar fillChar) const
{
QVarLengthArray<char16_t> utf16(a.size());
qt_from_latin1(utf16.data(), a.data(), a.size());
@@ -8596,11 +8596,11 @@ struct Part
Part() = default; // for QVarLengthArray; do not use
constexpr Part(QStringView s, int num = -1)
: tag{QtPrivate::ArgBase::U16}, number{num}, data{s.utf16()}, size{s.size()} {}
- constexpr Part(QLatin1String s, int num = -1)
+ constexpr Part(QLatin1StringView s, int num = -1)
: tag{QtPrivate::ArgBase::L1}, number{num}, data{s.data()}, size{s.size()} {}
void reset(QStringView s) noexcept { *this = {s, number}; }
- void reset(QLatin1String s) noexcept { *this = {s, number}; }
+ void reset(QLatin1StringView s) noexcept { *this = {s, number}; }
QtPrivate::ArgBase::Tag tag;
int number;
@@ -8695,7 +8695,7 @@ static qsizetype resolveStringRefsAndReturnTotalSize(ParseResult &parts, const A
} // unnamed namespace
-Q_ALWAYS_INLINE QString to_string(QLatin1String s) noexcept { return s; }
+Q_ALWAYS_INLINE QString to_string(QLatin1StringView s) noexcept { return s; }
Q_ALWAYS_INLINE QString to_string(QStringView s) noexcept { return s.toString(); }
template <typename StringView>
@@ -8747,7 +8747,7 @@ QString QtPrivate::argToQString(QStringView pattern, size_t n, const ArgBase **a
return argToQStringImpl(pattern, n, args);
}
-QString QtPrivate::argToQString(QLatin1String pattern, size_t n, const ArgBase **args)
+QString QtPrivate::argToQString(QLatin1StringView pattern, size_t n, const ArgBase **args)
{
return argToQStringImpl(pattern, n, args);
}
@@ -9004,9 +9004,9 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa toUcs4(), toStdWString(), toStdU16String()
*/
-/*! \class QLatin1String
+/*! \class QLatin1StringView
\inmodule QtCore
- \brief The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
+ \brief The QLatin1StringView class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
\ingroup string-processing
\reentrant
@@ -9032,9 +9032,9 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
Applications that define \l QT_NO_CAST_FROM_ASCII (as explained
in the QString documentation) don't have access to QString's
\c{const char *} API. To provide an efficient way of specifying
- constant Latin-1 strings, Qt provides the QLatin1String, which is
+ constant Latin-1 strings, Qt provides the QLatin1StringView, which is
just a very thin wrapper around a \c{const char *}. Using
- QLatin1String, the example code above becomes
+ QLatin1StringView, the example code above becomes
\snippet code/src_corelib_text_qstring.cpp 5
@@ -9042,16 +9042,16 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
benefits as the first version of the code, and is faster than
converting the Latin-1 strings using QString::fromLatin1().
- Thanks to the QString(QLatin1String) constructor,
- QLatin1String can be used everywhere a QString is expected. For
+ Thanks to the QString(QLatin1StringView) constructor,
+ QLatin1StringView can be used everywhere a QString is expected. For
example:
\snippet code/src_corelib_text_qstring.cpp 6
- \note If the function you're calling with a QLatin1String
- argument isn't actually overloaded to take QLatin1String, the
+ \note If the function you're calling with a QLatin1StringView
+ argument isn't actually overloaded to take QLatin1StringView, the
implicit conversion to QString will trigger a memory allocation,
- which is usually what you want to avoid by using QLatin1String
+ which is usually what you want to avoid by using QLatin1StringView
in the first place. In those cases, using QStringLiteral may be
the better option.
@@ -9060,112 +9060,124 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \typedef QLatin1String::value_type
+ \class QLatin1String
+ \inmodule QtCore
+ \brief QLatin1String is the same as QLatin1StringView.
+
+ QLatin1String is a view to a Latin-1 string. It's the same as
+ QLatin1StringView and is kept for compatibility reasons. It is
+ recommended to use QLatin1StringView instead.
+
+ Please see the QLatin1StringView documentation for details.
+*/
+
+/*!
+ \typedef QLatin1StringView::value_type
\since 5.10
Alias for \c{const char}. Provided for compatibility with the STL.
*/
/*!
- \typedef QLatin1String::difference_type
+ \typedef QLatin1StringView::difference_type
\since 5.10
Alias for \c{qsizetype}. Provided for compatibility with the STL.
*/
/*!
- \typedef QLatin1String::size_type
+ \typedef QLatin1StringView::size_type
\since 5.10
Alias for \c{qsizetype}. Provided for compatibility with the STL.
\note In version prior to Qt 6, this was an alias for \c{int},
- restricting the amount of data that could be held in a QLatin1String
+ restricting the amount of data that could be held in a QLatin1StringView
on 64-bit architectures.
*/
/*!
- \typedef QLatin1String::reference
+ \typedef QLatin1StringView::reference
\since 5.10
Alias for \c{value_type &}. Provided for compatibility with the STL.
*/
/*!
- \typedef QLatin1String::const_reference
+ \typedef QLatin1StringView::const_reference
\since 5.11
Alias for \c{reference}. Provided for compatibility with the STL.
*/
/*!
- \typedef QLatin1String::iterator
+ \typedef QLatin1StringView::iterator
\since 5.10
- QLatin1String does not support mutable iterators, so this is the same
+ QLatin1StringView does not support mutable iterators, so this is the same
as const_iterator.
\sa const_iterator, reverse_iterator
*/
/*!
- \typedef QLatin1String::const_iterator
+ \typedef QLatin1StringView::const_iterator
\since 5.10
\sa iterator, const_reverse_iterator
*/
/*!
- \typedef QLatin1String::reverse_iterator
+ \typedef QLatin1StringView::reverse_iterator
\since 5.10
- QLatin1String does not support mutable reverse iterators, so this is the
+ QLatin1StringView does not support mutable reverse iterators, so this is the
same as const_reverse_iterator.
\sa const_reverse_iterator, iterator
*/
/*!
- \typedef QLatin1String::const_reverse_iterator
+ \typedef QLatin1StringView::const_reverse_iterator
\since 5.10
\sa reverse_iterator, const_iterator
*/
-/*! \fn QLatin1String::QLatin1String()
+/*! \fn QLatin1StringView::QLatin1StringView()
\since 5.6
- Constructs a QLatin1String object that stores a \nullptr.
+ Constructs a QLatin1StringView object that stores a \nullptr.
\sa data(), isEmpty(), isNull(), {Distinction Between Null and Empty Strings}
*/
-/*! \fn QLatin1String::QLatin1String(std::nullptr_t)
+/*! \fn QLatin1StringView::QLatin1StringView(std::nullptr_t)
\since 6.4
- Constructs a QLatin1String object that stores a \nullptr.
+ Constructs a QLatin1StringView object that stores a \nullptr.
\sa data(), isEmpty(), isNull(), {Distinction Between Null and Empty Strings}
*/
-/*! \fn QLatin1String::QLatin1String(const char *str)
+/*! \fn QLatin1StringView::QLatin1StringView(const char *str)
- Constructs a QLatin1String object that stores \a str.
+ Constructs a QLatin1StringView object that stores \a str.
The string data is \e not copied. The caller must be able to
guarantee that \a str will not be deleted or modified as long as
- the QLatin1String object exists.
+ the QLatin1StringView object exists.
\sa latin1()
*/
-/*! \fn QLatin1String::QLatin1String(const char *str, qsizetype size)
+/*! \fn QLatin1StringView::QLatin1StringView(const char *str, qsizetype size)
- Constructs a QLatin1String object that stores \a str with \a size.
+ Constructs a QLatin1StringView object that stores \a str with \a size.
The string data is \e not copied. The caller must be able to
guarantee that \a str will not be deleted or modified as long as
- the QLatin1String object exists.
+ the QLatin1StringView object exists.
\note: any null ('\\0') bytes in the byte array will be included in this
string, which will be converted to Unicode null characters (U+0000) if this
@@ -9175,10 +9187,10 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::QLatin1String(const char *first, const char *last)
+ \fn QLatin1StringView::QLatin1StringView(const char *first, const char *last)
\since 5.10
- Constructs a QLatin1String object that stores \a first with length
+ Constructs a QLatin1StringView object that stores \a first with length
(\a last - \a first).
The range \c{[first,last)} must remain valid for the lifetime of
@@ -9192,25 +9204,25 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
INT_MAX}.
*/
-/*! \fn QLatin1String::QLatin1String(const QByteArray &str)
+/*! \fn QLatin1StringView::QLatin1StringView(const QByteArray &str)
- Constructs a QLatin1String object that stores \a str.
+ Constructs a QLatin1StringView object that stores \a str.
The string data is \e not copied. The caller must be able to
guarantee that \a str will not be deleted or modified as long as
- the QLatin1String object exists.
+ the QLatin1StringView object exists.
\sa latin1()
*/
-/*! \fn QLatin1String::QLatin1String(QByteArrayView str)
+/*! \fn QLatin1StringView::QLatin1StringView(QByteArrayView str)
\since 6.3
- Constructs a QLatin1String object that stores \a str.
+ Constructs a QLatin1StringView object that stores \a str.
The string data is \e not copied. The caller must be able to
guarantee that the data which \a str is pointing to will not
- be deleted or modified as long as the QLatin1String object
+ be deleted or modified as long as the QLatin1StringView object
exists. The size is obtained from \a str as-is, without checking
for a null-terminator.
@@ -9222,7 +9234,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QString QLatin1String::toString() const
+ \fn QString QLatin1StringView::toString() const
\since 6.0
Converts this Latin-1 string into a QString. Equivalent to
@@ -9231,17 +9243,17 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\endcode
*/
-/*! \fn const char *QLatin1String::latin1() const
+/*! \fn const char *QLatin1StringView::latin1() const
Returns the start of the Latin-1 string referenced by this object.
*/
-/*! \fn const char *QLatin1String::data() const
+/*! \fn const char *QLatin1StringView::data() const
Returns the start of the Latin-1 string referenced by this object.
*/
-/*! \fn const char *QLatin1String::constData() const
+/*! \fn const char *QLatin1StringView::constData() const
\since 6.4
Returns the start of the Latin-1 string referenced by this object.
@@ -9251,16 +9263,16 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa data()
*/
-/*! \fn qsizetype QLatin1String::size() const
+/*! \fn qsizetype QLatin1StringView::size() const
Returns the size of the Latin-1 string referenced by this object.
\note In version prior to Qt 6, this function returned \c{int},
- restricting the amount of data that could be held in a QLatin1String
+ restricting the amount of data that could be held in a QLatin1StringView
on 64-bit architectures.
*/
-/*! \fn qsizetype QLatin1String::length() const
+/*! \fn qsizetype QLatin1StringView::length() const
\since 6.4
Same as size().
@@ -9268,7 +9280,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
This function is provided for compatibility with other Qt containers.
*/
-/*! \fn bool QLatin1String::isNull() const
+/*! \fn bool QLatin1StringView::isNull() const
\since 5.10
Returns whether the Latin-1 string referenced by this object is null
@@ -9277,7 +9289,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa isEmpty(), data()
*/
-/*! \fn bool QLatin1String::isEmpty() const
+/*! \fn bool QLatin1StringView::isEmpty() const
\since 5.10
Returns whether the Latin-1 string referenced by this object is empty
@@ -9286,7 +9298,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa isNull(), size()
*/
-/*! \fn bool QLatin1String::empty() const
+/*! \fn bool QLatin1StringView::empty() const
\since 6.4
Returns whether the Latin-1 string referenced by this object is empty
@@ -9297,7 +9309,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa isEmpty(), isNull(), size()
*/
-/*! \fn QLatin1Char QLatin1String::at(qsizetype pos) const
+/*! \fn QLatin1Char QLatin1StringView::at(qsizetype pos) const
\since 5.8
Returns the character at position \a pos in this object.
@@ -9308,7 +9320,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa operator[]()
*/
-/*! \fn QLatin1Char QLatin1String::operator[](qsizetype pos) const
+/*! \fn QLatin1Char QLatin1StringView::operator[](qsizetype pos) const
\since 5.8
Returns the character at position \a pos in this object.
@@ -9320,7 +9332,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1Char QLatin1String::front() const
+ \fn QLatin1Char QLatin1StringView::front() const
\since 5.10
Returns the first character in the string.
@@ -9335,7 +9347,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1Char QLatin1String::first() const
+ \fn QLatin1Char QLatin1StringView::first() const
\since 6.4
Returns the first character in the string.
@@ -9350,7 +9362,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1Char QLatin1String::back() const
+ \fn QLatin1Char QLatin1StringView::back() const
\since 5.10
Returns the last character in the string.
@@ -9365,7 +9377,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1Char QLatin1String::last() const
+ \fn QLatin1Char QLatin1StringView::last() const
\since 6.4
Returns the last character in the string.
@@ -9380,10 +9392,10 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn int QLatin1String::compare(QStringView str, Qt::CaseSensitivity cs) const
- \fn int QLatin1String::compare(QLatin1String l1, Qt::CaseSensitivity cs) const
- \fn int QLatin1String::compare(QChar ch) const
- \fn int QLatin1String::compare(QChar ch, Qt::CaseSensitivity cs) const
+ \fn int QLatin1StringView::compare(QStringView str, Qt::CaseSensitivity cs) const
+ \fn int QLatin1StringView::compare(QLatin1StringView l1, Qt::CaseSensitivity cs) const
+ \fn int QLatin1StringView::compare(QChar ch) const
+ \fn int QLatin1StringView::compare(QChar ch, Qt::CaseSensitivity cs) const
\since 5.14
Returns an integer that compares to zero as this Latin-1 string compares to the
@@ -9397,13 +9409,13 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
/*!
- \fn bool QLatin1String::startsWith(QStringView str, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::startsWith(QStringView str, Qt::CaseSensitivity cs) const
\since 5.10
- \fn bool QLatin1String::startsWith(QLatin1String l1, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::startsWith(QLatin1StringView l1, Qt::CaseSensitivity cs) const
\since 5.10
- \fn bool QLatin1String::startsWith(QChar ch) const
+ \fn bool QLatin1StringView::startsWith(QChar ch) const
\since 5.10
- \fn bool QLatin1String::startsWith(QChar ch, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::startsWith(QChar ch, Qt::CaseSensitivity cs) const
\since 5.10
Returns \c true if this Latin-1 string starts with string-view \a str,
@@ -9417,13 +9429,13 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::endsWith(QStringView str, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::endsWith(QStringView str, Qt::CaseSensitivity cs) const
\since 5.10
- \fn bool QLatin1String::endsWith(QLatin1String l1, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::endsWith(QLatin1StringView l1, Qt::CaseSensitivity cs) const
\since 5.10
- \fn bool QLatin1String::endsWith(QChar ch) const
+ \fn bool QLatin1StringView::endsWith(QChar ch) const
\since 5.10
- \fn bool QLatin1String::endsWith(QChar ch, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::endsWith(QChar ch, Qt::CaseSensitivity cs) const
\since 5.10
Returns \c true if this Latin-1 string ends with string-view \a str,
@@ -9437,9 +9449,9 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn qsizetype QLatin1String::indexOf(QStringView str, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
- \fn qsizetype QLatin1String::indexOf(QLatin1String l1, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
- \fn qsizetype QLatin1String::indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \fn qsizetype QLatin1StringView::indexOf(QStringView str, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \fn qsizetype QLatin1StringView::indexOf(QLatin1StringView l1, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \fn qsizetype QLatin1StringView::indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\since 5.14
Returns the index position of the first occurrence of the string-view
@@ -9457,9 +9469,9 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::contains(QStringView str, Qt::CaseSensitivity cs) const
- \fn bool QLatin1String::contains(QLatin1String l1, Qt::CaseSensitivity cs) const
- \fn bool QLatin1String::contains(QChar c, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::contains(QStringView str, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::contains(QLatin1StringView l1, Qt::CaseSensitivity cs) const
+ \fn bool QLatin1StringView::contains(QChar c, Qt::CaseSensitivity cs) const
\since 5.14
Returns \c true if this Latin-1 string contains an occurrence of the
@@ -9474,9 +9486,9 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn qsizetype QLatin1String::lastIndexOf(QStringView str, qsizetype from, Qt::CaseSensitivity cs) const
- \fn qsizetype QLatin1String::lastIndexOf(QLatin1String l1, qsizetype from, Qt::CaseSensitivity cs) const
- \fn qsizetype QLatin1String::lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs) const
+ \fn qsizetype QLatin1StringView::lastIndexOf(QStringView str, qsizetype from, Qt::CaseSensitivity cs) const
+ \fn qsizetype QLatin1StringView::lastIndexOf(QLatin1StringView l1, qsizetype from, Qt::CaseSensitivity cs) const
+ \fn qsizetype QLatin1StringView::lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs) const
\since 5.14
Returns the index position of the last occurrence of the string-view \a str,
@@ -9503,8 +9515,8 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn qsizetype QLatin1String::lastIndexOf(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
- \fn qsizetype QLatin1String::lastIndexOf(QLatin1String l1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \fn qsizetype QLatin1StringView::lastIndexOf(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \fn qsizetype QLatin1StringView::lastIndexOf(QLatin1StringView l1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\since 6.2
\overload lastIndexOf()
@@ -9517,15 +9529,15 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn qsizetype QLatin1String::lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const
+ \fn qsizetype QLatin1StringView::lastIndexOf(QChar ch, Qt::CaseSensitivity cs) const
\since 6.3
\overload
*/
/*!
- \fn qsizetype QLatin1String::count(QStringView str, Qt::CaseSensitivity cs) const
- \fn qsizetype QLatin1String::count(QLatin1String l1, Qt::CaseSensitivity cs) const
- \fn qsizetype QLatin1String::count(QChar ch, Qt::CaseSensitivity cs) const
+ \fn qsizetype QLatin1StringView::count(QStringView str, Qt::CaseSensitivity cs) const
+ \fn qsizetype QLatin1StringView::count(QLatin1StringView l1, Qt::CaseSensitivity cs) const
+ \fn qsizetype QLatin1StringView::count(QChar ch, Qt::CaseSensitivity cs) const
\since 6.4
Returns the number of (potentially overlapping) occurrences of the
@@ -9539,7 +9551,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_iterator QLatin1String::begin() const
+ \fn QLatin1StringView::const_iterator QLatin1StringView::begin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the
@@ -9551,7 +9563,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_iterator QLatin1String::cbegin() const
+ \fn QLatin1StringView::const_iterator QLatin1StringView::cbegin() const
\since 5.10
Same as begin().
@@ -9562,7 +9574,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_iterator QLatin1String::constBegin() const
+ \fn QLatin1StringView::const_iterator QLatin1StringView::constBegin() const
\since 6.4
Same as begin().
@@ -9573,7 +9585,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_iterator QLatin1String::end() const
+ \fn QLatin1StringView::const_iterator QLatin1StringView::end() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style iterator} pointing just
@@ -9584,7 +9596,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa begin(), cend(), rend()
*/
-/*! \fn QLatin1String::const_iterator QLatin1String::cend() const
+/*! \fn QLatin1StringView::const_iterator QLatin1StringView::cend() const
\since 5.10
Same as end().
@@ -9594,7 +9606,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa cbegin(), end(), crend()
*/
-/*! \fn QLatin1String::const_iterator QLatin1String::constEnd() const
+/*! \fn QLatin1StringView::const_iterator QLatin1StringView::constEnd() const
\since 6.4
Same as end().
@@ -9605,7 +9617,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_reverse_iterator QLatin1String::rbegin() const
+ \fn QLatin1StringView::const_reverse_iterator QLatin1StringView::rbegin() const
\since 5.10
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing
@@ -9617,7 +9629,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_reverse_iterator QLatin1String::crbegin() const
+ \fn QLatin1StringView::const_reverse_iterator QLatin1StringView::crbegin() const
\since 5.10
Same as rbegin().
@@ -9628,7 +9640,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_reverse_iterator QLatin1String::rend() const
+ \fn QLatin1StringView::const_reverse_iterator QLatin1StringView::rend() const
\since 5.10
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing just
@@ -9640,7 +9652,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String::const_reverse_iterator QLatin1String::crend() const
+ \fn QLatin1StringView::const_reverse_iterator QLatin1StringView::crend() const
\since 5.10
Same as rend().
@@ -9651,7 +9663,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::mid(qsizetype start, qsizetype length) const
+ \fn QLatin1StringView QLatin1StringView::mid(qsizetype start, qsizetype length) const
\since 5.8
Returns the substring of length \a length starting at position
@@ -9670,7 +9682,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::left(qsizetype length) const
+ \fn QLatin1StringView QLatin1StringView::left(qsizetype length) const
\since 5.8
If you know that \a length cannot be out of bounds, use first() instead in
@@ -9686,7 +9698,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::right(qsizetype length) const
+ \fn QLatin1StringView QLatin1StringView::right(qsizetype length) const
\since 5.8
If you know that \a length cannot be out of bounds, use last() instead in
@@ -9702,7 +9714,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::first(qsizetype n) const
+ \fn QLatin1StringView QLatin1StringView::first(qsizetype n) const
\since 6.0
Returns a Latin-1 string that contains the first \a n characters
@@ -9714,7 +9726,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::last(qsizetype n) const
+ \fn QLatin1StringView QLatin1StringView::last(qsizetype n) const
\since 6.0
Returns a Latin-1 string that contains the last \a n characters
@@ -9726,7 +9738,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::sliced(qsizetype pos, qsizetype n) const
+ \fn QLatin1StringView QLatin1StringView::sliced(qsizetype pos, qsizetype n) const
\since 6.0
Returns a Latin-1 string that points to \a n characters of this
@@ -9739,7 +9751,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::sliced(qsizetype pos) const
+ \fn QLatin1StringView QLatin1StringView::sliced(qsizetype pos) const
\since 6.0
Returns a Latin-1 string starting at position \a pos in this
@@ -9751,7 +9763,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::chopped(qsizetype length) const
+ \fn QLatin1StringView QLatin1StringView::chopped(qsizetype length) const
\since 5.10
Returns the substring of length size() - \a length starting at the
@@ -9765,7 +9777,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn void QLatin1String::truncate(qsizetype length)
+ \fn void QLatin1StringView::truncate(qsizetype length)
\since 5.10
Truncates this string to length \a length.
@@ -9778,7 +9790,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn void QLatin1String::chop(qsizetype length)
+ \fn void QLatin1StringView::chop(qsizetype length)
\since 5.10
Truncates this string by \a length characters.
@@ -9791,7 +9803,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn QLatin1String QLatin1String::trimmed() const
+ \fn QLatin1StringView QLatin1StringView::trimmed() const
\since 5.10
Strips leading and trailing whitespace and returns the result.
@@ -9802,7 +9814,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator==(const char *other) const
+ \fn bool QLatin1StringView::operator==(const char *other) const
\since 4.3
Returns \c true if the string is equal to const char pointer \a other;
@@ -9820,7 +9832,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator==(const QByteArray &other) const
+ \fn bool QLatin1StringView::operator==(const QByteArray &other) const
\since 5.0
\overload
@@ -9834,7 +9846,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator!=(const char *other) const
+ \fn bool QLatin1StringView::operator!=(const char *other) const
\since 4.3
Returns \c true if this string is not equal to const char pointer \a other;
@@ -9852,7 +9864,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator!=(const QByteArray &other) const
+ \fn bool QLatin1StringView::operator!=(const QByteArray &other) const
\since 5.0
\overload operator!=()
@@ -9866,7 +9878,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator>(const char *other) const
+ \fn bool QLatin1StringView::operator>(const char *other) const
\since 4.3
Returns \c true if this string is lexically greater than const char pointer
@@ -9884,7 +9896,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator>(const QByteArray &other) const
+ \fn bool QLatin1StringView::operator>(const QByteArray &other) const
\since 5.0
\overload
@@ -9898,7 +9910,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator<(const char *other) const
+ \fn bool QLatin1StringView::operator<(const char *other) const
\since 4.3
Returns \c true if this string is lexically less than const char pointer
@@ -9916,7 +9928,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator<(const QByteArray &other) const
+ \fn bool QLatin1StringView::operator<(const QByteArray &other) const
\since 5.0
\overload
@@ -9930,7 +9942,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator>=(const char *other) const
+ \fn bool QLatin1StringView::operator>=(const char *other) const
\since 4.3
Returns \c true if this string is lexically greater than or equal to
@@ -9948,7 +9960,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator>=(const QByteArray &other) const
+ \fn bool QLatin1StringView::operator>=(const QByteArray &other) const
\since 5.0
\overload
@@ -9962,7 +9974,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator<=(const char *other) const
+ \fn bool QLatin1StringView::operator<=(const char *other) const
\since 4.3
Returns \c true if this string is lexically less than or equal to
@@ -9980,7 +9992,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn bool QLatin1String::operator<=(const QByteArray &other) const
+ \fn bool QLatin1StringView::operator<=(const QByteArray &other) const
\since 5.0
\overload
@@ -9993,204 +10005,204 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
go through QObject::tr(), for example.
*/
-/*! \fn bool QLatin1String::operator==(QLatin1String s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator==(QLatin1StringView s1, QLatin1StringView s2)
Returns \c true if string \a s1 is lexically equal to string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator!=(QLatin1String s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator!=(QLatin1StringView s1, QLatin1StringView s2)
Returns \c true if string \a s1 is lexically not equal to string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<(QLatin1String s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator<(QLatin1StringView s1, QLatin1StringView s2)
Returns \c true if string \a s1 is lexically less than string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<=(QLatin1String s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator<=(QLatin1StringView s1, QLatin1StringView s2)
Returns \c true if string \a s1 is lexically less than or equal to
string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>(QLatin1String s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator>(QLatin1StringView s1, QLatin1StringView s2)
Returns \c true if string \a s1 is lexically greater than string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>=(QLatin1String s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator>=(QLatin1StringView s1, QLatin1StringView s2)
Returns \c true if string \a s1 is lexically greater than or equal
to string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator==(QChar ch, QLatin1String s)
+/*! \fn bool QLatin1StringView::operator==(QChar ch, QLatin1StringView s)
Returns \c true if char \a ch is lexically equal to string \a s;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<(QChar ch, QLatin1String s)
+/*! \fn bool QLatin1StringView::operator<(QChar ch, QLatin1StringView s)
Returns \c true if char \a ch is lexically less than string \a s;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>(QChar ch, QLatin1String s)
+/*! \fn bool QLatin1StringView::operator>(QChar ch, QLatin1StringView s)
Returns \c true if char \a ch is lexically greater than string \a s;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator!=(QChar ch, QLatin1String s)
+/*! \fn bool QLatin1StringView::operator!=(QChar ch, QLatin1StringView s)
Returns \c true if char \a ch is lexically not equal to string \a s;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<=(QChar ch, QLatin1String s)
+/*! \fn bool QLatin1StringView::operator<=(QChar ch, QLatin1StringView s)
Returns \c true if char \a ch is lexically less than or equal to
string \a s; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>=(QChar ch, QLatin1String s)
+/*! \fn bool QLatin1StringView::operator>=(QChar ch, QLatin1StringView s)
Returns \c true if char \a ch is lexically greater than or equal to
string \a s; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator==(QLatin1String s, QChar ch)
+/*! \fn bool QLatin1StringView::operator==(QLatin1StringView s, QChar ch)
Returns \c true if string \a s is lexically equal to char \a ch;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<(QLatin1String s, QChar ch)
+/*! \fn bool QLatin1StringView::operator<(QLatin1StringView s, QChar ch)
Returns \c true if string \a s is lexically less than char \a ch;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>(QLatin1String s, QChar ch)
+/*! \fn bool QLatin1StringView::operator>(QLatin1StringView s, QChar ch)
Returns \c true if string \a s is lexically greater than char \a ch;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator!=(QLatin1String s, QChar ch)
+/*! \fn bool QLatin1StringView::operator!=(QLatin1StringView s, QChar ch)
Returns \c true if string \a s is lexically not equal to char \a ch;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<=(QLatin1String s, QChar ch)
+/*! \fn bool QLatin1StringView::operator<=(QLatin1StringView s, QChar ch)
Returns \c true if string \a s is lexically less than or equal to
char \a ch; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>=(QLatin1String s, QChar ch)
+/*! \fn bool QLatin1StringView::operator>=(QLatin1StringView s, QChar ch)
Returns \c true if string \a s is lexically greater than or equal to
char \a ch; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator==(QStringView s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator==(QStringView s1, QLatin1StringView s2)
Returns \c true if string view \a s1 is lexically equal to string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<(QStringView s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator<(QStringView s1, QLatin1StringView s2)
Returns \c true if string view \a s1 is lexically less than string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>(QStringView s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator>(QStringView s1, QLatin1StringView s2)
Returns \c true if string view \a s1 is lexically greater than string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator!=(QStringView s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator!=(QStringView s1, QLatin1StringView s2)
Returns \c true if string view \a s1 is lexically not equal to string \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<=(QStringView s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator<=(QStringView s1, QLatin1StringView s2)
Returns \c true if string view \a s1 is lexically less than or equal to
string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>=(QStringView s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator>=(QStringView s1, QLatin1StringView s2)
Returns \c true if string view \a s1 is lexically greater than or equal to
string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator==(QLatin1String s1, QStringView s2)
+/*! \fn bool QLatin1StringView::operator==(QLatin1StringView s1, QStringView s2)
Returns \c true if string \a s1 is lexically equal to string view \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<(QLatin1String s1, QStringView s2)
+/*! \fn bool QLatin1StringView::operator<(QLatin1StringView s1, QStringView s2)
Returns \c true if string \a s1 is lexically less than string view \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>(QLatin1String s1, QStringView s2)
+/*! \fn bool QLatin1StringView::operator>(QLatin1StringView s1, QStringView s2)
Returns \c true if string \a s1 is lexically greater than string view \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator!=(QLatin1String s1, QStringView s2)
+/*! \fn bool QLatin1StringView::operator!=(QLatin1StringView s1, QStringView s2)
Returns \c true if string \a s1 is lexically not equal to string view \a s2;
otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<=(QLatin1String s1, QStringView s2)
+/*! \fn bool QLatin1StringView::operator<=(QLatin1StringView s1, QStringView s2)
Returns \c true if string \a s1 is lexically less than or equal to
string view \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>=(QLatin1String s1, QStringView s2)
+/*! \fn bool QLatin1StringView::operator>=(QLatin1StringView s1, QStringView s2)
Returns \c true if string \a s1 is lexically greater than or equal to
string view \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator==(const char *s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator==(const char *s1, QLatin1StringView s2)
Returns \c true if const char pointer \a s1 is lexically equal to
string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<(const char *s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator<(const char *s1, QLatin1StringView s2)
Returns \c true if const char pointer \a s1 is lexically less than
string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>(const char *s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator>(const char *s1, QLatin1StringView s2)
Returns \c true if const char pointer \a s1 is lexically greater than
string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator!=(const char *s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator!=(const char *s1, QLatin1StringView s2)
Returns \c true if const char pointer \a s1 is lexically not equal to
string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator<=(const char *s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator<=(const char *s1, QLatin1StringView s2)
Returns \c true if const char pointer \a s1 is lexically less than or
equal to string \a s2; otherwise returns \c false.
*/
-/*! \fn bool QLatin1String::operator>=(const char *s1, QLatin1String s2)
+/*! \fn bool QLatin1StringView::operator>=(const char *s1, QLatin1StringView s2)
Returns \c true if const char pointer \a s1 is lexically greater than or
equal to string \a s2; otherwise returns \c false.
*/
/*!
- \fn qlonglong QLatin1String::toLongLong(bool *ok, int base) const
- \fn qulonglong QLatin1String::toULongLong(bool *ok, int base) const
- \fn int QLatin1String::toInt(bool *ok, int base) const
- \fn uint QLatin1String::toUInt(bool *ok, int base) const
- \fn long QLatin1String::toLong(bool *ok, int base) const
- \fn ulong QLatin1String::toULong(bool *ok, int base) const
- \fn short QLatin1String::toShort(bool *ok, int base) const
- \fn ushort QLatin1String::toUShort(bool *ok, int base) const
+ \fn qlonglong QLatin1StringView::toLongLong(bool *ok, int base) const
+ \fn qulonglong QLatin1StringView::toULongLong(bool *ok, int base) const
+ \fn int QLatin1StringView::toInt(bool *ok, int base) const
+ \fn uint QLatin1StringView::toUInt(bool *ok, int base) const
+ \fn long QLatin1StringView::toLong(bool *ok, int base) const
+ \fn ulong QLatin1StringView::toULong(bool *ok, int base) const
+ \fn short QLatin1StringView::toShort(bool *ok, int base) const
+ \fn ushort QLatin1StringView::toUShort(bool *ok, int base) const
\since 6.4
- Returns this QLatin1String converted to a corresponding numeric value using
+ Returns this QLatin1StringView converted to a corresponding numeric value using
base \a base, which is ten by default. Bases 0 and 2 through 36 are supported,
using letters for digits beyond 9; A is ten, B is eleven and so on.
@@ -10214,11 +10226,11 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
*/
/*!
- \fn double QLatin1String::toDouble(bool *ok) const
- \fn float QLatin1String::toFloat(bool *ok) const
+ \fn double QLatin1StringView::toDouble(bool *ok) const
+ \fn float QLatin1StringView::toFloat(bool *ok) const
\since 6.4
- Returns this QLatin1String converted to a corresponding floating-point value.
+ Returns this QLatin1StringView converted to a corresponding floating-point value.
Returns an infinity if the conversion overflows or 0.0 if the
conversion fails for other reasons (e.g. underflow).
@@ -10226,7 +10238,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
If \a ok is not \nullptr, failure is reported by setting *\a{ok}
to \c false, and success by setting *\a{ok} to \c true.
- \warning The QLatin1String content may only contain valid numerical
+ \warning The QLatin1StringView content may only contain valid numerical
characters which includes the plus/minus sign, the character e used in
scientific notation, and the decimal point. Including the unit or additional
characters leads to a conversion error.
@@ -10316,7 +10328,7 @@ QDataStream &operator>>(QDataStream &in, QString &str)
qbswap<sizeof(*data)>(data, len, data);
}
} else {
- str = QString(QLatin1String(""));
+ str = QString(QLatin1StringView(""));
}
}
return in;
@@ -10428,7 +10440,7 @@ qsizetype QtPrivate::count(QStringView haystack, QChar ch, Qt::CaseSensitivity c
return num;
}
-qsizetype QtPrivate::count(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs)
+qsizetype QtPrivate::count(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs)
{
qsizetype num = 0;
qsizetype i = -1;
@@ -10446,7 +10458,7 @@ qsizetype QtPrivate::count(QLatin1String haystack, QLatin1String needle, Qt::Cas
return num;
}
-qsizetype QtPrivate::count(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs)
+qsizetype QtPrivate::count(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs)
{
if (haystack.size() < needle.size())
return 0;
@@ -10473,7 +10485,7 @@ qsizetype QtPrivate::count(QLatin1String haystack, QStringView needle, Qt::CaseS
return num;
}
-qsizetype QtPrivate::count(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs)
+qsizetype QtPrivate::count(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs)
{
if (haystack.size() < needle.size())
return -1;
@@ -10484,7 +10496,7 @@ qsizetype QtPrivate::count(QStringView haystack, QLatin1String needle, Qt::CaseS
return QtPrivate::count(haystack, QStringView(s.data(), s.size()), cs);
}
-qsizetype QtPrivate::count(QLatin1String haystack, QChar needle, Qt::CaseSensitivity cs) noexcept
+qsizetype QtPrivate::count(QLatin1StringView haystack, QChar needle, Qt::CaseSensitivity cs) noexcept
{
// non-L1 needles cannot possibly match in L1-only haystacks
if (needle.unicode() > 0xff)
@@ -10511,11 +10523,11 @@ qsizetype QtPrivate::count(QLatin1String haystack, QChar needle, Qt::CaseSensiti
/*!
\fn bool QtPrivate::startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs)
\since 5.10
- \fn bool QtPrivate::startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs)
+ \fn bool QtPrivate::startsWith(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs)
\since 5.10
- \fn bool QtPrivate::startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs)
+ \fn bool QtPrivate::startsWith(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs)
\since 5.10
- \fn bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs)
+ \fn bool QtPrivate::startsWith(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs)
\since 5.10
\internal
\relates QStringView
@@ -10526,7 +10538,7 @@ qsizetype QtPrivate::count(QLatin1String haystack, QChar needle, Qt::CaseSensiti
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa QtPrivate::endsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith()
+ \sa QtPrivate::endsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1StringView::endsWith()
*/
bool QtPrivate::startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept
@@ -10534,17 +10546,17 @@ bool QtPrivate::startsWith(QStringView haystack, QStringView needle, Qt::CaseSen
return qt_starts_with_impl(haystack, needle, cs);
}
-bool QtPrivate::startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+bool QtPrivate::startsWith(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
return qt_starts_with_impl(haystack, needle, cs);
}
-bool QtPrivate::startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept
+bool QtPrivate::startsWith(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept
{
return qt_starts_with_impl(haystack, needle, cs);
}
-bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+bool QtPrivate::startsWith(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
return qt_starts_with_impl(haystack, needle, cs);
}
@@ -10552,11 +10564,11 @@ bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::Cas
/*!
\fn bool QtPrivate::endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs)
\since 5.10
- \fn bool QtPrivate::endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs)
+ \fn bool QtPrivate::endsWith(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs)
\since 5.10
- \fn bool QtPrivate::endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs)
+ \fn bool QtPrivate::endsWith(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs)
\since 5.10
- \fn bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs)
+ \fn bool QtPrivate::endsWith(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs)
\since 5.10
\internal
\relates QStringView
@@ -10567,7 +10579,7 @@ bool QtPrivate::startsWith(QLatin1String haystack, QLatin1String needle, Qt::Cas
If \a cs is Qt::CaseSensitive (the default), the search is case-sensitive;
otherwise the search is case-insensitive.
- \sa QtPrivate::startsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1String::endsWith()
+ \sa QtPrivate::startsWith(), QString::endsWith(), QStringView::endsWith(), QLatin1StringView::endsWith()
*/
bool QtPrivate::endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept
@@ -10575,17 +10587,17 @@ bool QtPrivate::endsWith(QStringView haystack, QStringView needle, Qt::CaseSensi
return qt_ends_with_impl(haystack, needle, cs);
}
-bool QtPrivate::endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+bool QtPrivate::endsWith(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
return qt_ends_with_impl(haystack, needle, cs);
}
-bool QtPrivate::endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept
+bool QtPrivate::endsWith(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs) noexcept
{
return qt_ends_with_impl(haystack, needle, cs);
}
-bool QtPrivate::endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+bool QtPrivate::endsWith(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
return qt_ends_with_impl(haystack, needle, cs);
}
@@ -10665,7 +10677,7 @@ qsizetype QtPrivate::findString(QStringView haystack0, qsizetype from, QStringVi
return -1;
}
-qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
if (haystack.size() < needle.size())
return -1;
@@ -10675,7 +10687,7 @@ qsizetype QtPrivate::findString(QStringView haystack, qsizetype from, QLatin1Str
return QtPrivate::findString(haystack, from, QStringView(reinterpret_cast<const QChar*>(s.constData()), s.size()), cs);
}
-qsizetype QtPrivate::findString(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs) noexcept
+qsizetype QtPrivate::findString(QLatin1StringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs) noexcept
{
if (haystack.size() < needle.size())
return -1;
@@ -10685,15 +10697,15 @@ qsizetype QtPrivate::findString(QLatin1String haystack, qsizetype from, QStringV
if (needle.size() == 1) {
const char n = needle.front().toLatin1();
- return QtPrivate::findString(haystack, from, QLatin1String(&n, 1), cs);
+ return QtPrivate::findString(haystack, from, QLatin1StringView(&n, 1), cs);
}
QVarLengthArray<char> s(needle.size());
qt_to_latin1_unchecked(reinterpret_cast<uchar *>(s.data()), needle.utf16(), needle.size());
- return QtPrivate::findString(haystack, from, QLatin1String(s.data(), s.size()), cs);
+ return QtPrivate::findString(haystack, from, QLatin1StringView(s.data(), s.size()), cs);
}
-qsizetype QtPrivate::findString(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+qsizetype QtPrivate::findString(QLatin1StringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
if (from < 0)
from += haystack.size();
@@ -10743,7 +10755,7 @@ qsizetype QtPrivate::findString(QLatin1String haystack, qsizetype from, QLatin1S
for (auto it = std::find_if(begin + from, end, ciMatch); it < end;
it = std::find_if(it + 1, end, ciMatch)) {
// In this comparison we skip the first character because we know it's a match
- if (!nlen1 || QLatin1String(it + 1, nlen1).compare(needle.sliced(1), cs) == 0)
+ if (!nlen1 || QLatin1StringView(it + 1, nlen1).compare(needle.sliced(1), cs) == 0)
return std::distance(begin, it);
}
return -1;
@@ -10777,17 +10789,17 @@ qsizetype QtPrivate::lastIndexOf(QStringView haystack, qsizetype from, QStringVi
return qLastIndexOf(haystack, from, needle, cs);
}
-qsizetype QtPrivate::lastIndexOf(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+qsizetype QtPrivate::lastIndexOf(QStringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
return qLastIndexOf(haystack, from, needle, cs);
}
-qsizetype QtPrivate::lastIndexOf(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs) noexcept
+qsizetype QtPrivate::lastIndexOf(QLatin1StringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs) noexcept
{
return qLastIndexOf(haystack, from, needle, cs);
}
-qsizetype QtPrivate::lastIndexOf(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs) noexcept
+qsizetype QtPrivate::lastIndexOf(QLatin1StringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs) noexcept
{
return qLastIndexOf(haystack, from, needle, cs);
}
@@ -10931,10 +10943,10 @@ QString QString::toHtmlEscaped() const
significantly speed up creation of QString instances from data known at
compile time.
- \note QLatin1String can still be more efficient than QStringLiteral
+ \note QLatin1StringView can still be more efficient than QStringLiteral
when the string is passed to a function that has an overload taking
- QLatin1String and this overload avoids conversion to QString. For
- instance, QString::operator==() can compare to a QLatin1String
+ QLatin1StringView and this overload avoids conversion to QString. For
+ instance, QString::operator==() can compare to a QLatin1StringView
directly:
\snippet code/src_corelib_text_qstring.cpp 11
@@ -10972,13 +10984,13 @@ QString QString::toHtmlEscaped() const
/*!
\fn Qt::Literals::StringLiterals::operator""_L1(const char *str, size_t size)
- \relates QLatin1String
+ \relates QLatin1StringView
\since 6.4
- Literal operator that creates a QLatin1String out of the first \a size
+ Literal operator that creates a QLatin1StringView out of the first \a size
characters in the char string literal \a str.
- The following code creates a QLatin1String:
+ The following code creates a QLatin1StringView:
\code
using namespace Qt::Literals::StringLiterals;
@@ -10991,7 +11003,7 @@ QString QString::toHtmlEscaped() const
/*!
\internal
*/
-void QAbstractConcatenable::appendLatin1To(QLatin1String in, QChar *out) noexcept
+void QAbstractConcatenable::appendLatin1To(QLatin1StringView in, QChar *out) noexcept
{
qt_from_latin1(reinterpret_cast<char16_t *>(out), in.data(), size_t(in.size()));
}
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index 64ed40eb2a..497d4b7f4e 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -87,7 +87,7 @@ namespace QtPrivate {
template <bool...B> class BoolList;
}
-#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED)
+#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED) || defined(Q_CLANG_QDOC)
# define Q_L1S_VIEW_IS_PRIMARY
class QLatin1StringView
#else
@@ -149,7 +149,7 @@ public:
[[nodiscard]] int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::compareStrings(*this, other, cs); }
- [[nodiscard]] int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ [[nodiscard]] int compare(QLatin1StringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::compareStrings(*this, other, cs); }
[[nodiscard]] constexpr int compare(QChar c) const noexcept
{ return isEmpty() ? -1 : front() == c ? int(size() > 1) : uchar(m_data[0]) - c.unicode(); }
@@ -158,7 +158,7 @@ public:
[[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
- [[nodiscard]] bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ [[nodiscard]] bool startsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
[[nodiscard]] constexpr bool startsWith(QChar c) const noexcept
{ return !isEmpty() && front() == c; }
@@ -167,7 +167,7 @@ public:
[[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
- [[nodiscard]] bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ [[nodiscard]] bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
[[nodiscard]] constexpr bool endsWith(QChar c) const noexcept
{ return !isEmpty() && back() == c; }
@@ -176,14 +176,14 @@ public:
[[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, s, cs); }
- [[nodiscard]] qsizetype indexOf(QLatin1String s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ [[nodiscard]] qsizetype indexOf(QLatin1StringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, s, cs); }
[[nodiscard]] qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, QStringView(&c, 1), cs); }
[[nodiscard]] bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != -1; }
- [[nodiscard]] bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ [[nodiscard]] bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != -1; }
[[nodiscard]] inline bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(QStringView(&c, 1), 0, cs) != -1; }
@@ -192,9 +192,9 @@ public:
{ return lastIndexOf(s, size(), cs); }
[[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::lastIndexOf(*this, from, s, cs); }
- [[nodiscard]] qsizetype lastIndexOf(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return lastIndexOf(s, size(), cs); }
- [[nodiscard]] qsizetype lastIndexOf(QLatin1String s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
+ [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::lastIndexOf(*this, from, s, cs); }
[[nodiscard]] qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return lastIndexOf(c, -1, cs); }
@@ -203,7 +203,7 @@ public:
[[nodiscard]] qsizetype count(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
{ return QtPrivate::count(*this, str, cs); }
- [[nodiscard]] qsizetype count(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ [[nodiscard]] qsizetype count(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
{ return QtPrivate::count(*this, str, cs); }
[[nodiscard]] qsizetype count(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::count(*this, ch, cs); }
@@ -260,97 +260,99 @@ public:
const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
- [[nodiscard]] constexpr QLatin1String mid(qsizetype pos, qsizetype n = -1) const
+ [[nodiscard]] constexpr QLatin1StringView mid(qsizetype pos, qsizetype n = -1) const
{
using namespace QtPrivate;
auto result = QContainerImplHelper::mid(size(), &pos, &n);
- return result == QContainerImplHelper::Null ? QLatin1String() : QLatin1String(m_data + pos, n);
+ return result == QContainerImplHelper::Null ? QLatin1StringView()
+ : QLatin1StringView(m_data + pos, n);
}
- [[nodiscard]] constexpr QLatin1String left(qsizetype n) const
+ [[nodiscard]] constexpr QLatin1StringView left(qsizetype n) const
{
if (size_t(n) >= size_t(size()))
n = size();
- return QLatin1String(m_data, n);
+ return QLatin1StringView(m_data, n);
}
- [[nodiscard]] constexpr QLatin1String right(qsizetype n) const
+ [[nodiscard]] constexpr QLatin1StringView right(qsizetype n) const
{
if (size_t(n) >= size_t(size()))
n = size();
- return QLatin1String(m_data + m_size - n, n);
+ return QLatin1StringView(m_data + m_size - n, n);
}
- [[nodiscard]] constexpr QLatin1String sliced(qsizetype pos) const
- { verify(pos); return QLatin1String(m_data + pos, m_size - pos); }
- [[nodiscard]] constexpr QLatin1String sliced(qsizetype pos, qsizetype n) const
- { verify(pos, n); return QLatin1String(m_data + pos, n); }
- [[nodiscard]] constexpr QLatin1String first(qsizetype n) const
- { verify(n); return QLatin1String(m_data, n); }
- [[nodiscard]] constexpr QLatin1String last(qsizetype n) const
- { verify(n); return QLatin1String(m_data + size() - n, n); }
- [[nodiscard]] constexpr QLatin1String chopped(qsizetype n) const
- { verify(n); return QLatin1String(m_data, size() - n); }
+ [[nodiscard]] constexpr QLatin1StringView sliced(qsizetype pos) const
+ { verify(pos); return QLatin1StringView(m_data + pos, m_size - pos); }
+ [[nodiscard]] constexpr QLatin1StringView sliced(qsizetype pos, qsizetype n) const
+ { verify(pos, n); return QLatin1StringView(m_data + pos, n); }
+ [[nodiscard]] constexpr QLatin1StringView first(qsizetype n) const
+ { verify(n); return QLatin1StringView(m_data, n); }
+ [[nodiscard]] constexpr QLatin1StringView last(qsizetype n) const
+ { verify(n); return QLatin1StringView(m_data + size() - n, n); }
+ [[nodiscard]] constexpr QLatin1StringView chopped(qsizetype n) const
+ { verify(n); return QLatin1StringView(m_data, size() - n); }
constexpr void chop(qsizetype n)
{ verify(n); m_size -= n; }
constexpr void truncate(qsizetype n)
{ verify(n); m_size = n; }
- [[nodiscard]] QLatin1String trimmed() const noexcept { return QtPrivate::trimmed(*this); }
+ [[nodiscard]] QLatin1StringView trimmed() const noexcept { return QtPrivate::trimmed(*this); }
template <typename Needle, typename...Flags>
[[nodiscard]] inline constexpr auto tokenize(Needle &&needle, Flags...flags) const
- noexcept(noexcept(qTokenize(std::declval<const QLatin1String &>(), std::forward<Needle>(needle), flags...)))
+ noexcept(noexcept(qTokenize(std::declval<const QLatin1StringView &>(),
+ std::forward<Needle>(needle), flags...)))
-> decltype(qTokenize(*this, std::forward<Needle>(needle), flags...))
{ return qTokenize(*this, std::forward<Needle>(needle), flags...); }
- friend inline bool operator==(QLatin1String s1, QLatin1String s2) noexcept
+ friend inline bool operator==(QLatin1StringView s1, QLatin1StringView s2) noexcept
{ return s1.size() == s2.size() && (!s1.size() || !memcmp(s1.latin1(), s2.latin1(), s1.size())); }
- friend inline bool operator!=(QLatin1String s1, QLatin1String s2) noexcept
+ friend inline bool operator!=(QLatin1StringView s1, QLatin1StringView s2) noexcept
{ return !(s1 == s2); }
- friend inline bool operator<(QLatin1String s1, QLatin1String s2) noexcept
+ friend inline bool operator<(QLatin1StringView s1, QLatin1StringView s2) noexcept
{
const qsizetype len = qMin(s1.size(), s2.size());
const int r = len ? memcmp(s1.latin1(), s2.latin1(), len) : 0;
return r < 0 || (r == 0 && s1.size() < s2.size());
}
- friend inline bool operator>(QLatin1String s1, QLatin1String s2) noexcept
+ friend inline bool operator>(QLatin1StringView s1, QLatin1StringView s2) noexcept
{ return s2 < s1; }
- friend inline bool operator<=(QLatin1String s1, QLatin1String s2) noexcept
+ friend inline bool operator<=(QLatin1StringView s1, QLatin1StringView s2) noexcept
{ return !(s1 > s2); }
- friend inline bool operator>=(QLatin1String s1, QLatin1String s2) noexcept
+ friend inline bool operator>=(QLatin1StringView s1, QLatin1StringView s2) noexcept
{ return !(s1 < s2); }
- // QChar <> QLatin1String
- friend inline bool operator==(QChar lhs, QLatin1String rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); }
- friend inline bool operator< (QChar lhs, QLatin1String rhs) noexcept { return compare_helper(&lhs, 1, rhs) < 0; }
- friend inline bool operator> (QChar lhs, QLatin1String rhs) noexcept { return compare_helper(&lhs, 1, rhs) > 0; }
- friend inline bool operator!=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs == rhs); }
- friend inline bool operator<=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs > rhs); }
- friend inline bool operator>=(QChar lhs, QLatin1String rhs) noexcept { return !(lhs < rhs); }
-
- friend inline bool operator==(QLatin1String lhs, QChar rhs) noexcept { return rhs == lhs; }
- friend inline bool operator!=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs == lhs); }
- friend inline bool operator< (QLatin1String lhs, QChar rhs) noexcept { return rhs > lhs; }
- friend inline bool operator> (QLatin1String lhs, QChar rhs) noexcept { return rhs < lhs; }
- friend inline bool operator<=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs < lhs); }
- friend inline bool operator>=(QLatin1String lhs, QChar rhs) noexcept { return !(rhs > lhs); }
-
- // QStringView <> QLatin1String
- friend inline bool operator==(QStringView lhs, QLatin1String rhs) noexcept
+ // QChar <> QLatin1StringView
+ friend inline bool operator==(QChar lhs, QLatin1StringView rhs) noexcept { return rhs.size() == 1 && lhs == rhs.front(); }
+ friend inline bool operator< (QChar lhs, QLatin1StringView rhs) noexcept { return compare_helper(&lhs, 1, rhs) < 0; }
+ friend inline bool operator> (QChar lhs, QLatin1StringView rhs) noexcept { return compare_helper(&lhs, 1, rhs) > 0; }
+ friend inline bool operator!=(QChar lhs, QLatin1StringView rhs) noexcept { return !(lhs == rhs); }
+ friend inline bool operator<=(QChar lhs, QLatin1StringView rhs) noexcept { return !(lhs > rhs); }
+ friend inline bool operator>=(QChar lhs, QLatin1StringView rhs) noexcept { return !(lhs < rhs); }
+
+ friend inline bool operator==(QLatin1StringView lhs, QChar rhs) noexcept { return rhs == lhs; }
+ friend inline bool operator!=(QLatin1StringView lhs, QChar rhs) noexcept { return !(rhs == lhs); }
+ friend inline bool operator< (QLatin1StringView lhs, QChar rhs) noexcept { return rhs > lhs; }
+ friend inline bool operator> (QLatin1StringView lhs, QChar rhs) noexcept { return rhs < lhs; }
+ friend inline bool operator<=(QLatin1StringView lhs, QChar rhs) noexcept { return !(rhs < lhs); }
+ friend inline bool operator>=(QLatin1StringView lhs, QChar rhs) noexcept { return !(rhs > lhs); }
+
+ // QStringView <> QLatin1StringView
+ friend inline bool operator==(QStringView lhs, QLatin1StringView rhs) noexcept
{ return lhs.size() == rhs.size() && QtPrivate::equalStrings(lhs, rhs); }
- friend inline bool operator!=(QStringView lhs, QLatin1String rhs) noexcept { return !(lhs == rhs); }
- friend inline bool operator< (QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; }
- friend inline bool operator<=(QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; }
- friend inline bool operator> (QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; }
- friend inline bool operator>=(QStringView lhs, QLatin1String rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; }
+ friend inline bool operator!=(QStringView lhs, QLatin1StringView rhs) noexcept { return !(lhs == rhs); }
+ friend inline bool operator< (QStringView lhs, QLatin1StringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; }
+ friend inline bool operator<=(QStringView lhs, QLatin1StringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; }
+ friend inline bool operator> (QStringView lhs, QLatin1StringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; }
+ friend inline bool operator>=(QStringView lhs, QLatin1StringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; }
- friend inline bool operator==(QLatin1String lhs, QStringView rhs) noexcept
+ friend inline bool operator==(QLatin1StringView lhs, QStringView rhs) noexcept
{ return lhs.size() == rhs.size() && QtPrivate::equalStrings(lhs, rhs); }
- friend inline bool operator!=(QLatin1String lhs, QStringView rhs) noexcept { return !(lhs == rhs); }
- friend inline bool operator< (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; }
- friend inline bool operator<=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; }
- friend inline bool operator> (QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; }
- friend inline bool operator>=(QLatin1String lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; }
+ friend inline bool operator!=(QLatin1StringView lhs, QStringView rhs) noexcept { return !(lhs == rhs); }
+ friend inline bool operator< (QLatin1StringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) < 0; }
+ friend inline bool operator<=(QLatin1StringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) <= 0; }
+ friend inline bool operator> (QLatin1StringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) > 0; }
+ friend inline bool operator>=(QLatin1StringView lhs, QStringView rhs) noexcept { return QtPrivate::compareStrings(lhs, rhs) >= 0; }
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
@@ -368,17 +370,17 @@ public:
QT_ASCII_CAST_WARN inline bool operator<=(const QByteArray &s) const;
QT_ASCII_CAST_WARN inline bool operator>=(const QByteArray &s) const;
- QT_ASCII_CAST_WARN friend bool operator==(const char *s1, QLatin1String s2) { return compare_helper(s2, s1) == 0; }
- QT_ASCII_CAST_WARN friend bool operator!=(const char *s1, QLatin1String s2) { return compare_helper(s2, s1) != 0; }
- QT_ASCII_CAST_WARN friend bool operator< (const char *s1, QLatin1String s2) { return compare_helper(s2, s1) > 0; }
- QT_ASCII_CAST_WARN friend bool operator> (const char *s1, QLatin1String s2) { return compare_helper(s2, s1) < 0; }
- QT_ASCII_CAST_WARN friend bool operator<=(const char *s1, QLatin1String s2) { return compare_helper(s2, s1) >= 0; }
- QT_ASCII_CAST_WARN friend bool operator>=(const char *s1, QLatin1String s2) { return compare_helper(s2, s1) <= 0; }
+ QT_ASCII_CAST_WARN friend bool operator==(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) == 0; }
+ QT_ASCII_CAST_WARN friend bool operator!=(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) != 0; }
+ QT_ASCII_CAST_WARN friend bool operator< (const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) > 0; }
+ QT_ASCII_CAST_WARN friend bool operator> (const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) < 0; }
+ QT_ASCII_CAST_WARN friend bool operator<=(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) >= 0; }
+ QT_ASCII_CAST_WARN friend bool operator>=(const char *s1, QLatin1StringView s2) { return compare_helper(s2, s1) <= 0; }
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
private:
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
- static inline int compare_helper(const QLatin1String &s1, const char *s2);
+ static inline int compare_helper(const QLatin1StringView &s1, const char *s2);
#endif
Q_ALWAYS_INLINE constexpr void verify(qsizetype pos, qsizetype n = 0) const
{
@@ -388,7 +390,7 @@ private:
Q_ASSERT(n <= size() - pos);
}
Q_CORE_EXPORT static int compare_helper(const QChar *data1, qsizetype length1,
- QLatin1String s2,
+ QLatin1StringView s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
qsizetype m_size;
const char *m_data;
@@ -402,43 +404,43 @@ Q_DECLARE_TYPEINFO(QLatin1String, Q_RELOCATABLE_TYPE);
// Qt 4.x compatibility
//
-// QLatin1String inline implementations
+// QLatin1StringView inline implementations
//
-constexpr bool QtPrivate::isLatin1(QLatin1String) noexcept
+constexpr bool QtPrivate::isLatin1(QLatin1StringView) noexcept
{ return true; }
//
-// QStringView members that require QLatin1String:
+// QStringView members that require QLatin1StringView:
//
-int QStringView::compare(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
+int QStringView::compare(QLatin1StringView s, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::compareStrings(*this, s, cs); }
-bool QStringView::startsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
+bool QStringView::startsWith(QLatin1StringView s, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
-bool QStringView::endsWith(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
+bool QStringView::endsWith(QLatin1StringView s, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
-qsizetype QStringView::indexOf(QLatin1String s, qsizetype from, Qt::CaseSensitivity cs) const noexcept
+qsizetype QStringView::indexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::findString(*this, from, s, cs); }
-bool QStringView::contains(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
+bool QStringView::contains(QLatin1StringView s, Qt::CaseSensitivity cs) const noexcept
{ return indexOf(s, 0, cs) != qsizetype(-1); }
-qsizetype QStringView::lastIndexOf(QLatin1String s, Qt::CaseSensitivity cs) const noexcept
+qsizetype QStringView::lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::lastIndexOf(*this, size(), s, cs); }
-qsizetype QStringView::lastIndexOf(QLatin1String s, qsizetype from, Qt::CaseSensitivity cs) const noexcept
+qsizetype QStringView::lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs) const noexcept
{ return QtPrivate::lastIndexOf(*this, from, s, cs); }
-qsizetype QStringView::count(QLatin1String s, Qt::CaseSensitivity cs) const
+qsizetype QStringView::count(QLatin1StringView s, Qt::CaseSensitivity cs) const
{ return QtPrivate::count(*this, s, cs); }
//
-// QAnyStringView members that require QLatin1String
+// QAnyStringView members that require QLatin1StringView
//
-constexpr QAnyStringView::QAnyStringView(QLatin1String str) noexcept
+constexpr QAnyStringView::QAnyStringView(QLatin1StringView str) noexcept
: m_data{str.data()}, m_size{size_t(str.size()) | Tag::Latin1} {}
-constexpr QLatin1String QAnyStringView::asLatin1StringView() const
+constexpr QLatin1StringView QAnyStringView::asLatin1StringView() const
{
Q_ASSERT(isLatin1());
- return QLatin1String{m_data_utf8, int(size())};
+ return QLatin1StringView{m_data_utf8, int(size())};
}
template <typename Visitor>
@@ -476,7 +478,7 @@ public:
explicit QString(const QChar *unicode, qsizetype size = -1);
QString(QChar c);
QString(qsizetype size, QChar c);
- inline QString(QLatin1String latin1);
+ inline QString(QLatin1StringView latin1);
#if defined(__cpp_char8_t) || defined(Q_CLANG_QDOC)
Q_WEAK_OVERLOAD
inline QString(const char8_t *str)
@@ -487,7 +489,7 @@ public:
inline ~QString();
QString &operator=(QChar c);
QString &operator=(const QString &) noexcept;
- QString &operator=(QLatin1String latin1);
+ QString &operator=(QLatin1StringView latin1);
inline QString(QString &&other) noexcept
= default;
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QString)
@@ -557,7 +559,7 @@ public:
#endif
[[nodiscard]] QString arg(QStringView a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
- [[nodiscard]] QString arg(QLatin1String a, int fieldWidth = 0,
+ [[nodiscard]] QString arg(QLatin1StringView a, int fieldWidth = 0,
QChar fillChar = QLatin1Char(' ')) const;
private:
template <typename T>
@@ -565,7 +567,7 @@ private:
: std::integral_constant<bool,
std::is_convertible<T, QString>::value ||
std::is_convertible<T, QStringView>::value ||
- std::is_convertible<T, QLatin1String>::value> {};
+ std::is_convertible<T, QLatin1StringView>::value> {};
template <typename T>
struct is_convertible_to_view_or_qstring
: is_convertible_to_view_or_qstring_helper<typename std::decay<T>::type> {};
@@ -590,7 +592,7 @@ public:
static QString asprintf(const char *format, ...) Q_ATTRIBUTE_FORMAT_PRINTF(1, 2);
[[nodiscard]] qsizetype indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- [[nodiscard]] qsizetype indexOf(QLatin1String s, 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
@@ -599,9 +601,9 @@ public:
[[nodiscard]] qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return lastIndexOf(c, -1, cs); }
[[nodiscard]] qsizetype lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
- [[nodiscard]] qsizetype lastIndexOf(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ [[nodiscard]] qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
{ return lastIndexOf(s, size(), cs); }
- [[nodiscard]] qsizetype lastIndexOf(QLatin1String s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ [[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); }
@@ -617,7 +619,7 @@ public:
#if QT_STRINGVIEW_LEVEL < 2
[[nodiscard]] inline bool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
#endif
- [[nodiscard]] inline bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ [[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;
[[nodiscard]] qsizetype count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -675,7 +677,7 @@ public:
#endif
[[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); }
- bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ 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
@@ -683,7 +685,7 @@ public:
#endif
[[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); }
- bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool isUpper() const;
@@ -728,7 +730,7 @@ public:
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, QLatin1String s);
+ QString &insert(qsizetype i, QLatin1StringView s);
QString &append(QChar c);
QString &append(const QChar *uc, qsizetype len);
@@ -736,7 +738,7 @@ public:
QString &append(const QString &s);
#endif
inline QString &append(QStringView v) { return append(v.data(), v.length()); }
- QString &append(QLatin1String s);
+ 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); }
@@ -744,7 +746,7 @@ public:
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(QLatin1String s) { return insert(0, s); }
+ inline QString &prepend(QLatin1StringView s) { return insert(0, s); }
inline QString &operator+=(QChar c) { return append(c); }
@@ -752,11 +754,11 @@ public:
inline QString &operator+=(const QString &s) { return append(s); }
#endif
inline QString &operator+=(QStringView v) { return append(v); }
- inline QString &operator+=(QLatin1String s) { return append(s); }
+ inline QString &operator+=(QLatin1StringView s) { return append(s); }
QString &remove(qsizetype i, qsizetype len);
QString &remove(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive);
- QString &remove(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+ QString &remove(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
QString &remove(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive);
template <typename Predicate>
QString &removeIf(Predicate pred)
@@ -769,13 +771,13 @@ public:
QString &replace(qsizetype i, qsizetype len, const QString &after);
QString &replace(QChar before, QChar after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
QString &replace(const QChar *before, qsizetype blen, const QChar *after, qsizetype alen, Qt::CaseSensitivity cs = Qt::CaseSensitive);
- QString &replace(QLatin1String before, QLatin1String after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
- QString &replace(QLatin1String before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
- QString &replace(const QString &before, QLatin1String after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+ QString &replace(QLatin1StringView before, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+ QString &replace(QLatin1StringView before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+ QString &replace(const QString &before, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
QString &replace(const QString &before, const QString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
QString &replace(QChar c, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
- QString &replace(QChar c, QLatin1String after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+ QString &replace(QChar c, QLatin1StringView after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
#if QT_CONFIG(regularexpression)
QString &replace(const QRegularExpression &re, const QString &after);
inline QString &remove(const QRegularExpression &re)
@@ -899,7 +901,7 @@ public:
#if QT_STRINGVIEW_LEVEL < 2
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
#endif
- int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
+ 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
{ return compare(QStringView{&ch, 1}, cs); }
@@ -908,10 +910,10 @@ public:
Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept
{ return s1.compare(s2, cs); }
- static inline int compare(const QString &s1, QLatin1String s2,
+ static inline int compare(const QString &s1, QLatin1StringView s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept
{ return s1.compare(s2, cs); }
- static inline int compare(QLatin1String s1, const QString &s2,
+ static inline int compare(QLatin1StringView s1, const QString &s2,
Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept
{ return -s2.compare(s1, cs); }
static int compare(const QString &s1, QStringView s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept
@@ -971,22 +973,22 @@ public:
friend bool operator<=(const QString &s1, const QString &s2) noexcept { return !(s1 > s2); }
friend bool operator>=(const QString &s1, const QString &s2) noexcept { return !(s1 < s2); }
- friend bool operator==(const QString &s1, QLatin1String s2) noexcept
+ friend bool operator==(const QString &s1, QLatin1StringView s2) noexcept
{ return (s1.size() == s2.size()) && QtPrivate::compareStrings(s1, s2, Qt::CaseSensitive) == 0; }
- friend bool operator< (const QString &s1, QLatin1String s2) noexcept
+ friend bool operator< (const QString &s1, QLatin1StringView s2) noexcept
{ return QtPrivate::compareStrings(s1, s2, Qt::CaseSensitive) < 0; }
- friend bool operator> (const QString &s1, QLatin1String s2) noexcept
+ friend bool operator> (const QString &s1, QLatin1StringView s2) noexcept
{ return QtPrivate::compareStrings(s1, s2, Qt::CaseSensitive) > 0; }
- friend bool operator!=(const QString &s1, QLatin1String s2) noexcept { return !(s1 == s2); }
- friend bool operator<=(const QString &s1, QLatin1String s2) noexcept { return !(s1 > s2); }
- friend bool operator>=(const QString &s1, QLatin1String s2) noexcept { return !(s1 < s2); }
+ friend bool operator!=(const QString &s1, QLatin1StringView s2) noexcept { return !(s1 == s2); }
+ friend bool operator<=(const QString &s1, QLatin1StringView s2) noexcept { return !(s1 > s2); }
+ friend bool operator>=(const QString &s1, QLatin1StringView s2) noexcept { return !(s1 < s2); }
- friend bool operator==(QLatin1String s1, const QString &s2) noexcept { return s2 == s1; }
- friend bool operator< (QLatin1String s1, const QString &s2) noexcept { return s2 > s1; }
- friend bool operator> (QLatin1String s1, const QString &s2) noexcept { return s2 < s1; }
- friend bool operator!=(QLatin1String s1, const QString &s2) noexcept { return s2 != s1; }
- friend bool operator<=(QLatin1String s1, const QString &s2) noexcept { return s2 >= s1; }
- friend bool operator>=(QLatin1String s1, const QString &s2) noexcept { return s2 <= s1; }
+ friend bool operator==(QLatin1StringView s1, const QString &s2) noexcept { return s2 == s1; }
+ friend bool operator< (QLatin1StringView s1, const QString &s2) noexcept { return s2 > s1; }
+ friend bool operator> (QLatin1StringView s1, const QString &s2) noexcept { return s2 < s1; }
+ friend bool operator!=(QLatin1StringView s1, const QString &s2) noexcept { return s2 != s1; }
+ friend bool operator<=(QLatin1StringView s1, const QString &s2) noexcept { return s2 >= s1; }
+ friend bool operator>=(QLatin1StringView s1, const QString &s2) noexcept { return s2 <= s1; }
// Check isEmpty() instead of isNull() for backwards compatibility.
friend bool operator==(const QString &s1, std::nullptr_t) noexcept { return s1.isEmpty(); }
@@ -1238,10 +1240,10 @@ public:
};
//
-// QLatin1String inline members that require QString:
+// QLatin1StringView inline members that require QString:
//
-QString QLatin1String::toString() const { return *this; }
+QString QLatin1StringView::toString() const { return *this; }
//
// QStringView inline members that require QString:
@@ -1293,7 +1295,7 @@ QString QAnyStringView::toString() const
//
// QString inline members
//
-inline QString::QString(QLatin1String latin1)
+inline QString::QString(QLatin1StringView latin1)
{ *this = QString::fromLatin1(latin1.data(), latin1.size()); }
inline const QChar QString::at(qsizetype i) const
{ Q_ASSERT(size_t(i) < size_t(size())); return QChar(d.data()[i]); }
@@ -1434,7 +1436,7 @@ inline QString::const_iterator QString::constEnd() const
inline bool QString::contains(const QString &s, Qt::CaseSensitivity cs) const
{ return indexOf(s, 0, cs) != -1; }
#endif
-inline bool QString::contains(QLatin1String s, Qt::CaseSensitivity cs) const
+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
{ return indexOf(c, 0, cs) != -1; }
@@ -1455,33 +1457,33 @@ inline bool QString::operator<=(const char *s) const
inline bool QString::operator>=(const char *s) const
{ return QString::compare_helper(constData(), size(), s, -1) >= 0; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator==(const char *s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator==(const char *s) const
{ return QString::fromUtf8(s) == *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator!=(const char *s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator!=(const char *s) const
{ return QString::fromUtf8(s) != *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator<(const char *s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator<(const char *s) const
{ return QString::fromUtf8(s) > *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator>(const char *s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator>(const char *s) const
{ return QString::fromUtf8(s) < *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator<=(const char *s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator<=(const char *s) const
{ return QString::fromUtf8(s) >= *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator>=(const char *s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator>=(const char *s) const
{ return QString::fromUtf8(s) <= *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator==(const QByteArray &s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator==(const QByteArray &s) const
{ return QString::fromUtf8(s) == *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator!=(const QByteArray &s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator!=(const QByteArray &s) const
{ return QString::fromUtf8(s) != *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator<(const QByteArray &s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator<(const QByteArray &s) const
{ return QString::fromUtf8(s) > *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator>(const QByteArray &s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator>(const QByteArray &s) const
{ return QString::fromUtf8(s) < *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator<=(const QByteArray &s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator<=(const QByteArray &s) const
{ return QString::fromUtf8(s) >= *this; }
-QT_ASCII_CAST_WARN inline bool QLatin1String::operator>=(const QByteArray &s) const
+QT_ASCII_CAST_WARN inline bool QLatin1StringView::operator>=(const QByteArray &s) const
{ return QString::fromUtf8(s) <= *this; }
-inline int QLatin1String::compare_helper(const QLatin1String &s1, const char *s2)
+inline int QLatin1StringView::compare_helper(const QLatin1StringView &s1, const char *s2)
{
return QString::compare(s1, QString::fromUtf8(s2));
}
@@ -1608,13 +1610,13 @@ struct QStringViewArg : ArgBase {
};
struct QLatin1StringArg : ArgBase {
- QLatin1String string;
+ QLatin1StringView string;
QLatin1StringArg() = default;
- constexpr explicit QLatin1StringArg(QLatin1String v) noexcept : ArgBase{L1}, string{v} {}
+ constexpr explicit QLatin1StringArg(QLatin1StringView v) noexcept : ArgBase{L1}, string{v} {}
};
[[nodiscard]] Q_CORE_EXPORT QString argToQString(QStringView pattern, size_t n, const ArgBase **args);
-[[nodiscard]] Q_CORE_EXPORT QString argToQString(QLatin1String pattern, size_t n, const ArgBase **args);
+[[nodiscard]] Q_CORE_EXPORT QString argToQString(QLatin1StringView pattern, size_t n, const ArgBase **args);
template <typename StringView, typename...Args>
[[nodiscard]] Q_ALWAYS_INLINE QString argToQStringDispatch(StringView pattern, const Args &...args)
@@ -1626,7 +1628,7 @@ template <typename StringView, typename...Args>
inline QStringViewArg qStringLikeToArg(const QString &s) noexcept { return QStringViewArg{qToStringViewIgnoringNull(s)}; }
constexpr inline QStringViewArg qStringLikeToArg(QStringView s) noexcept { return QStringViewArg{s}; }
inline QStringViewArg qStringLikeToArg(const QChar &c) noexcept { return QStringViewArg{QStringView{&c, 1}}; }
-constexpr inline QLatin1StringArg qStringLikeToArg(QLatin1String s) noexcept { return QLatin1StringArg{s}; }
+constexpr inline QLatin1StringArg qStringLikeToArg(QLatin1StringView s) noexcept { return QLatin1StringArg{s}; }
} // namespace QtPrivate
@@ -1639,7 +1641,7 @@ QString QStringView::arg(Args &&...args) const
template <typename...Args>
Q_ALWAYS_INLINE
-QString QLatin1String::arg(Args &&...args) const
+QString QLatin1StringView::arg(Args &&...args) const
{
return QtPrivate::argToQStringDispatch(*this, QtPrivate::qStringLikeToArg(args)...);
}
@@ -1667,9 +1669,9 @@ namespace Qt {
inline namespace Literals {
inline namespace StringLiterals {
-constexpr inline QLatin1String operator"" _L1(const char *str, size_t size) noexcept
+constexpr inline QLatin1StringView operator"" _L1(const char *str, size_t size) noexcept
{
- return QLatin1String(str, qsizetype(size));
+ return QLatin1StringView(str, qsizetype(size));
}
} // StringLiterals
diff --git a/src/corelib/text/qstringalgorithms.h b/src/corelib/text/qstringalgorithms.h
index 40882a73ee..42aae1cd4c 100644
--- a/src/corelib/text/qstringalgorithms.h
+++ b/src/corelib/text/qstringalgorithms.h
@@ -55,54 +55,54 @@ namespace QtPrivate {
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION const char16_t *qustrchr(QStringView str, char16_t ch) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QLatin1StringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QStringView lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1String lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1StringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1StringView lhs, QLatin1StringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QLatin1StringView lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QLatin1StringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int compareStrings(QBasicUtf8StringView<false> lhs, QBasicUtf8StringView<false> rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QStringView rhs) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QLatin1String rhs) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QLatin1StringView rhs) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QStringView lhs, QBasicUtf8StringView<false> rhs) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QLatin1String lhs, QStringView rhs) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QLatin1String lhs, QLatin1String rhs) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QLatin1String lhs, QBasicUtf8StringView<false> rhs) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QLatin1StringView lhs, QStringView rhs) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QLatin1StringView lhs, QLatin1StringView rhs) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QLatin1StringView lhs, QBasicUtf8StringView<false> rhs) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QBasicUtf8StringView<false> lhs, QStringView rhs) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QBasicUtf8StringView<false> lhs, QLatin1String rhs) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QBasicUtf8StringView<false> lhs, QLatin1StringView rhs) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool equalStrings(QBasicUtf8StringView<false> lhs, QBasicUtf8StringView<false> rhs) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool startsWith(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool endsWith(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QStringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1StringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype findString(QLatin1StringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QStringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QStringView haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1String haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1String haystack, qsizetype from, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QStringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1StringView haystack, qsizetype from, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype lastIndexOf(QLatin1StringView haystack, qsizetype from, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QStringView trimmed(QStringView s) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1String trimmed(QLatin1String s) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION QLatin1StringView trimmed(QLatin1StringView s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QChar needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive);
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QLatin1String haystack, QLatin1String needle, Qt::CaseSensitivity cs = Qt::CaseSensitive);
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QLatin1String haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive);
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QLatin1String haystack, QChar needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QStringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QLatin1StringView haystack, QLatin1StringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QLatin1StringView haystack, QStringView needle, Qt::CaseSensitivity cs = Qt::CaseSensitive);
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qsizetype count(QLatin1StringView haystack, QChar needle, Qt::CaseSensitivity cs = Qt::CaseSensitive) noexcept;
#if QT_CONFIG(regularexpression)
[[nodiscard]] Q_CORE_EXPORT qsizetype indexOf(QStringView haystack,
@@ -128,9 +128,9 @@ namespace QtPrivate {
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isRightToLeft(QStringView string) noexcept;
-[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1String s) noexcept;
+[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QLatin1StringView s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isAscii(QStringView s) noexcept;
-[[nodiscard]] constexpr inline bool isLatin1(QLatin1String s) noexcept;
+[[nodiscard]] constexpr inline bool isLatin1(QLatin1StringView s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isLatin1(QStringView s) noexcept;
[[nodiscard]] Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool isValidUtf16(QStringView s) noexcept;
diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp
index 84569fccdd..4047a36823 100644
--- a/src/corelib/text/qstringconverter.cpp
+++ b/src/corelib/text/qstringconverter.cpp
@@ -872,7 +872,7 @@ int QUtf8::compareUtf8(QByteArrayView utf8, QStringView utf16) noexcept
return (end1 > src1) - int(end2 > src2);
}
-int QUtf8::compareUtf8(QByteArrayView utf8, QLatin1String s)
+int QUtf8::compareUtf8(QByteArrayView utf8, QLatin1StringView s)
{
char32_t uc1 = QChar::Null;
auto src1 = reinterpret_cast<const uchar *>(utf8.data());
diff --git a/src/corelib/text/qstringconverter_p.h b/src/corelib/text/qstringconverter_p.h
index b4e2f675ff..d04df88aea 100644
--- a/src/corelib/text/qstringconverter_p.h
+++ b/src/corelib/text/qstringconverter_p.h
@@ -310,7 +310,7 @@ struct QUtf8
};
static ValidUtf8Result isValidUtf8(QByteArrayView in);
static int compareUtf8(QByteArrayView utf8, QStringView utf16) noexcept;
- static int compareUtf8(QByteArrayView utf8, QLatin1String s);
+ static int compareUtf8(QByteArrayView utf8, QLatin1StringView s);
};
struct QUtf16
diff --git a/src/corelib/text/qstringfwd.h b/src/corelib/text/qstringfwd.h
index 9574232a7e..781c1070bb 100644
--- a/src/corelib/text/qstringfwd.h
+++ b/src/corelib/text/qstringfwd.h
@@ -62,7 +62,7 @@ QT_END_NO_CHAR8_T_NAMESPACE
class QByteArray;
class QByteArrayView;
-#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED)
+#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0) || defined(QT_BOOTSTRAPPED) || defined(Q_CLANG_QDOC)
class QLatin1StringView;
using QLatin1String = QLatin1StringView;
#else
diff --git a/src/corelib/text/qstringview.cpp b/src/corelib/text/qstringview.cpp
index 6babe3450e..ef33ebf43e 100644
--- a/src/corelib/text/qstringview.cpp
+++ b/src/corelib/text/qstringview.cpp
@@ -554,7 +554,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn template <typename...Args> QString QStringView::arg(Args &&...args) const
- \fn template <typename...Args> QString QLatin1String::arg(Args &&...args) const
+ \fn template <typename...Args> QString QLatin1StringView::arg(Args &&...args) const
\fn template <typename...Args> QString QString::arg(Args &&...args) const
\since 5.14
@@ -1403,7 +1403,7 @@ QT_BEGIN_NAMESPACE
/*!
\fn template <typename Needle, typename...Flags> auto QStringView::tokenize(Needle &&sep, Flags...flags) const
- \fn template <typename Needle, typename...Flags> auto QLatin1String::tokenize(Needle &&sep, Flags...flags) const
+ \fn template <typename Needle, typename...Flags> auto QLatin1StringView::tokenize(Needle &&sep, Flags...flags) const
\fn template <typename Needle, typename...Flags> auto QString::tokenize(Needle &&sep, Flags...flags) const &
\fn template <typename Needle, typename...Flags> auto QString::tokenize(Needle &&sep, Flags...flags) const &&
\fn template <typename Needle, typename...Flags> auto QString::tokenize(Needle &&sep, Flags...flags) &&