QtCore: Replace remaining uses of QLatin1String with QLatin1StringView

Task-number: QTBUG-98434
Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Sona Kurazyan 2022-03-09 21:26:01 +01:00
parent 73a03a0c29
commit b625195893
94 changed files with 419 additions and 405 deletions

View File

@ -142,7 +142,7 @@ QUuid QUuid::fromString(QStringView string) noexcept
return fromString(QAnyStringView{string}); return fromString(QAnyStringView{string});
} }
QUuid QUuid::fromString(QLatin1String string) noexcept QUuid QUuid::fromString(QLatin1StringView string) noexcept
{ {
return fromString(QAnyStringView{string}); return fromString(QAnyStringView{string});
} }
@ -202,7 +202,7 @@ QByteArray QUrl::toAce(const QString &domain)
QCalendar::QCalendar(QStringView name) QCalendar::QCalendar(QStringView name)
: QCalendar(QAnyStringView{name}) {} : QCalendar(QAnyStringView{name}) {}
QCalendar::QCalendar(QLatin1String name) QCalendar::QCalendar(QLatin1StringView name)
: QCalendar(QAnyStringView{name}) {} : QCalendar(QAnyStringView{name}) {}
@ -272,7 +272,7 @@ QVersionNumber QVersionNumber::fromString(QStringView string, int *suffixIndex)
return fromString(QAnyStringView{string}, suffixIndex); return fromString(QAnyStringView{string}, suffixIndex);
} }
QVersionNumber QVersionNumber::fromString(QLatin1String string, int *suffixIndex) QVersionNumber QVersionNumber::fromString(QLatin1StringView string, int *suffixIndex)
{ {
return fromString(QAnyStringView{string}, suffixIndex); return fromString(QAnyStringView{string}, suffixIndex);
} }

View File

@ -69,6 +69,6 @@ using namespace Qt::StringLiterals;
QString hello("hello"); QString hello("hello");
QStringView el = QStringView{ hello }.mid(2, 3); QStringView el = QStringView{ hello }.mid(2, 3);
QLatin1String world("world"); QLatin1StringView world("world");
QString message = hello % el % world % QChar('!'); QString message = hello % el % world % QChar('!');
//! [5] //! [5]

View File

@ -97,7 +97,7 @@ void QObject::parse()
//! [3] //! [3]
//! [3-latin1-1] //! [3-latin1-1]
QLatin1String string("5.4.0-alpha"); QLatin1StringView string("5.4.0-alpha");
qsizetype suffixIndex; qsizetype suffixIndex;
auto version = QVersionNumber::fromString(string, &suffixIndex); auto version = QVersionNumber::fromString(string, &suffixIndex);
// version is 5.4.0 // version is 5.4.0

View File

@ -2617,9 +2617,9 @@ QString QSysInfo::currentCpuArchitecture()
# if defined(Q_PROCESSOR_POWER) || defined(QT_BUILD_INTERNAL) # if defined(Q_PROCESSOR_POWER) || defined(QT_BUILD_INTERNAL)
// harmonize "powerpc" and "ppc" to "power" // harmonize "powerpc" and "ppc" to "power"
if (strncmp(u.machine, "ppc", 3) == 0) if (strncmp(u.machine, "ppc", 3) == 0)
return "power"_L1 + QLatin1String(u.machine + 3); return "power"_L1 + QLatin1StringView(u.machine + 3);
if (strncmp(u.machine, "powerpc", 7) == 0) if (strncmp(u.machine, "powerpc", 7) == 0)
return "power"_L1 + QLatin1String(u.machine + 7); return "power"_L1 + QLatin1StringView(u.machine + 7);
if (strcmp(u.machine, "Power Macintosh") == 0) if (strcmp(u.machine, "Power Macintosh") == 0)
return "power"_L1; return "power"_L1;
# endif # endif
@ -2907,7 +2907,7 @@ QString QSysInfo::prettyProductName()
const char *name = osVer_helper(version); const char *name = osVer_helper(version);
if (!name) if (!name)
return result + versionString; return result + versionString;
result += QLatin1String(name); result += QLatin1StringView(name);
# if !defined(Q_OS_WIN) # if !defined(Q_OS_WIN)
return result + " ("_L1 + versionString + u')'; return result + " ("_L1 + versionString + u')';
# else # else

View File

@ -626,7 +626,8 @@ using qsizetype = QIntegerForSizeof<std::size_t>::Signed;
#endif #endif
#ifdef QT_ASCII_CAST_WARNINGS #ifdef QT_ASCII_CAST_WARNINGS
# define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED_X("Use fromUtf8, QStringLiteral, or QLatin1String") # define QT_ASCII_CAST_WARN \
Q_DECL_DEPRECATED_X("Use fromUtf8, QStringLiteral, or QLatin1StringView")
#else #else
# define QT_ASCII_CAST_WARN # define QT_ASCII_CAST_WARN
#endif #endif

View File

@ -148,7 +148,7 @@ static QSettings *findConfiguration()
#endif #endif
if (QCoreApplication::instance()) { if (QCoreApplication::instance()) {
QDir pwd(QCoreApplication::applicationDirPath()); QDir pwd(QCoreApplication::applicationDirPath());
qtconfig = pwd.filePath(QLatin1String("qt" QT_STRINGIFY(QT_VERSION_MAJOR) ".conf")); qtconfig = pwd.filePath(u"qt" QT_STRINGIFY(QT_VERSION_MAJOR) ".conf"_qs);
if (QFile::exists(qtconfig)) if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat); return new QSettings(qtconfig, QSettings::IniFormat);
qtconfig = pwd.filePath("qt.conf"_L1); qtconfig = pwd.filePath("qt.conf"_L1);
@ -529,14 +529,14 @@ QLibraryInfoPrivate::LocationInfo QLibraryInfoPrivate::locationInfo(QLibraryInfo
LocationInfo result; LocationInfo result;
if (int(loc) < qtConfEntries.count()) { if (int(loc) < qtConfEntries.count()) {
result.key = QLatin1String(qtConfEntries.viewAt(loc * 2)); result.key = QLatin1StringView(qtConfEntries.viewAt(loc * 2));
result.defaultValue = QLatin1String(qtConfEntries.viewAt(loc * 2 + 1)); result.defaultValue = QLatin1StringView(qtConfEntries.viewAt(loc * 2 + 1));
if (result.key == u"QmlImports") if (result.key == u"QmlImports")
result.fallbackKey = u"Qml2Imports"_qs; result.fallbackKey = u"Qml2Imports"_qs;
#ifndef Q_OS_WIN // On Windows we use the registry #ifndef Q_OS_WIN // On Windows we use the registry
} else if (loc == QLibraryInfo::SettingsPath) { } else if (loc == QLibraryInfo::SettingsPath) {
result.key = "Settings"_L1; result.key = "Settings"_L1;
result.defaultValue = QLatin1String(dot); result.defaultValue = QLatin1StringView(dot);
#endif #endif
} }

View File

@ -1105,7 +1105,7 @@ QMessagePattern::QMessagePattern()
#endif #endif
const QString envPattern = QString::fromLocal8Bit(qgetenv("QT_MESSAGE_PATTERN")); const QString envPattern = QString::fromLocal8Bit(qgetenv("QT_MESSAGE_PATTERN"));
if (envPattern.isEmpty()) { if (envPattern.isEmpty()) {
setPattern(QLatin1String(defaultPattern)); setPattern(QLatin1StringView(defaultPattern));
fromEnvironment = false; fromEnvironment = false;
} else { } else {
setPattern(envPattern); setPattern(envPattern);
@ -1165,34 +1165,34 @@ void QMessagePattern::setPattern(const QString &pattern)
const QString lexeme = lexemes.at(i); const QString lexeme = lexemes.at(i);
if (lexeme.startsWith("%{"_L1) && lexeme.endsWith(u'}')) { if (lexeme.startsWith("%{"_L1) && lexeme.endsWith(u'}')) {
// placeholder // placeholder
if (lexeme == QLatin1String(typeTokenC)) { if (lexeme == QLatin1StringView(typeTokenC)) {
tokens[i] = typeTokenC; tokens[i] = typeTokenC;
} else if (lexeme == QLatin1String(categoryTokenC)) } else if (lexeme == QLatin1StringView(categoryTokenC))
tokens[i] = categoryTokenC; tokens[i] = categoryTokenC;
else if (lexeme == QLatin1String(messageTokenC)) else if (lexeme == QLatin1StringView(messageTokenC))
tokens[i] = messageTokenC; tokens[i] = messageTokenC;
else if (lexeme == QLatin1String(fileTokenC)) else if (lexeme == QLatin1StringView(fileTokenC))
tokens[i] = fileTokenC; tokens[i] = fileTokenC;
else if (lexeme == QLatin1String(lineTokenC)) else if (lexeme == QLatin1StringView(lineTokenC))
tokens[i] = lineTokenC; tokens[i] = lineTokenC;
else if (lexeme == QLatin1String(functionTokenC)) else if (lexeme == QLatin1StringView(functionTokenC))
tokens[i] = functionTokenC; tokens[i] = functionTokenC;
else if (lexeme == QLatin1String(pidTokenC)) else if (lexeme == QLatin1StringView(pidTokenC))
tokens[i] = pidTokenC; tokens[i] = pidTokenC;
else if (lexeme == QLatin1String(appnameTokenC)) else if (lexeme == QLatin1StringView(appnameTokenC))
tokens[i] = appnameTokenC; tokens[i] = appnameTokenC;
else if (lexeme == QLatin1String(threadidTokenC)) else if (lexeme == QLatin1StringView(threadidTokenC))
tokens[i] = threadidTokenC; tokens[i] = threadidTokenC;
else if (lexeme == QLatin1String(qthreadptrTokenC)) else if (lexeme == QLatin1StringView(qthreadptrTokenC))
tokens[i] = qthreadptrTokenC; tokens[i] = qthreadptrTokenC;
else if (lexeme.startsWith(QLatin1String(timeTokenC))) { else if (lexeme.startsWith(QLatin1StringView(timeTokenC))) {
tokens[i] = timeTokenC; tokens[i] = timeTokenC;
int spaceIdx = lexeme.indexOf(QChar::fromLatin1(' ')); int spaceIdx = lexeme.indexOf(QChar::fromLatin1(' '));
if (spaceIdx > 0) if (spaceIdx > 0)
timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.length() - spaceIdx - 2)); timeArgs.append(lexeme.mid(spaceIdx + 1, lexeme.length() - spaceIdx - 2));
else else
timeArgs.append(QString()); timeArgs.append(QString());
} else if (lexeme.startsWith(QLatin1String(backtraceTokenC))) { } else if (lexeme.startsWith(QLatin1StringView(backtraceTokenC))) {
#ifdef QLOGGING_HAVE_BACKTRACE #ifdef QLOGGING_HAVE_BACKTRACE
tokens[i] = backtraceTokenC; tokens[i] = backtraceTokenC;
QString backtraceSeparator = QStringLiteral("|"); QString backtraceSeparator = QStringLiteral("|");
@ -1221,7 +1221,7 @@ void QMessagePattern::setPattern(const QString &pattern)
} }
#define IF_TOKEN(LEVEL) \ #define IF_TOKEN(LEVEL) \
else if (lexeme == QLatin1String(LEVEL)) { \ else if (lexeme == QLatin1StringView(LEVEL)) { \
if (inIf) \ if (inIf) \
nestedIfError = true; \ nestedIfError = true; \
tokens[i] = LEVEL; \ tokens[i] = LEVEL; \
@ -1234,7 +1234,7 @@ void QMessagePattern::setPattern(const QString &pattern)
IF_TOKEN(ifCriticalTokenC) IF_TOKEN(ifCriticalTokenC)
IF_TOKEN(ifFatalTokenC) IF_TOKEN(ifFatalTokenC)
#undef IF_TOKEN #undef IF_TOKEN
else if (lexeme == QLatin1String(endifTokenC)) { else if (lexeme == QLatin1StringView(endifTokenC)) {
tokens[i] = endifTokenC; tokens[i] = endifTokenC;
if (!inIf && !nestedIfError) if (!inIf && !nestedIfError)
error += "QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"_L1; error += "QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"_L1;
@ -1344,12 +1344,12 @@ static QStringList backtraceFramesForLogMessage(int frameCount)
return {}; return {};
// These are actually UTF-8, so we'll correct below // These are actually UTF-8, so we'll correct below
QLatin1String fn(info.dli_sname); QLatin1StringView fn(info.dli_sname);
QLatin1String lib; QLatin1StringView lib;
if (const char *lastSlash = strrchr(info.dli_fname, '/')) if (const char *lastSlash = strrchr(info.dli_fname, '/'))
lib = QLatin1String(lastSlash + 1); lib = QLatin1StringView(lastSlash + 1);
else else
lib = QLatin1String(info.dli_fname); lib = QLatin1StringView(info.dli_fname);
if (shouldSkipFrame(lib, fn)) if (shouldSkipFrame(lib, fn))
return {}; return {};
@ -1488,7 +1488,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
} else if (token == categoryTokenC) { } else if (token == categoryTokenC) {
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
// Don't add the category to the message on Android // Don't add the category to the message on Android
message.append(QLatin1String(context.category)); message.append(QLatin1StringView(context.category));
#endif #endif
} else if (token == typeTokenC) { } else if (token == typeTokenC) {
switch (type) { switch (type) {
@ -1500,7 +1500,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
} }
} else if (token == fileTokenC) { } else if (token == fileTokenC) {
if (context.file) if (context.file)
message.append(QLatin1String(context.file)); message.append(QLatin1StringView(context.file));
else else
message.append("unknown"_L1); message.append("unknown"_L1);
} else if (token == lineTokenC) { } else if (token == lineTokenC) {
@ -1559,7 +1559,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
HANDLE_IF_TOKEN(Fatal) HANDLE_IF_TOKEN(Fatal)
#undef HANDLE_IF_TOKEN #undef HANDLE_IF_TOKEN
} else { } else {
message.append(QLatin1String(token)); message.append(QLatin1StringView(token));
} }
} }
return message; return message;

View File

@ -72,12 +72,12 @@ Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray
data = data.trimmed(); data = data.trimmed();
// find out if the payload is encoded in Base64 // find out if the payload is encoded in Base64
if (QLatin1String{data}.endsWith(";base64"_L1, Qt::CaseInsensitive)) { if (QLatin1StringView{data}.endsWith(";base64"_L1, Qt::CaseInsensitive)) {
payload = QByteArray::fromBase64(payload); payload = QByteArray::fromBase64(payload);
data.chop(7); data.chop(7);
} }
if (QLatin1String{data}.startsWith("charset"_L1, Qt::CaseInsensitive)) { if (QLatin1StringView{data}.startsWith("charset"_L1, Qt::CaseInsensitive)) {
int i = 7; // strlen("charset") int i = 7; // strlen("charset")
while (data.at(i) == ' ') while (data.at(i) == ' ')
++i; ++i;

View File

@ -728,7 +728,7 @@ QDebug &QDebug::resetFormat()
*/ */
/*! /*!
\fn QDebug &QDebug::operator<<(QLatin1String t) \fn QDebug &QDebug::operator<<(QLatin1StringView t)
Writes the string, \a t, to the stream and returns a reference to the Writes the string, \a t, to the stream and returns a reference to the
stream. Normally, QDebug prints the string inside quotes and transforms stream. Normally, QDebug prints the string inside quotes and transforms

View File

@ -147,7 +147,7 @@ public:
#endif #endif
inline QDebug &operator<<(QStringView s) { putString(s.data(), size_t(s.size())); return maybeSpace(); } inline QDebug &operator<<(QStringView s) { putString(s.data(), size_t(s.size())); return maybeSpace(); }
inline QDebug &operator<<(QUtf8StringView s) { putByteArray(reinterpret_cast<const char*>(s.data()), s.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(QUtf8StringView s) { putByteArray(reinterpret_cast<const char*>(s.data()), s.size(), ContainsBinary); return maybeSpace(); }
inline QDebug &operator<<(QLatin1String t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); } inline QDebug &operator<<(QLatin1StringView t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); }
inline QDebug &operator<<(const QByteArray & t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(const QByteArray & t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); }
inline QDebug &operator<<(QByteArrayView t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(QByteArrayView t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); }
inline QDebug &operator<<(const void * t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(const void * t) { stream->ts << t; return maybeSpace(); }

View File

@ -1654,7 +1654,7 @@ QString QFileSystemEngine::rootPath()
QString QFileSystemEngine::tempPath() QString QFileSystemEngine::tempPath()
{ {
#ifdef QT_UNIX_TEMP_PATH_OVERRIDE #ifdef QT_UNIX_TEMP_PATH_OVERRIDE
return QLatin1String(QT_UNIX_TEMP_PATH_OVERRIDE); return QT_UNIX_TEMP_PATH_OVERRIDE ""_L1;
#else #else
QString temp = QFile::decodeName(qgetenv("TMPDIR")); QString temp = QFile::decodeName(qgetenv("TMPDIR"));
if (temp.isEmpty()) { if (temp.isEmpty()) {
@ -1664,7 +1664,7 @@ QString QFileSystemEngine::tempPath()
temp = QString::fromCFString((CFStringRef)nsPath); temp = QString::fromCFString((CFStringRef)nsPath);
#endif #endif
} else { } else {
temp = QLatin1String(_PATH_TMP); temp = _PATH_TMP ""_L1;
} }
} }
return QDir(QDir::cleanPath(temp)).canonicalPath(); return QDir(QDir::cleanPath(temp)).canonicalPath();

View File

@ -101,7 +101,7 @@ static inline QString msgOpenDirectory()
#if QT_CONFIG(translation) #if QT_CONFIG(translation)
return QIODevice::tr(message); return QIODevice::tr(message);
#else #else
return QLatin1String(message); return QLatin1StringView(message);
#endif #endif
} }

View File

@ -2173,7 +2173,7 @@ QString QIODevice::errorString() const
Q_D(const QIODevice); Q_D(const QIODevice);
if (d->errorString.isEmpty()) { if (d->errorString.isEmpty()) {
#ifdef QT_NO_QOBJECT #ifdef QT_NO_QOBJECT
return QLatin1String(QT_TRANSLATE_NOOP(QIODevice, "Unknown error")); return QLatin1StringView(QT_TRANSLATE_NOOP(QIODevice, "Unknown error"));
#else #else
return tr("Unknown error"); return tr("Unknown error");
#endif #endif

View File

@ -89,7 +89,7 @@ QLoggingRule::QLoggingRule(QStringView pattern, bool enabled) :
Return value 1 means filter passed, 0 means filter doesn't influence this Return value 1 means filter passed, 0 means filter doesn't influence this
category, -1 means category doesn't pass this filter. category, -1 means category doesn't pass this filter.
*/ */
int QLoggingRule::pass(QLatin1String cat, QtMsgType msgType) const int QLoggingRule::pass(QLatin1StringView cat, QtMsgType msgType) const
{ {
// check message type // check message type
if (messageType > -1 && messageType != msgType) if (messageType > -1 && messageType != msgType)
@ -482,7 +482,7 @@ void QLoggingRegistry::defaultCategoryFilter(QLoggingCategory *cat)
} }
} }
const auto categoryName = QLatin1String(cat->categoryName()); const auto categoryName = QLatin1StringView(cat->categoryName());
for (const auto &ruleSet : reg->ruleSets) { for (const auto &ruleSet : reg->ruleSets) {
for (const auto &rule : ruleSet) { for (const auto &rule : ruleSet) {

View File

@ -79,7 +79,7 @@ class Q_AUTOTEST_EXPORT QLoggingRule
public: public:
QLoggingRule(); QLoggingRule();
QLoggingRule(QStringView pattern, bool enabled); QLoggingRule(QStringView pattern, bool enabled);
int pass(QLatin1String categoryName, QtMsgType type) const; int pass(QLatin1StringView categoryName, QtMsgType type) const;
enum PatternFlag { enum PatternFlag {
FullText = 0x1, FullText = 0x1,

View File

@ -627,7 +627,7 @@ bool QProcessPrivate::processStarted(QString *errorMessage)
// did we read an error message? // did we read an error message?
if (errorMessage) if (errorMessage)
*errorMessage = QLatin1String(buf.function) + ": "_L1 + qt_error_string(buf.code); *errorMessage = QLatin1StringView(buf.function) + ": "_L1 + qt_error_string(buf.code);
return false; return false;
} }
@ -1036,7 +1036,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
*pid = -1; *pid = -1;
QString msg; QString msg;
if (startResult == sizeof(childStatus)) if (startResult == sizeof(childStatus))
msg = QLatin1String(childStatus.function) + qt_error_string(childStatus.code); msg = QLatin1StringView(childStatus.function) + qt_error_string(childStatus.code);
setErrorAndEmit(QProcess::FailedToStart, msg); setErrorAndEmit(QProcess::FailedToStart, msg);
} }
return success; return success;

View File

@ -418,7 +418,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
case QMetaType::QByteArray: { case QMetaType::QByteArray: {
QByteArray a = v.toByteArray(); QByteArray a = v.toByteArray();
result = "@ByteArray("_L1 result = "@ByteArray("_L1
+ QLatin1String(a.constData(), a.size()) + QLatin1StringView(a.constData(), a.size())
+ u')'; + u')';
break; break;
} }
@ -477,8 +477,8 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
s << v; s << v;
} }
result = QLatin1String(typeSpec) result = QLatin1StringView(typeSpec)
+ QLatin1String(a.constData(), a.size()) + QLatin1StringView(a.constData(), a.size())
+ u')'; + u')';
#else #else
Q_ASSERT(!"QSettings: Cannot save custom types without QDataStream support"); Q_ASSERT(!"QSettings: Cannot save custom types without QDataStream support");
@ -1656,7 +1656,7 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data,
currentSection.clear(); currentSection.clear();
} else { } else {
if (iniSection.compare("%general", Qt::CaseInsensitive) == 0) { if (iniSection.compare("%general", Qt::CaseInsensitive) == 0) {
currentSection = QLatin1String(iniSection.constData() + 1); currentSection = QLatin1StringView(iniSection.constData() + 1);
} else { } else {
currentSection.clear(); currentSection.clear();
iniUnescapedKey(iniSection, 0, iniSection.size(), currentSection); iniUnescapedKey(iniSection, 0, iniSection.size(), currentSection);

View File

@ -75,7 +75,7 @@ static inline QString getAbsolutePath(const QJniObject &file)
*/ */
static QString getExternalFilesDir(const char *directoryField = nullptr) static QString getExternalFilesDir(const char *directoryField = nullptr)
{ {
QString &path = (*androidDirCache)["APPNAME_%1"_L1.arg(QLatin1String(directoryField))]; QString &path = (*androidDirCache)["APPNAME_%1"_L1.arg(QLatin1StringView(directoryField))];
if (!path.isEmpty()) if (!path.isEmpty())
return path; return path;

View File

@ -75,7 +75,7 @@ static void appendOrganizationAndApp(QString &path)
} }
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
static QLatin1String xdg_key_name(QStandardPaths::StandardLocation type) static QLatin1StringView xdg_key_name(QStandardPaths::StandardLocation type)
{ {
switch (type) { switch (type) {
case QStandardPaths::DesktopLocation: case QStandardPaths::DesktopLocation:
@ -285,7 +285,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
if (xdgConfigHome.isEmpty()) if (xdgConfigHome.isEmpty())
xdgConfigHome = QDir::homePath() + "/.config"_L1; xdgConfigHome = QDir::homePath() + "/.config"_L1;
QFile file(xdgConfigHome + "/user-dirs.dirs"_L1); QFile file(xdgConfigHome + "/user-dirs.dirs"_L1);
const QLatin1String key = xdg_key_name(type); const QLatin1StringView key = xdg_key_name(type);
if (!key.isEmpty() && !isTestModeEnabled() && file.open(QIODevice::ReadOnly)) { if (!key.isEmpty() && !isTestModeEnabled() && file.open(QIODevice::ReadOnly)) {
QTextStream stream(&file); QTextStream stream(&file);
// Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop" // Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"

View File

@ -796,7 +796,7 @@ static inline QString retrieveLabel(const QByteArray &device)
QFileInfo devinfo(QFile::decodeName(device)); QFileInfo devinfo(QFile::decodeName(device));
QString devicePath = devinfo.canonicalFilePath(); QString devicePath = devinfo.canonicalFilePath();
QDirIterator it(QLatin1String(pathDiskByLabel), QDir::NoDotAndDotDot); QDirIterator it(QLatin1StringView(pathDiskByLabel), QDir::NoDotAndDotDot);
while (it.hasNext()) { while (it.hasNext()) {
QFileInfo fileInfo = it.nextFileInfo(); QFileInfo fileInfo = it.nextFileInfo();
if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath) if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath)

View File

@ -3597,12 +3597,8 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err
static inline void appendComponentIfPresent(QString &msg, bool present, const char *componentName, static inline void appendComponentIfPresent(QString &msg, bool present, const char *componentName,
const QString &component) const QString &component)
{ {
if (present) { if (present)
msg += QLatin1String(componentName); msg += QLatin1StringView(componentName) % u'"' % component % "\","_L1;
msg += u'"';
msg += component;
msg += "\","_L1;
}
} }
/*! /*!

View File

@ -968,7 +968,7 @@ QStringList QUrl::idnWhitelist()
list.reserve(idn_whitelist.count()); list.reserve(idn_whitelist.count());
int i = 0; int i = 0;
while (i < idn_whitelist.count()) { while (i < idn_whitelist.count()) {
list << QLatin1String(idn_whitelist.at(i)); list << QLatin1StringView(idn_whitelist.at(i));
++i; ++i;
} }
return list; return list;

View File

@ -175,7 +175,7 @@ static QString flagsValue(const QWinMessageMapping<IntType> *haystack,
if ((p->value & value) == p->value) { if ((p->value & value) == p->value) {
if (!result.isEmpty()) if (!result.isEmpty())
result += " | "_L1; result += " | "_L1;
result += QLatin1String(p->name); result += QLatin1StringView(p->name);
} }
} }
return result; return result;
@ -677,7 +677,7 @@ QString decodeMSG(const MSG& msg)
switch (msg.message) { switch (msg.message) {
case WM_ACTIVATE: case WM_ACTIVATE:
if (const char *a = activateParameter(uint(wParam))) if (const char *a = activateParameter(uint(wParam)))
parameters += QLatin1String(a); parameters += QLatin1StringView(a);
parameters += " Hwnd "_L1 + hwndS; parameters += " Hwnd "_L1 + hwndS;
break; break;
case WM_CAPTURECHANGED: case WM_CAPTURECHANGED:
@ -719,7 +719,7 @@ QString decodeMSG(const MSG& msg)
{ {
parameters = "Command("_L1; parameters = "Command("_L1;
if (const char *c = imeCommand(uint(wParam))) if (const char *c = imeCommand(uint(wParam)))
parameters += QLatin1String(c); parameters += QLatin1StringView(c);
parameters += " : "_L1 + lParamS; parameters += " : "_L1 + lParamS;
} }
break; break;
@ -794,7 +794,7 @@ QString decodeMSG(const MSG& msg)
case WM_SETCURSOR: case WM_SETCURSOR:
parameters = QString::asprintf("HitTestCode(0x%x) MouseMsg(", LOWORD(lParam)); parameters = QString::asprintf("HitTestCode(0x%x) MouseMsg(", LOWORD(lParam));
if (const char *mouseMsg = findWMstr(HIWORD(lParam))) if (const char *mouseMsg = findWMstr(HIWORD(lParam)))
parameters += QLatin1String(mouseMsg); parameters += QLatin1StringView(mouseMsg);
parameters += u')'; parameters += u')';
break; break;
case WM_SETFOCUS: case WM_SETFOCUS:
@ -809,7 +809,7 @@ QString decodeMSG(const MSG& msg)
parameters = QString::asprintf("w,h(%4d,%4d) showmode(", parameters = QString::asprintf("w,h(%4d,%4d) showmode(",
LOWORD(lParam), HIWORD(lParam)); LOWORD(lParam), HIWORD(lParam));
if (const char *showMode = wmSizeParam(uint(wParam))) if (const char *showMode = wmSizeParam(uint(wParam)))
parameters += QLatin1String(showMode); parameters += QLatin1StringView(showMode);
parameters += u')'; parameters += u')';
break; break;
case WM_WINDOWPOSCHANGED: case WM_WINDOWPOSCHANGED:
@ -822,7 +822,7 @@ QString decodeMSG(const MSG& msg)
winPos->x, winPos->y, winPos->cx, winPos->cy, winPos->x, winPos->y, winPos->cx, winPos->cy,
winPosFlags(winPos->flags).toLatin1().constData()); winPosFlags(winPos->flags).toLatin1().constData());
if (const char *h = winPosInsertAfter(insertAfter)) if (const char *h = winPosInsertAfter(insertAfter))
parameters += QLatin1String(h); parameters += QLatin1StringView(h);
else else
parameters += QString::number(insertAfter, 16); parameters += QString::number(insertAfter, 16);
parameters += u')'; parameters += u')';
@ -831,7 +831,7 @@ QString decodeMSG(const MSG& msg)
case WM_QUERYENDSESSION: case WM_QUERYENDSESSION:
parameters = "End session: "_L1; parameters = "End session: "_L1;
if (const char *logoffOption = sessionMgrLogOffOption(uint(wParam))) if (const char *logoffOption = sessionMgrLogOffOption(uint(wParam)))
parameters += QLatin1String(logoffOption); parameters += QLatin1StringView(logoffOption);
break; break;
default: default:
parameters = "wParam"_L1 + wParamS + " lParam"_L1 + lParamS; parameters = "wParam"_L1 + wParamS + " lParam"_L1 + lParamS;

View File

@ -317,7 +317,7 @@ public:
QByteArray m_className; QByteArray m_className;
}; };
static inline QLatin1String keyBase() static inline QLatin1StringView keyBase()
{ {
return "%1%2:%3"_L1; return "%1%2:%3"_L1;
} }
@ -367,7 +367,7 @@ jclass QJniObject::loadClass(const QByteArray &className, JNIEnv *env, bool binE
QWriteLocker locker(cachedClassesLock); QWriteLocker locker(cachedClassesLock);
// did we lose the race? // did we lose the race?
const QLatin1String key(binEncClassName); const QLatin1StringView key(binEncClassName);
const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key); const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key);
if (it != cachedClasses->constEnd()) if (it != cachedClasses->constEnd())
return it.value(); return it.value();
@ -418,9 +418,9 @@ jmethodID QJniObject::getCachedMethodID(JNIEnv *env,
if (className.isEmpty()) if (className.isEmpty())
return getMethodID(env, clazz, name, signature, isStatic); return getMethodID(env, clazz, name, signature, isStatic);
const QString key = keyBase().arg(QLatin1String(className), const QString key = keyBase().arg(QLatin1StringView(className),
QLatin1String(name), QLatin1StringView(name),
QLatin1String(signature)); QLatin1StringView(signature));
QHash<QString, jmethodID>::const_iterator it; QHash<QString, jmethodID>::const_iterator it;
{ {
@ -478,9 +478,9 @@ jfieldID QJniObject::getCachedFieldID(JNIEnv *env,
if (className.isNull()) if (className.isNull())
return getFieldID(env, clazz, name, signature, isStatic); return getFieldID(env, clazz, name, signature, isStatic);
const QString key = keyBase().arg(QLatin1String(className), const QString key = keyBase().arg(QLatin1StringView(className),
QLatin1String(name), QLatin1StringView(name),
QLatin1String(signature)); QLatin1StringView(signature));
QHash<QString, jfieldID>::const_iterator it; QHash<QString, jfieldID>::const_iterator it;
{ {
@ -520,7 +520,7 @@ jclass QtAndroidPrivate::findClass(const char *className, JNIEnv *env)
if (clazz || isCached) if (clazz || isCached)
return clazz; return clazz;
const QLatin1String key(classDotEnc); const QLatin1StringView key(classDotEnc);
if (env) { // We got an env. pointer (We expect this to be the right env. and call FindClass()) if (env) { // We got an env. pointer (We expect this to be the right env. and call FindClass())
QWriteLocker locker(cachedClassesLock); QWriteLocker locker(cachedClassesLock);
const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key); const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(key);

View File

@ -160,13 +160,13 @@ static inline const char *rawStringData(const QMetaObject *mo, int index)
return reinterpret_cast<const char *>(mo->d.stringdata) + offset; return reinterpret_cast<const char *>(mo->d.stringdata) + offset;
} }
static inline QLatin1String stringDataView(const QMetaObject *mo, int index) static inline QLatin1StringView stringDataView(const QMetaObject *mo, int index)
{ {
Q_ASSERT(priv(mo->d.data)->revision >= 7); Q_ASSERT(priv(mo->d.data)->revision >= 7);
uint offset = mo->d.stringdata[2*index]; uint offset = mo->d.stringdata[2*index];
uint length = mo->d.stringdata[2*index + 1]; uint length = mo->d.stringdata[2*index + 1];
const char *string = reinterpret_cast<const char *>(mo->d.stringdata) + offset; const char *string = reinterpret_cast<const char *>(mo->d.stringdata) + offset;
return QLatin1String(string, length); return QLatin1StringView(string, length);
} }
static inline QByteArray stringData(const QMetaObject *mo, int index) static inline QByteArray stringData(const QMetaObject *mo, int index)
@ -2833,11 +2833,11 @@ const char *QMetaEnum::valueToKey(int value) const
return nullptr; return nullptr;
} }
static auto parse_scope(QLatin1String qualifiedKey) noexcept static auto parse_scope(QLatin1StringView qualifiedKey) noexcept
{ {
struct R { struct R {
std::optional<QLatin1String> scope; std::optional<QLatin1StringView> scope;
QLatin1String key; QLatin1StringView key;
}; };
const auto scopePos = qualifiedKey.lastIndexOf("::"_L1); const auto scopePos = qualifiedKey.lastIndexOf("::"_L1);
if (scopePos < 0) if (scopePos < 0)
@ -2863,7 +2863,7 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const
if (!mobj || !keys) if (!mobj || !keys)
return -1; return -1;
auto lookup = [&] (QLatin1String key) -> std::optional<int> { auto lookup = [&] (QLatin1StringView key) -> std::optional<int> {
for (int i = data.keyCount() - 1; i >= 0; --i) { for (int i = data.keyCount() - 1; i >= 0; --i) {
if (key == stringDataView(mobj, mobj->d.data[data.data() + 2*i])) if (key == stringDataView(mobj, mobj->d.data[data.data() + 2*i]))
return mobj->d.data[data.data() + 2*i + 1]; return mobj->d.data[data.data() + 2*i + 1];
@ -2873,7 +2873,7 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const
auto className = [&] { return stringDataView(mobj, priv(mobj->d.data)->className); }; auto className = [&] { return stringDataView(mobj, priv(mobj->d.data)->className); };
int value = 0; int value = 0;
for (const QLatin1String &untrimmed : qTokenize(QLatin1String{keys}, u'|')) { for (const QLatin1StringView &untrimmed : qTokenize(QLatin1StringView{keys}, u'|')) {
const auto parsed = parse_scope(untrimmed.trimmed()); const auto parsed = parse_scope(untrimmed.trimmed());
if (parsed.scope && *parsed.scope != className()) if (parsed.scope && *parsed.scope != className())
return -1; // wrong type name in qualified name return -1; // wrong type name in qualified name
@ -2920,7 +2920,7 @@ QByteArray QMetaEnum::valueToKeys(int value) const
QByteArray keys; QByteArray keys;
if (!mobj) if (!mobj)
return keys; return keys;
QVarLengthArray<QLatin1String, sizeof(int) * CHAR_BIT> parts; QVarLengthArray<QLatin1StringView, sizeof(int) * CHAR_BIT> parts;
int v = value; int v = value;
// reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first. // reverse iterate to ensure values like Qt::Dialog=0x2|Qt::Window are processed first.
for (int i = data.keyCount() - 1; i >= 0; --i) { for (int i = data.keyCount() - 1; i >= 0; --i) {

View File

@ -871,7 +871,7 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
static const struct : QMetaTypeModuleHelper static const struct : QMetaTypeModuleHelper
{ {
template<typename T, typename LiteralWrapper = template<typename T, typename LiteralWrapper =
std::conditional_t<std::is_same_v<T, QString>, QLatin1String, const char *>> std::conditional_t<std::is_same_v<T, QString>, QLatin1StringView, const char *>>
static inline bool convertToBool(const T &source) static inline bool convertToBool(const T &source)
{ {
T str = source.toLower(); T str = source.toLower();

View File

@ -611,7 +611,7 @@ namespace QtPrivate {
inline QObject & deref_for_methodcall(QObject &o) { return o; } inline QObject & deref_for_methodcall(QObject &o) { return o; }
inline QObject & deref_for_methodcall(QObject *o) { return *o; } inline QObject & deref_for_methodcall(QObject *o) { return *o; }
} }
#define Q_SET_OBJECT_NAME(obj) QT_PREPEND_NAMESPACE(QtPrivate)::deref_for_methodcall(obj).setObjectName(QLatin1String(#obj)) #define Q_SET_OBJECT_NAME(obj) QT_PREPEND_NAMESPACE(QtPrivate)::deref_for_methodcall(obj).setObjectName(QLatin1StringView(#obj))
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -102,7 +102,7 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
(ch >= u'A' && ch <= u'Z')) (ch >= u'A' && ch <= u'Z'))
result += ch; result += ch;
} }
result.append(QLatin1String(hex)); result.append(QLatin1StringView(hex));
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
return result; return result;

View File

@ -53,7 +53,7 @@ QSharedMemoryPrivate::QSharedMemoryPrivate()
{ {
} }
void QSharedMemoryPrivate::setErrorString(QLatin1String function) void QSharedMemoryPrivate::setErrorString(QLatin1StringView function)
{ {
Q_UNUSED(function); Q_UNUSED(function);
Q_UNIMPLEMENTED(); Q_UNIMPLEMENTED();

View File

@ -155,7 +155,7 @@ public:
bool attach(QSharedMemory::AccessMode mode); bool attach(QSharedMemory::AccessMode mode);
bool detach(); bool detach();
void setErrorString(QLatin1String function); void setErrorString(QLatin1StringView function);
#ifndef QT_NO_SYSTEMSEMAPHORE #ifndef QT_NO_SYSTEMSEMAPHORE
bool tryLocker(QSharedMemoryLocker *locker, const QString &function) { bool tryLocker(QSharedMemoryLocker *locker, const QString &function) {

View File

@ -80,7 +80,7 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() :
{ {
} }
void QSharedMemoryPrivate::setErrorString(QLatin1String function) void QSharedMemoryPrivate::setErrorString(QLatin1StringView function)
{ {
// EINVAL is handled in functions so they can give better error strings // EINVAL is handled in functions so they can give better error strings
switch (errno) { switch (errno) {

View File

@ -58,7 +58,7 @@ QSharedMemoryPrivate::QSharedMemoryPrivate() :
{ {
} }
void QSharedMemoryPrivate::setErrorString(QLatin1String function) void QSharedMemoryPrivate::setErrorString(QLatin1StringView function)
{ {
DWORD windowsError = GetLastError(); DWORD windowsError = GetLastError();
if (windowsError == 0) if (windowsError == 0)

View File

@ -72,7 +72,7 @@ public:
QString makeKeyFileName() QString makeKeyFileName()
{ {
return QSharedMemoryPrivate::makePlatformSafeKey(key, QLatin1String("qipc_systemsem_")); return QSharedMemoryPrivate::makePlatformSafeKey(key, QLatin1StringView("qipc_systemsem_"));
} }
inline void setError(QSystemSemaphore::SystemSemaphoreError e, const QString &message) inline void setError(QSystemSemaphore::SystemSemaphoreError e, const QString &message)

View File

@ -549,7 +549,7 @@ QVariant::QVariant(const QVariant &p)
*/ */
/*! /*!
\fn QVariant::QVariant(QLatin1String val) \fn QVariant::QVariant(QLatin1StringView val)
Constructs a new variant with a string value, \a val. Constructs a new variant with a string value, \a val.
*/ */
@ -858,7 +858,7 @@ QVariant::QVariant(const QString &val)
QVariant::QVariant(QChar val) QVariant::QVariant(QChar val)
: d(QMetaType::fromType<QChar>()) : d(QMetaType::fromType<QChar>())
{ v_construct<QChar>(&d, val); } { v_construct<QChar>(&d, val); }
QVariant::QVariant(QLatin1String val) QVariant::QVariant(QLatin1StringView val)
: d(QMetaType::fromType<QString>()) : d(QMetaType::fromType<QString>())
{ v_construct<QString>(&d, val); } { v_construct<QString>(&d, val); }
QVariant::QVariant(const QStringList &val) QVariant::QVariant(const QStringList &val)

View File

@ -190,7 +190,7 @@ class Q_CORE_EXPORT QVariant
QVariant(const QByteArray &bytearray); QVariant(const QByteArray &bytearray);
QVariant(const QBitArray &bitarray); QVariant(const QBitArray &bitarray);
QVariant(const QString &string); QVariant(const QString &string);
QVariant(QLatin1String string); QVariant(QLatin1StringView string);
QVariant(const QStringList &stringlist); QVariant(const QStringList &stringlist);
QVariant(QChar qchar); QVariant(QChar qchar);
QVariant(QDate date); QVariant(QDate date);

View File

@ -263,7 +263,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (Q_UNLIKELY(!ok)) { if (Q_UNLIKELY(!ok)) {
m_type = Invalid; m_type = Invalid;
if (errorString) if (errorString)
*errorString = "Invalid magic rule value \""_L1 + QLatin1String(m_value) + u'"'; *errorString = "Invalid magic rule value \""_L1 + QLatin1StringView(m_value) + u'"';
return; return;
} }
m_numberMask = !m_mask.isEmpty() ? m_mask.toUInt(&ok, 0) : 0; // autodetect base m_numberMask = !m_mask.isEmpty() ? m_mask.toUInt(&ok, 0) : 0; // autodetect base
@ -277,7 +277,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (Q_UNLIKELY(m_mask.size() < 4 || !m_mask.startsWith("0x"))) { if (Q_UNLIKELY(m_mask.size() < 4 || !m_mask.startsWith("0x"))) {
m_type = Invalid; m_type = Invalid;
if (errorString) if (errorString)
*errorString = "Invalid magic rule mask \""_L1 + QLatin1String(m_mask) + u'"'; *errorString = "Invalid magic rule mask \""_L1 + QLatin1StringView(m_mask) + u'"';
return; return;
} }
const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData( const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(
@ -285,7 +285,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (Q_UNLIKELY(tempMask.size() != m_pattern.size())) { if (Q_UNLIKELY(tempMask.size() != m_pattern.size())) {
m_type = Invalid; m_type = Invalid;
if (errorString) if (errorString)
*errorString = "Invalid magic rule mask size \""_L1 + QLatin1String(m_mask) + u'"'; *errorString = "Invalid magic rule mask size \""_L1 + QLatin1StringView(m_mask) + u'"';
return; return;
} }
m_mask = tempMask; m_mask = tempMask;

View File

@ -275,14 +275,14 @@ void QMimeBinaryProvider::matchGlobList(QMimeGlobMatchResult &result, CacheFile
const int weight = flagsAndWeight & 0xff; const int weight = flagsAndWeight & 0xff;
const bool caseSensitive = flagsAndWeight & 0x100; const bool caseSensitive = flagsAndWeight & 0x100;
const Qt::CaseSensitivity qtCaseSensitive = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive; const Qt::CaseSensitivity qtCaseSensitive = caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive;
const QString pattern = QLatin1String(cacheFile->getCharStar(globOffset)); const QString pattern = QLatin1StringView(cacheFile->getCharStar(globOffset));
const char *mimeType = cacheFile->getCharStar(mimeTypeOffset); const char *mimeType = cacheFile->getCharStar(mimeTypeOffset);
//qDebug() << pattern << mimeType << weight << caseSensitive; //qDebug() << pattern << mimeType << weight << caseSensitive;
QMimeGlobPattern glob(pattern, QString() /*unused*/, weight, qtCaseSensitive); QMimeGlobPattern glob(pattern, QString() /*unused*/, weight, qtCaseSensitive);
if (glob.matchFileName(fileName)) if (glob.matchFileName(fileName))
result.addMatch(QLatin1String(mimeType), weight, pattern); result.addMatch(QLatin1StringView(mimeType), weight, pattern);
} }
} }
@ -318,7 +318,7 @@ bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBin
const int weight = flagsAndWeight & 0xff; const int weight = flagsAndWeight & 0xff;
const bool caseSensitive = flagsAndWeight & 0x100; const bool caseSensitive = flagsAndWeight & 0x100;
if (caseSensitiveCheck || !caseSensitive) { if (caseSensitiveCheck || !caseSensitive) {
result.addMatch(QLatin1String(mimeType), weight, result.addMatch(QLatin1StringView(mimeType), weight,
u'*' + QStringView{fileName}.mid(charPos + 1), u'*' + QStringView{fileName}.mid(charPos + 1),
fileName.size() - charPos - 2); fileName.size() - charPos - 2);
success = true; success = true;
@ -376,7 +376,7 @@ void QMimeBinaryProvider::findByMagic(const QByteArray &data, int *accuracyPtr,
*accuracyPtr = m_cacheFile->getUint32(off); *accuracyPtr = m_cacheFile->getUint32(off);
// Return the first match. We have no rules for conflicting magic data... // Return the first match. We have no rules for conflicting magic data...
// (mime.cache itself is sorted, but what about local overrides with a lower prio?) // (mime.cache itself is sorted, but what about local overrides with a lower prio?)
candidate = mimeTypeForNameUnchecked(QLatin1String(mimeType)); candidate = mimeTypeForNameUnchecked(QLatin1StringView(mimeType));
return; return;
} }
} }
@ -435,7 +435,7 @@ QString QMimeBinaryProvider::resolveAlias(const QString &name)
} else { } else {
const int mimeOffset = m_cacheFile->getUint32(off + 4); const int mimeOffset = m_cacheFile->getUint32(off + 4);
const char *mimeType = m_cacheFile->getCharStar(mimeOffset); const char *mimeType = m_cacheFile->getCharStar(mimeOffset);
return QLatin1String(mimeType); return QLatin1StringView(mimeType);
} }
} }
return QString(); return QString();
@ -577,7 +577,8 @@ bool QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
} }
// Binary search in the icons or generic-icons list // Binary search in the icons or generic-icons list
QLatin1String QMimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime) QLatin1StringView QMimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posListOffset,
const QByteArray &inputMime)
{ {
const int iconsListOffset = cacheFile->getUint32(posListOffset); const int iconsListOffset = cacheFile->getUint32(posListOffset);
const int numIcons = cacheFile->getUint32(iconsListOffset); const int numIcons = cacheFile->getUint32(iconsListOffset);
@ -595,16 +596,16 @@ QLatin1String QMimeBinaryProvider::iconForMime(CacheFile *cacheFile, int posList
end = medium - 1; end = medium - 1;
else { else {
const int iconOffset = cacheFile->getUint32(off + 4); const int iconOffset = cacheFile->getUint32(off + 4);
return QLatin1String(cacheFile->getCharStar(iconOffset)); return QLatin1StringView(cacheFile->getCharStar(iconOffset));
} }
} }
return QLatin1String(); return QLatin1StringView();
} }
void QMimeBinaryProvider::loadIcon(QMimeTypePrivate &data) void QMimeBinaryProvider::loadIcon(QMimeTypePrivate &data)
{ {
const QByteArray inputMime = data.name.toLatin1(); const QByteArray inputMime = data.name.toLatin1();
const QLatin1String icon = iconForMime(m_cacheFile, PosIconsListOffset, inputMime); const QLatin1StringView icon = iconForMime(m_cacheFile, PosIconsListOffset, inputMime);
if (!icon.isEmpty()) { if (!icon.isEmpty()) {
data.iconName = icon; data.iconName = icon;
} }
@ -613,7 +614,7 @@ void QMimeBinaryProvider::loadIcon(QMimeTypePrivate &data)
void QMimeBinaryProvider::loadGenericIcon(QMimeTypePrivate &data) void QMimeBinaryProvider::loadGenericIcon(QMimeTypePrivate &data)
{ {
const QByteArray inputMime = data.name.toLatin1(); const QByteArray inputMime = data.name.toLatin1();
const QLatin1String icon = iconForMime(m_cacheFile, PosGenericIconsListOffset, inputMime); const QLatin1StringView icon = iconForMime(m_cacheFile, PosGenericIconsListOffset, inputMime);
if (!icon.isEmpty()) { if (!icon.isEmpty()) {
data.genericIconName = icon; data.genericIconName = icon;
} }

View File

@ -120,7 +120,7 @@ private:
void matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int offset, const QString &fileName); void matchGlobList(QMimeGlobMatchResult &result, CacheFile *cacheFile, int offset, const QString &fileName);
bool matchSuffixTree(QMimeGlobMatchResult &result, CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, int charPos, bool caseSensitiveCheck); bool matchSuffixTree(QMimeGlobMatchResult &result, CacheFile *cacheFile, int numEntries, int firstOffset, const QString &fileName, int charPos, bool caseSensitiveCheck);
bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data); bool matchMagicRule(CacheFile *cacheFile, int numMatchlets, int firstOffset, const QByteArray &data);
QLatin1String iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime); QLatin1StringView iconForMime(CacheFile *cacheFile, int posListOffset, const QByteArray &inputMime);
void loadMimeTypeList(); void loadMimeTypeList();
bool checkCacheChanged(); bool checkCacheChanged();

View File

@ -114,13 +114,13 @@ QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState curren
{ {
switch (currentState) { switch (currentState) {
case ParseBeginning: case ParseBeginning:
if (startElement == QLatin1String(mimeInfoTagC)) if (startElement == QLatin1StringView(mimeInfoTagC))
return ParseMimeInfo; return ParseMimeInfo;
if (startElement == QLatin1String(mimeTypeTagC)) if (startElement == QLatin1StringView(mimeTypeTagC))
return ParseMimeType; return ParseMimeType;
return ParseError; return ParseError;
case ParseMimeInfo: case ParseMimeInfo:
return startElement == QLatin1String(mimeTypeTagC) ? ParseMimeType : ParseError; return startElement == QLatin1StringView(mimeTypeTagC) ? ParseMimeType : ParseError;
case ParseMimeType: case ParseMimeType:
case ParseComment: case ParseComment:
case ParseGenericIcon: case ParseGenericIcon:
@ -131,29 +131,29 @@ QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState curren
case ParseAlias: case ParseAlias:
case ParseOtherMimeTypeSubTag: case ParseOtherMimeTypeSubTag:
case ParseMagicMatchRule: case ParseMagicMatchRule:
if (startElement == QLatin1String(mimeTypeTagC)) // Sequence of <mime-type> if (startElement == QLatin1StringView(mimeTypeTagC)) // Sequence of <mime-type>
return ParseMimeType; return ParseMimeType;
if (startElement == QLatin1String(commentTagC)) if (startElement == QLatin1StringView(commentTagC))
return ParseComment; return ParseComment;
if (startElement == QLatin1String(genericIconTagC)) if (startElement == QLatin1StringView(genericIconTagC))
return ParseGenericIcon; return ParseGenericIcon;
if (startElement == QLatin1String(iconTagC)) if (startElement == QLatin1StringView(iconTagC))
return ParseIcon; return ParseIcon;
if (startElement == QLatin1String(globTagC)) if (startElement == QLatin1StringView(globTagC))
return ParseGlobPattern; return ParseGlobPattern;
if (startElement == QLatin1String(globDeleteAllTagC)) if (startElement == QLatin1StringView(globDeleteAllTagC))
return ParseGlobDeleteAll; return ParseGlobDeleteAll;
if (startElement == QLatin1String(subClassTagC)) if (startElement == QLatin1StringView(subClassTagC))
return ParseSubClass; return ParseSubClass;
if (startElement == QLatin1String(aliasTagC)) if (startElement == QLatin1StringView(aliasTagC))
return ParseAlias; return ParseAlias;
if (startElement == QLatin1String(magicTagC)) if (startElement == QLatin1StringView(magicTagC))
return ParseMagic; return ParseMagic;
if (startElement == QLatin1String(matchTagC)) if (startElement == QLatin1StringView(matchTagC))
return ParseMagicMatchRule; return ParseMagicMatchRule;
return ParseOtherMimeTypeSubTag; return ParseOtherMimeTypeSubTag;
case ParseMagic: case ParseMagic:
if (startElement == QLatin1String(matchTagC)) if (startElement == QLatin1StringView(matchTagC))
return ParseMagicMatchRule; return ParseMagicMatchRule;
break; break;
case ParseError: case ParseError:
@ -190,10 +190,10 @@ struct CreateMagicMatchRuleResult
static CreateMagicMatchRuleResult createMagicMatchRule(const QXmlStreamAttributes &atts) static CreateMagicMatchRuleResult createMagicMatchRule(const QXmlStreamAttributes &atts)
{ {
const auto type = atts.value(QLatin1String(matchTypeAttributeC)); const auto type = atts.value(QLatin1StringView(matchTypeAttributeC));
const auto value = atts.value(QLatin1String(matchValueAttributeC)); const auto value = atts.value(QLatin1StringView(matchValueAttributeC));
const auto offsets = atts.value(QLatin1String(matchOffsetAttributeC)); const auto offsets = atts.value(QLatin1StringView(matchOffsetAttributeC));
const auto mask = atts.value(QLatin1String(matchMaskAttributeC)); const auto mask = atts.value(QLatin1StringView(matchMaskAttributeC));
return CreateMagicMatchRuleResult(type, value, offsets, mask); return CreateMagicMatchRuleResult(type, value, offsets, mask);
} }
#endif #endif
@ -220,7 +220,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
const QXmlStreamAttributes atts = reader.attributes(); const QXmlStreamAttributes atts = reader.attributes();
switch (ps) { switch (ps) {
case ParseMimeType: { // start parsing a MIME type name case ParseMimeType: { // start parsing a MIME type name
const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString(); const QString name = atts.value(QLatin1StringView(mimeTypeAttributeC)).toString();
if (name.isEmpty()) { if (name.isEmpty()) {
reader.raiseError(QStringLiteral("Missing 'type'-attribute")); reader.raiseError(QStringLiteral("Missing 'type'-attribute"));
} else { } else {
@ -229,15 +229,15 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
} }
break; break;
case ParseGenericIcon: case ParseGenericIcon:
data.genericIconName = atts.value(QLatin1String(nameAttributeC)).toString(); data.genericIconName = atts.value(QLatin1StringView(nameAttributeC)).toString();
break; break;
case ParseIcon: case ParseIcon:
data.iconName = atts.value(QLatin1String(nameAttributeC)).toString(); data.iconName = atts.value(QLatin1StringView(nameAttributeC)).toString();
break; break;
case ParseGlobPattern: { case ParseGlobPattern: {
const QString pattern = atts.value(QLatin1String(patternAttributeC)).toString(); const QString pattern = atts.value(QLatin1StringView(patternAttributeC)).toString();
unsigned weight = atts.value(QLatin1String(weightAttributeC)).toInt(); unsigned weight = atts.value(QLatin1StringView(weightAttributeC)).toInt();
const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)) == "true"_L1; const bool caseSensitive = atts.value(QLatin1StringView(caseSensitiveAttributeC)) == "true"_L1;
if (weight == 0) if (weight == 0)
weight = QMimeGlobPattern::DefaultWeight; weight = QMimeGlobPattern::DefaultWeight;
@ -253,14 +253,14 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
data.globPatterns.clear(); data.globPatterns.clear();
break; break;
case ParseSubClass: { case ParseSubClass: {
const QString inheritsFrom = atts.value(QLatin1String(mimeTypeAttributeC)).toString(); const QString inheritsFrom = atts.value(QLatin1StringView(mimeTypeAttributeC)).toString();
if (!inheritsFrom.isEmpty()) if (!inheritsFrom.isEmpty())
processParent(data.name, inheritsFrom); processParent(data.name, inheritsFrom);
} }
break; break;
case ParseComment: { case ParseComment: {
// comments have locale attributes. // comments have locale attributes.
QString locale = atts.value(QLatin1String(localeAttributeC)).toString(); QString locale = atts.value(QLatin1StringView(localeAttributeC)).toString();
const QString comment = reader.readElementText(); const QString comment = reader.readElementText();
if (locale.isEmpty()) if (locale.isEmpty())
locale = QString::fromLatin1("default"); locale = QString::fromLatin1("default");
@ -268,14 +268,14 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
} }
break; break;
case ParseAlias: { case ParseAlias: {
const QString alias = atts.value(QLatin1String(mimeTypeAttributeC)).toString(); const QString alias = atts.value(QLatin1StringView(mimeTypeAttributeC)).toString();
if (!alias.isEmpty()) if (!alias.isEmpty())
processAlias(alias, data.name); processAlias(alias, data.name);
} }
break; break;
case ParseMagic: { case ParseMagic: {
priority = 50; priority = 50;
const auto priorityS = atts.value(QLatin1String(priorityAttributeC)); const auto priorityS = atts.value(QLatin1StringView(priorityAttributeC));
if (!priorityS.isEmpty()) { if (!priorityS.isEmpty()) {
if (!parseNumber(priorityS, &priority, errorMessage)) if (!parseNumber(priorityS, &priority, errorMessage))
return false; return false;
@ -312,15 +312,15 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
case QXmlStreamReader::EndElement: // Finished element case QXmlStreamReader::EndElement: // Finished element
{ {
const auto elementName = reader.name(); const auto elementName = reader.name();
if (elementName == QLatin1String(mimeTypeTagC)) { if (elementName == QLatin1StringView(mimeTypeTagC)) {
if (!process(QMimeType(data), errorMessage)) if (!process(QMimeType(data), errorMessage))
return false; return false;
data.clear(); data.clear();
} else if (elementName == QLatin1String(matchTagC)) { } else if (elementName == QLatin1StringView(matchTagC)) {
// Closing a <match> tag, pop stack // Closing a <match> tag, pop stack
currentRules.pop(); currentRules.pop();
//qDebug() << " MATCH closed. Stack size is now" << currentRules.size(); //qDebug() << " MATCH closed. Stack size is now" << currentRules.size();
} else if (elementName == QLatin1String(magicTagC)) { } else if (elementName == QLatin1StringView(magicTagC)) {
//qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority; //qDebug() << "MAGIC ended, we got" << rules.count() << "rules, with prio" << priority;
// Finished a <magic> sequence // Finished a <magic> sequence
QMimeMagicRuleMatcher ruleMatcher(data.name, priority); QMimeMagicRuleMatcher ruleMatcher(data.name, priority);

View File

@ -56,7 +56,7 @@ using namespace Qt::StringLiterals;
static constexpr bool IncludeValidityChecks = true; static constexpr bool IncludeValidityChecks = true;
static constexpr inline auto metadataSectionName() noexcept { return ".qtmetadata"_L1; } static constexpr inline auto metadataSectionName() noexcept { return ".qtmetadata"_L1; }
static constexpr QLatin1String truncatedSectionName = static constexpr QLatin1StringView truncatedSectionName =
metadataSectionName().left(sizeof(IMAGE_SECTION_HEADER::Name)); metadataSectionName().left(sizeof(IMAGE_SECTION_HEADER::Name));
#ifdef QT_BUILD_INTERNAL #ifdef QT_BUILD_INTERNAL
@ -328,7 +328,7 @@ findStringTable(QByteArrayView data, const IMAGE_NT_HEADERS *ntHeader, const Err
return data.sliced(off, size); return data.sliced(off, size);
} }
static QLatin1String findSectionName(const IMAGE_SECTION_HEADER *section, QByteArrayView stringTable) static QLatin1StringView findSectionName(const IMAGE_SECTION_HEADER *section, QByteArrayView stringTable)
{ {
auto ptr = reinterpret_cast<const char *>(section->Name); auto ptr = reinterpret_cast<const char *>(section->Name);
qsizetype n = qstrnlen(ptr, sizeof(section->Name)); qsizetype n = qstrnlen(ptr, sizeof(section->Name));
@ -344,13 +344,13 @@ static QLatin1String findSectionName(const IMAGE_SECTION_HEADER *section, QByteA
bool ok; bool ok;
qsizetype offset = QByteArrayView(ptr + 1, n - 1).toUInt(&ok); qsizetype offset = QByteArrayView(ptr + 1, n - 1).toUInt(&ok);
if (!ok || offset >= stringTable.size()) if (!ok || offset >= stringTable.size())
return QLatin1String(); return {};
ptr = stringTable.data() + offset; ptr = stringTable.data() + offset;
n = qstrnlen(ptr, stringTable.size() - offset); n = qstrnlen(ptr, stringTable.size() - offset);
} }
return QLatin1String(ptr, n); return QLatin1StringView(ptr, n);
} }
QLibraryScanResult QCoffPeParser::parse(QByteArrayView data, QString *errMsg) QLibraryScanResult QCoffPeParser::parse(QByteArrayView data, QString *errMsg)
@ -373,7 +373,7 @@ QLibraryScanResult QCoffPeParser::parse(QByteArrayView data, QString *errMsg)
// scan the sections now // scan the sections now
const auto sectionTableEnd = section + ntHeaders->FileHeader.NumberOfSections; const auto sectionTableEnd = section + ntHeaders->FileHeader.NumberOfSections;
for ( ; section < sectionTableEnd; ++section) { for ( ; section < sectionTableEnd; ++section) {
QLatin1String sectionName = findSectionName(section, stringTable); QLatin1StringView sectionName = findSectionName(section, stringTable);
peDebug << "section" << sectionName << SectionDebug{section}; peDebug << "section" << sectionName << SectionDebug{section};
if (IncludeValidityChecks && sectionName.isEmpty()) if (IncludeValidityChecks && sectionName.isEmpty())
return error(QLibrary::tr("a section name is empty or extends past the end of the file")); return error(QLibrary::tr("a section name is empty or extends past the end of the file"));

View File

@ -698,11 +698,11 @@ static QLibraryScanResult scanSections(QByteArrayView data, const ErrorMaker &er
const char *shstrtab_start = data.data() + offset; const char *shstrtab_start = data.data() + offset;
shdr = sections; shdr = sections;
for (int section = 0; shdr != sections_end; ++section, ++shdr) { for (int section = 0; shdr != sections_end; ++section, ++shdr) {
QLatin1String name; QLatin1StringView name;
if (shdr->sh_name < shstrtab_size) { if (shdr->sh_name < shstrtab_size) {
const char *namestart = shstrtab_start + shdr->sh_name; const char *namestart = shstrtab_start + shdr->sh_name;
size_t len = qstrnlen(namestart, shstrtab_size - shdr->sh_name); size_t len = qstrnlen(namestart, shstrtab_size - shdr->sh_name);
name = QLatin1String(namestart, len); name = QLatin1StringView(namestart, len);
} }
qEDebug << "section" << section << "name" << name << ElfSectionDebug{shdr}; qEDebug << "section" << section << "name" << name << ElfSectionDebug{shdr};

View File

@ -230,7 +230,7 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
bool metaDataOk = false; bool metaDataOk = false;
QString iid = library->metaData.value(QtPluginMetaDataKeys::IID).toString(); QString iid = library->metaData.value(QtPluginMetaDataKeys::IID).toString();
if (iid == QLatin1String(this->iid.constData(), this->iid.size())) { if (iid == QLatin1StringView(this->iid.constData(), this->iid.size())) {
QCborMap object = library->metaData.value(QtPluginMetaDataKeys::MetaData).toMap(); QCborMap object = library->metaData.value(QtPluginMetaDataKeys::MetaData).toMap();
metaDataOk = true; metaDataOk = true;
@ -381,7 +381,7 @@ QFactoryLoader::MetaDataList QFactoryLoader::metaData() const
metaData.append(library->metaData); metaData.append(library->metaData);
#endif #endif
QLatin1String iid(d->iid.constData(), d->iid.size()); QLatin1StringView iid(d->iid.constData(), d->iid.size());
const auto staticPlugins = QPluginLoader::staticPlugins(); const auto staticPlugins = QPluginLoader::staticPlugins();
for (const QStaticPlugin &plugin : staticPlugins) { for (const QStaticPlugin &plugin : staticPlugins) {
QByteArrayView pluginData(static_cast<const char *>(plugin.rawMetaData), plugin.rawMetaDataSize); QByteArrayView pluginData(static_cast<const char *>(plugin.rawMetaData), plugin.rawMetaDataSize);
@ -414,7 +414,7 @@ QObject *QFactoryLoader::instance(int index) const
lock.unlock(); lock.unlock();
#endif #endif
QLatin1String iid(d->iid.constData(), d->iid.size()); QLatin1StringView iid(d->iid.constData(), d->iid.size());
const QList<QStaticPlugin> staticPlugins = QPluginLoader::staticPlugins(); const QList<QStaticPlugin> staticPlugins = QPluginLoader::staticPlugins();
for (QStaticPlugin plugin : staticPlugins) { for (QStaticPlugin plugin : staticPlugins) {
QByteArrayView pluginData(static_cast<const char *>(plugin.rawMetaData), plugin.rawMetaDataSize); QByteArrayView pluginData(static_cast<const char *>(plugin.rawMetaData), plugin.rawMetaDataSize);

View File

@ -642,7 +642,7 @@ bool QLibrary::isLibrary(const QString &fileName)
return false; return false;
// if this throws an empty-array error, you need to fix the #ifdef's: // if this throws an empty-array error, you need to fix the #ifdef's:
const QLatin1String candidates[] = { const QLatin1StringView candidates[] = {
# if defined(Q_OS_HPUX) # if defined(Q_OS_HPUX)
/* /*
See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF": See "HP-UX Linker and Libraries User's Guide", section "Link-time Differences between PA-RISC and IPF":

View File

@ -299,7 +299,7 @@ bool QLibraryPrivate::unload_sys()
if (!qstrcmp(error, "Shared objects still referenced")) // On QNX that's only "informative" if (!qstrcmp(error, "Shared objects still referenced")) // On QNX that's only "informative"
return true; return true;
errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName, errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName,
QLatin1String(error)); QLatin1StringView(error));
#else #else
errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName, qdlerror()); errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName, qdlerror());
#endif #endif

View File

@ -102,7 +102,7 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
searchOrder << qSystemDirectory(); searchOrder << qSystemDirectory();
if (!onlySystemDirectory) { if (!onlySystemDirectory) {
const QString PATH(QLatin1String(qgetenv("PATH").constData())); const QString PATH(QLatin1StringView(qgetenv("PATH")));
searchOrder << PATH.split(u';', Qt::SkipEmptyParts); searchOrder << PATH.split(u';', Qt::SkipEmptyParts);
} }
QString fileName = QString::fromWCharArray(libraryName); QString fileName = QString::fromWCharArray(libraryName);

View File

@ -395,7 +395,7 @@ static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCrypto
public data members in QUuid. public data members in QUuid.
\note In Qt versions prior to 6.3, this function was an overload \note In Qt versions prior to 6.3, this function was an overload
set consisting of QStringView and QLatin1String instead of set consisting of QStringView and QLatin1StringView instead of
one function taking QAnyStringView. one function taking QAnyStringView.
\sa toString(), QUuid() \sa toString(), QUuid()
@ -416,13 +416,13 @@ static QUuid uuidFromString(QStringView text) noexcept
return _q_uuidFromHex(latin1); return _q_uuidFromHex(latin1);
} }
static QUuid uuidFromString(QLatin1String text) noexcept static QUuid uuidFromString(QLatin1StringView text) noexcept
{ {
if (Q_UNLIKELY(text.size() < MaxStringUuidLength - 2 if (Q_UNLIKELY(text.size() < MaxStringUuidLength - 2
|| (text.front() == '{' && text.size() < MaxStringUuidLength - 1))) { || (text.front() == '{' && text.size() < MaxStringUuidLength - 1))) {
// Too short. Don't call _q_uuidFromHex(); QL1Ss need not be NUL-terminated, // Too short. Don't call _q_uuidFromHex(); QL1Ss need not be NUL-terminated,
// and we don't want to read trailing garbage as potentially valid data. // and we don't want to read trailing garbage as potentially valid data.
text = QLatin1String(); text = QLatin1StringView();
} }
return _q_uuidFromHex(text.data()); return _q_uuidFromHex(text.data());
} }
@ -431,7 +431,7 @@ Q_ALWAYS_INLINE
// can treat UTF-8 the same as Latin-1: // can treat UTF-8 the same as Latin-1:
static QUuid uuidFromString(QUtf8StringView text) noexcept static QUuid uuidFromString(QUtf8StringView text) noexcept
{ {
return uuidFromString(QLatin1String(text.data(), text.size())); return uuidFromString(QLatin1StringView(text.data(), text.size()));
} }
QUuid QUuid::fromString(QAnyStringView text) noexcept QUuid QUuid::fromString(QAnyStringView text) noexcept

View File

@ -103,7 +103,7 @@ public:
#if QT_CORE_REMOVED_SINCE(6, 3) #if QT_CORE_REMOVED_SINCE(6, 3)
explicit QUuid(const QString &); explicit QUuid(const QString &);
static QUuid fromString(QStringView string) noexcept; static QUuid fromString(QStringView string) noexcept;
static QUuid fromString(QLatin1String string) noexcept; static QUuid fromString(QLatin1StringView string) noexcept;
explicit QUuid(const char *); explicit QUuid(const char *);
explicit QUuid(const QByteArray &); explicit QUuid(const QByteArray &);
#endif #endif

View File

@ -77,7 +77,7 @@ private:
++dn->nestingLevel; ++dn->nestingLevel;
static const char indent[IndentationWidth + 1] = " "; static const char indent[IndentationWidth + 1] = " ";
if (dn->opts & QCborValue::LineWrapped) if (dn->opts & QCborValue::LineWrapped)
dn->separator += QLatin1String(indent, IndentationWidth); dn->separator += QLatin1StringView(indent, IndentationWidth);
} }
~Nest() ~Nest()
{ {
@ -213,10 +213,10 @@ void DiagnosticNotation::appendArray(const QCborArray &a)
result += u'['; result += u'[';
// length 2 (including the space) when not line wrapping // length 2 (including the space) when not line wrapping
QLatin1String commaValue(", ", opts & QCborValue::LineWrapped ? 1 : 2); QLatin1StringView commaValue(", ", opts & QCborValue::LineWrapped ? 1 : 2);
{ {
Nest n(this); Nest n(this);
QLatin1String comma; QLatin1StringView comma;
for (auto v : a) { for (auto v : a) {
result += comma + separator; result += comma + separator;
comma = commaValue; comma = commaValue;
@ -232,10 +232,10 @@ void DiagnosticNotation::appendMap(const QCborMap &m)
result += u'{'; result += u'{';
// length 2 (including the space) when not line wrapping // length 2 (including the space) when not line wrapping
QLatin1String commaValue(", ", opts & QCborValue::LineWrapped ? 1 : 2); QLatin1StringView commaValue(", ", opts & QCborValue::LineWrapped ? 1 : 2);
{ {
Nest n(this); Nest n(this);
QLatin1String comma; QLatin1StringView comma;
for (auto v : m) { for (auto v : m) {
result += comma + separator; result += comma + separator;
comma = commaValue; comma = commaValue;

View File

@ -328,7 +328,7 @@ QList<QCborValue> QCborMap::keys() const
duplicate keys is usually an indication of a problem in the sender. duplicate keys is usually an indication of a problem in the sender.
\sa operator[](qint64), find(qint64), constFind(qint64), remove(qint64), contains(qint64) \sa operator[](qint64), find(qint64), constFind(qint64), remove(qint64), contains(qint64)
value(QLatin1String), value(const QString &), value(const QCborValue &) value(QLatin1StringView), value(const QString &), value(const QCborValue &)
*/ */
/*! /*!
@ -350,7 +350,8 @@ QList<QCborValue> QCborMap::keys() const
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(qint64), find(qint64), constFind(qint64), remove(qint64), contains(qint64) \sa value(qint64), find(qint64), constFind(qint64), remove(qint64), contains(qint64)
operator[](QLatin1String), operator[](const QString &), operator[](const QCborOperator[] &) operator[](QLatin1StringView), operator[](const QString &),
operator[](const QCborOperator[] &)
*/ */
/*! /*!
@ -366,7 +367,7 @@ QList<QCborValue> QCborMap::keys() const
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(qint64), operator[](qint64), find(qint64), contains(qint64), \sa value(qint64), operator[](qint64), find(qint64), contains(qint64),
take(QLatin1String), take(const QString &), take(const QCborValue &), insert() take(QLatin1StringView), take(const QString &), take(const QCborValue &), insert()
*/ */
/*! /*!
@ -382,7 +383,7 @@ QList<QCborValue> QCborMap::keys() const
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(qint64), operator[](qint64), find(qint64), contains(qint64) \sa value(qint64), operator[](qint64), find(qint64), contains(qint64)
remove(QLatin1String), remove(const QString &), remove(const QCborValue &) remove(QLatin1StringView), remove(const QString &), remove(const QCborValue &)
*/ */
/*! /*!
@ -393,7 +394,7 @@ QList<QCborValue> QCborMap::keys() const
are simpler to encode and decode. are simpler to encode and decode.
\sa value(qint64), operator[](qint64), find(qint64), remove(qint64), \sa value(qint64), operator[](qint64), find(qint64), remove(qint64),
contains(QLatin1String), remove(const QString &), remove(const QCborValue &) contains(QLatin1StringView), remove(const QString &), remove(const QCborValue &)
*/ */
/*! /*!
@ -418,7 +419,7 @@ QList<QCborValue> QCborMap::keys() const
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(qint64), find(qint64), contains(qint64), remove(qint64), \sa value(qint64), find(qint64), contains(qint64), remove(qint64),
operator[](QLatin1String), operator[](const QString &), operator[](const QCborValue &) operator[](QLatin1StringView), operator[](const QString &), operator[](const QCborValue &)
*/ */
QCborValueRef QCborMap::operator[](qint64 key) QCborValueRef QCborMap::operator[](qint64 key)
{ {
@ -426,7 +427,7 @@ QCborValueRef QCborMap::operator[](qint64 key)
} }
/*! /*!
\fn QCborValue QCborMap::value(QLatin1String key) const \fn QCborValue QCborMap::value(QLatin1StringView key) const
\overload \overload
Returns the QCborValue element in this map that corresponds to key \a key, Returns the QCborValue element in this map that corresponds to key \a key,
@ -443,13 +444,13 @@ QCborValueRef QCborMap::operator[](qint64 key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa operator[](QLatin1String), find(QLatin1String), constFind(QLatin1String), \sa operator[](QLatin1StringView), find(QLatin1StringView), constFind(QLatin1StringView),
remove(QLatin1String), contains(QLatin1String) remove(QLatin1StringView), contains(QLatin1StringView)
value(qint64), value(const QString &), value(const QCborValue &) value(qint64), value(const QString &), value(const QCborValue &)
*/ */
/*! /*!
\fn QCborValue QCborMap::operator[](QLatin1String key) const \fn QCborValue QCborMap::operator[](QLatin1StringView key) const
\overload \overload
Returns the QCborValue element in this map that corresponds to key \a key, Returns the QCborValue element in this map that corresponds to key \a key,
@ -466,13 +467,13 @@ QCborValueRef QCborMap::operator[](qint64 key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(QLatin1String), find(QLatin1String), constFind(QLatin1String), \sa value(QLatin1StringView), find(QLatin1StringView), constFind(QLatin1StringView),
remove(QLatin1String), contains(QLatin1String) remove(QLatin1StringView), contains(QLatin1StringView)
operator[](qint64), operator[](const QString &), operator[](const QCborOperator[] &) operator[](qint64), operator[](const QString &), operator[](const QCborOperator[] &)
*/ */
/*! /*!
\fn QCborValue QCborMap::take(QLatin1String key) \fn QCborValue QCborMap::take(QLatin1StringView key)
Removes the key \a key and the corresponding value from the map and returns Removes the key \a key and the corresponding value from the map and returns
the value, if it is found. If the map contains no such key, this function does nothing. the value, if it is found. If the map contains no such key, this function does nothing.
@ -483,12 +484,13 @@ QCborValueRef QCborMap::operator[](qint64 key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(QLatin1String), operator[](QLatin1String), find(QLatin1String), contains(QLatin1String), \sa value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView),
take(qint64), take(const QString &), take(const QCborValue &), insert() contains(QLatin1StringView), take(qint64), take(const QString &),
take(const QCborValue &), insert()
*/ */
/*! /*!
\fn void QCborMap::remove(QLatin1String key) \fn void QCborMap::remove(QLatin1StringView key)
\overload \overload
Removes the key \a key and the corresponding value from the map, if it is Removes the key \a key and the corresponding value from the map, if it is
@ -500,19 +502,21 @@ QCborValueRef QCborMap::operator[](qint64 key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(QLatin1String), operator[](QLatin1String), find(QLatin1String), contains(QLatin1String) \sa value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView),
remove(qint64), remove(const QString &), remove(const QCborValue &) contains(QLatin1StringView), remove(qint64), remove(const QString &),
remove(const QCborValue &)
*/ */
/*! /*!
\fn bool QCborMap::contains(QLatin1String key) const \fn bool QCborMap::contains(QLatin1StringView key) const
\overload \overload
Returns true if this map contains a key-value pair identified by key \a Returns true if this map contains a key-value pair identified by key \a
key. key.
\sa value(QLatin1String), operator[](QLatin1String), find(QLatin1String), remove(QLatin1String), \sa value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView),
contains(qint64), remove(const QString &), remove(const QCborValue &) remove(QLatin1StringView), contains(qint64), remove(const QString &),
remove(const QCborValue &)
*/ */
/*! /*!
@ -537,10 +541,11 @@ QCborValueRef QCborMap::operator[](qint64 key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(QLatin1String), find(QLatin1String), contains(QLatin1String), remove(QLatin1String), \sa value(QLatin1StringView), find(QLatin1StringView), contains(QLatin1StringView),
operator[](qint64), operator[](const QString &), operator[](const QCborValue &) remove(QLatin1StringView), operator[](qint64), operator[](const QString &),
operator[](const QCborValue &)
*/ */
QCborValueRef QCborMap::operator[](QLatin1String key) QCborValueRef QCborMap::operator[](QLatin1StringView key)
{ {
return QCborContainerPrivate::findOrAddMapKey(*this, key); return QCborContainerPrivate::findOrAddMapKey(*this, key);
} }
@ -565,7 +570,7 @@ QCborValueRef QCborMap::operator[](QLatin1String key)
\sa operator[](const QString &), find(const QString &), constFind(const QString &), \sa operator[](const QString &), find(const QString &), constFind(const QString &),
remove(const QString &), contains(const QString &) remove(const QString &), contains(const QString &)
value(qint64), value(QLatin1String), value(const QCborValue &) value(qint64), value(QLatin1StringView), value(const QCborValue &)
*/ */
/*! /*!
@ -588,7 +593,7 @@ QCborValueRef QCborMap::operator[](QLatin1String key)
\sa value(const QString &), find(const QString &), constFind(const QString &), \sa value(const QString &), find(const QString &), constFind(const QString &),
remove(const QString &), contains(const QString &) remove(const QString &), contains(const QString &)
operator[](qint64), operator[](QLatin1String), operator[](const QCborOperator[] &) operator[](qint64), operator[](QLatin1StringView), operator[](const QCborOperator[] &)
*/ */
/*! /*!
@ -603,8 +608,9 @@ QCborValueRef QCborMap::operator[](QLatin1String key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(const QString &), operator[](const QString &), find(const QString &), contains(const QString &), \sa value(const QString &), operator[](const QString &), find(const QString &),
take(QLatin1String), take(qint64), take(const QCborValue &), insert() contains(const QString &), take(QLatin1StringView), take(qint64),
take(const QCborValue &), insert()
*/ */
/*! /*!
@ -622,7 +628,7 @@ QCborValueRef QCborMap::operator[](QLatin1String key)
\sa value(const QString &), operator[](const QString &), find(const QString &), \sa value(const QString &), operator[](const QString &), find(const QString &),
contains(const QString &) contains(const QString &)
remove(qint64), remove(QLatin1String), remove(const QCborValue &) remove(qint64), remove(QLatin1StringView), remove(const QCborValue &)
*/ */
/*! /*!
@ -634,7 +640,7 @@ QCborValueRef QCborMap::operator[](QLatin1String key)
\sa value(const QString &), operator[](const QString &), find(const QString &), \sa value(const QString &), operator[](const QString &), find(const QString &),
remove(const QString &), remove(const QString &),
contains(qint64), remove(QLatin1String), remove(const QCborValue &) contains(qint64), remove(QLatin1StringView), remove(const QCborValue &)
*/ */
/*! /*!
@ -659,8 +665,9 @@ QCborValueRef QCborMap::operator[](QLatin1String key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(const QString &), find(const QString &), contains(const QString &), remove(const QString &), \sa value(const QString &), find(const QString &), contains(const QString &),
operator[](qint64), operator[](QLatin1String), operator[](const QCborValue &) remove(const QString &), operator[](qint64), operator[](QLatin1StringView),
operator[](const QCborValue &)
*/ */
QCborValueRef QCborMap::operator[](const QString & key) QCborValueRef QCborMap::operator[](const QString & key)
{ {
@ -686,7 +693,7 @@ QCborValueRef QCborMap::operator[](const QString & key)
\sa operator[](const QCborValue &), find(const QCborValue &), constFind(const QCborValue &), \sa operator[](const QCborValue &), find(const QCborValue &), constFind(const QCborValue &),
remove(const QCborValue &), contains(const QCborValue &) remove(const QCborValue &), contains(const QCborValue &)
value(qint64), value(QLatin1String), value(const QString &) value(qint64), value(QLatin1StringView), value(const QString &)
*/ */
/*! /*!
@ -708,7 +715,7 @@ QCborValueRef QCborMap::operator[](const QString & key)
\sa value(const QCborValue &), find(const QCborValue &), constFind(const QCborValue &), \sa value(const QCborValue &), find(const QCborValue &), constFind(const QCborValue &),
remove(const QCborValue &), contains(const QCborValue &) remove(const QCborValue &), contains(const QCborValue &)
operator[](qint64), operator[](QLatin1String), operator[](const QCborOperator[] &) operator[](qint64), operator[](QLatin1StringView), operator[](const QCborOperator[] &)
*/ */
/*! /*!
@ -723,8 +730,9 @@ QCborValueRef QCborMap::operator[](const QString & key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), contains(const QCborValue &), \sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &),
take(QLatin1String), take(const QString &), take(qint64), insert() contains(const QCborValue &), take(QLatin1StringView), take(const QString &),
take(qint64), insert()
*/ */
/*! /*!
@ -741,7 +749,7 @@ QCborValueRef QCborMap::operator[](const QString & key)
\sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), \sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &),
contains(const QCborValue &) contains(const QCborValue &)
remove(qint64), remove(QLatin1String), remove(const QString &) remove(qint64), remove(QLatin1StringView), remove(const QString &)
*/ */
/*! /*!
@ -752,7 +760,7 @@ QCborValueRef QCborMap::operator[](const QString & key)
\sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), \sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &),
remove(const QCborValue &), remove(const QCborValue &),
contains(qint64), remove(QLatin1String), remove(const QString &) contains(qint64), remove(QLatin1StringView), remove(const QString &)
*/ */
/*! /*!
@ -777,8 +785,9 @@ QCborValueRef QCborMap::operator[](const QString & key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(const QCborValue &), find(const QCborValue &), contains(const QCborValue &), remove(const QCborValue &), \sa value(const QCborValue &), find(const QCborValue &), contains(const QCborValue &),
operator[](qint64), operator[](QLatin1String), operator[](const QString &) remove(const QCborValue &), operator[](qint64), operator[](QLatin1StringView),
operator[](const QString &)
*/ */
QCborValueRef QCborMap::operator[](const QCborValue &key) QCborValueRef QCborMap::operator[](const QCborValue &key)
{ {
@ -809,8 +818,8 @@ QCborContainerPrivate::findOrAddMapKey(QCborMap &map, KeyType key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(qint64), operator[](qint64), constFind(qint64), remove(qint64), contains(qint64) \sa value(qint64), operator[](qint64), constFind(qint64), remove(qint64), contains(qint64),
value(QLatin1String), value(const QString &), value(const QCborValue &) value(QLatin1StringView), value(const QString &), value(const QCborValue &)
*/ */
QCborMap::iterator QCborMap::find(qint64 key) QCborMap::iterator QCborMap::find(qint64 key)
{ {
@ -820,8 +829,8 @@ QCborMap::iterator QCborMap::find(qint64 key)
} }
/*! /*!
\fn QCborMap::iterator QCborMap::find(QLatin1String key) \fn QCborMap::iterator QCborMap::find(QLatin1StringView key)
\fn QCborMap::const_iterator QCborMap::find(QLatin1String key) const \fn QCborMap::const_iterator QCborMap::find(QLatin1StringView key) const
\overload \overload
Returns a map iterator to the key-value pair whose key is \a key, if the Returns a map iterator to the key-value pair whose key is \a key, if the
@ -833,11 +842,11 @@ QCborMap::iterator QCborMap::find(qint64 key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(QLatin1String), operator[](QLatin1String), constFind(QLatin1String), \sa value(QLatin1StringView), operator[](QLatin1StringView), constFind(QLatin1StringView),
remove(QLatin1String), contains(QLatin1String) remove(QLatin1StringView), contains(QLatin1StringView),
value(qint64), value(const QString &), value(const QCborValue &) value(qint64), value(const QString &), value(const QCborValue &)
*/ */
QCborMap::iterator QCborMap::find(QLatin1String key) QCborMap::iterator QCborMap::find(QLatin1StringView key)
{ {
detach(); detach();
auto it = constFind(key); auto it = constFind(key);
@ -859,8 +868,8 @@ QCborMap::iterator QCborMap::find(QLatin1String key)
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(const QString &), operator[](const QString &), constFind(const QString &), \sa value(const QString &), operator[](const QString &), constFind(const QString &),
remove(const QString &), contains(const QString &) remove(const QString &), contains(const QString &),
value(qint64), value(QLatin1String), value(const QCborValue &) value(qint64), value(QLatin1StringView), value(const QCborValue &)
*/ */
QCborMap::iterator QCborMap::find(const QString & key) QCborMap::iterator QCborMap::find(const QString & key)
{ {
@ -884,8 +893,8 @@ QCborMap::iterator QCborMap::find(const QString & key)
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(const QCborValue &), operator[](const QCborValue &), constFind(const QCborValue &), \sa value(const QCborValue &), operator[](const QCborValue &), constFind(const QCborValue &),
remove(const QCborValue &), contains(const QCborValue &) remove(const QCborValue &), contains(const QCborValue &),
value(qint64), value(QLatin1String), value(const QString &) value(qint64), value(QLatin1StringView), value(const QString &)
*/ */
QCborMap::iterator QCborMap::find(const QCborValue &key) QCborMap::iterator QCborMap::find(const QCborValue &key)
{ {
@ -907,8 +916,8 @@ QCborMap::iterator QCborMap::find(const QCborValue &key)
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(qint64), operator[](qint64), find(qint64), remove(qint64), contains(qint64) \sa value(qint64), operator[](qint64), find(qint64), remove(qint64), contains(qint64),
value(QLatin1String), value(const QString &), value(const QCborValue &) value(QLatin1StringView), value(const QString &), value(const QCborValue &)
*/ */
QCborMap::const_iterator QCborMap::constFind(qint64 key) const QCborMap::const_iterator QCborMap::constFind(qint64 key) const
{ {
@ -927,11 +936,11 @@ QCborMap::const_iterator QCborMap::constFind(qint64 key) const
stream with them. They are usually not permitted and having duplicate keys stream with them. They are usually not permitted and having duplicate keys
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(QLatin1String), operator[](QLatin1String), find(QLatin1String), \sa value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView),
remove(QLatin1String), contains(QLatin1String) remove(QLatin1StringView), contains(QLatin1StringView),
value(qint64), value(const QString &), value(const QCborValue &) value(qint64), value(const QString &), value(const QCborValue &)
*/ */
QCborMap::const_iterator QCborMap::constFind(QLatin1String key) const QCborMap::const_iterator QCborMap::constFind(QLatin1StringView key) const
{ {
return d ? d->findCborMapKey(key) : constEnd(); return d ? d->findCborMapKey(key) : constEnd();
} }
@ -949,8 +958,8 @@ QCborMap::const_iterator QCborMap::constFind(QLatin1String key) const
is usually an indication of a problem in the sender. is usually an indication of a problem in the sender.
\sa value(const QString &), operator[](const QString &), find(const QString &), \sa value(const QString &), operator[](const QString &), find(const QString &),
remove(const QString &), contains(const QString &) remove(const QString &), contains(const QString &),
value(qint64), value(QLatin1String), value(const QCborValue &) value(qint64), value(QLatin1StringView), value(const QCborValue &)
*/ */
QCborMap::const_iterator QCborMap::constFind(const QString &key) const QCborMap::const_iterator QCborMap::constFind(const QString &key) const
{ {
@ -971,7 +980,7 @@ QCborMap::const_iterator QCborMap::constFind(const QString &key) const
\sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), \sa value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &),
remove(const QCborValue &), contains(const QCborValue &), remove(const QCborValue &), contains(const QCborValue &),
value(qint64), value(QLatin1String), value(const QString &) value(qint64), value(QLatin1StringView), value(const QString &)
*/ */
QCborMap::const_iterator QCborMap::constFind(const QCborValue &key) const QCborMap::const_iterator QCborMap::constFind(const QCborValue &key) const
{ {
@ -993,7 +1002,7 @@ QCborMap::const_iterator QCborMap::constFind(const QCborValue &key) const
*/ */
/*! /*!
\fn QCborMap::iterator QCborMap::insert(QLatin1String key, const QCborValue &value) \fn QCborMap::iterator QCborMap::insert(QLatin1StringView key, const QCborValue &value)
\overload \overload
Inserts the key \a key and value \a value into this map and returns a map Inserts the key \a key and value \a value into this map and returns a map
@ -1002,8 +1011,8 @@ QCborMap::const_iterator QCborMap::constFind(const QCborValue &key) const
If the map already had a key equal to \a key, its value will be overwritten If the map already had a key equal to \a key, its value will be overwritten
by \a value. by \a value.
\sa erase(), remove(QLatin1String), value(QLatin1String), operator[](QLatin1String), \sa erase(), remove(QLatin1StringView), value(QLatin1StringView), operator[](QLatin1StringView),
find(QLatin1String), contains(QLatin1String), take(QLatin1String), extract() find(QLatin1StringView), contains(QLatin1StringView), take(QLatin1StringView), extract()
*/ */
/*! /*!

View File

@ -204,7 +204,7 @@ public:
QCborValue value(qint64 key) const QCborValue value(qint64 key) const
{ const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); } { const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); }
QCborValue value(QLatin1String key) const QCborValue value(QLatin1StringView key) const
{ const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); } { const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); }
QCborValue value(const QString & key) const QCborValue value(const QString & key) const
{ const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); } { const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); }
@ -216,7 +216,7 @@ public:
#endif #endif
const QCborValue operator[](qint64 key) const const QCborValue operator[](qint64 key) const
{ const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); } { const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); }
const QCborValue operator[](QLatin1String key) const const QCborValue operator[](QLatin1StringView key) const
{ const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); } { const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); }
const QCborValue operator[](const QString & key) const const QCborValue operator[](const QString & key) const
{ const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); } { const_iterator it = find(key); return it == end() ? QCborValue() : it.value(); }
@ -227,13 +227,13 @@ public:
{ return operator[](QString::fromUtf8(key, N - 1)); } { return operator[](QString::fromUtf8(key, N - 1)); }
#endif #endif
QCborValueRef operator[](qint64 key); QCborValueRef operator[](qint64 key);
QCborValueRef operator[](QLatin1String key); QCborValueRef operator[](QLatin1StringView key);
QCborValueRef operator[](const QString & key); QCborValueRef operator[](const QString & key);
QCborValueRef operator[](const QCborValue &key); QCborValueRef operator[](const QCborValue &key);
QCborValue take(qint64 key) QCborValue take(qint64 key)
{ const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); }
QCborValue take(QLatin1String key) QCborValue take(QLatin1StringView key)
{ const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); }
QCborValue take(const QString &key) QCborValue take(const QString &key)
{ const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); }
@ -241,7 +241,7 @@ public:
{ const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); } { const_iterator it = constFind(key); if (it != constEnd()) return extract(it); return QCborValue(); }
void remove(qint64 key) void remove(qint64 key)
{ const_iterator it = constFind(key); if (it != constEnd()) erase(it); } { const_iterator it = constFind(key); if (it != constEnd()) erase(it); }
void remove(QLatin1String key) void remove(QLatin1StringView key)
{ const_iterator it = constFind(key); if (it != constEnd()) erase(it); } { const_iterator it = constFind(key); if (it != constEnd()) erase(it); }
void remove(const QString & key) void remove(const QString & key)
{ const_iterator it = constFind(key); if (it != constEnd()) erase(it); } { const_iterator it = constFind(key); if (it != constEnd()) erase(it); }
@ -249,7 +249,7 @@ public:
{ const_iterator it = constFind(key); if (it != constEnd()) erase(it); } { const_iterator it = constFind(key); if (it != constEnd()) erase(it); }
bool contains(qint64 key) const bool contains(qint64 key) const
{ const_iterator it = find(key); return it != end(); } { const_iterator it = find(key); return it != end(); }
bool contains(QLatin1String key) const bool contains(QLatin1StringView key) const
{ const_iterator it = find(key); return it != end(); } { const_iterator it = find(key); return it != end(); }
bool contains(const QString & key) const bool contains(const QString & key) const
{ const_iterator it = find(key); return it != end(); } { const_iterator it = find(key); return it != end(); }
@ -291,15 +291,15 @@ public:
bool empty() const { return isEmpty(); } bool empty() const { return isEmpty(); }
iterator find(qint64 key); iterator find(qint64 key);
iterator find(QLatin1String key); iterator find(QLatin1StringView key);
iterator find(const QString & key); iterator find(const QString & key);
iterator find(const QCborValue &key); iterator find(const QCborValue &key);
const_iterator constFind(qint64 key) const; const_iterator constFind(qint64 key) const;
const_iterator constFind(QLatin1String key) const; const_iterator constFind(QLatin1StringView key) const;
const_iterator constFind(const QString & key) const; const_iterator constFind(const QString & key) const;
const_iterator constFind(const QCborValue &key) const; const_iterator constFind(const QCborValue &key) const;
const_iterator find(qint64 key) const { return constFind(key); } const_iterator find(qint64 key) const { return constFind(key); }
const_iterator find(QLatin1String key) const { return constFind(key); } const_iterator find(QLatin1StringView key) const { return constFind(key); }
const_iterator find(const QString & key) const { return constFind(key); } const_iterator find(const QString & key) const { return constFind(key); }
const_iterator find(const QCborValue &key) const { return constFind(key); } const_iterator find(const QCborValue &key) const { return constFind(key); }
@ -309,7 +309,7 @@ public:
v = value_; v = value_;
return { d.data(), v.i }; return { d.data(), v.i };
} }
iterator insert(QLatin1String key, const QCborValue &value_) iterator insert(QLatin1StringView key, const QCborValue &value_)
{ {
QCborValueRef v = operator[](key); // detaches QCborValueRef v = operator[](key); // detaches
v = value_; v = value_;

View File

@ -466,7 +466,7 @@ void QCborStreamWriter::append(QCborNegativeInteger n)
\sa QCborStreamReader::isString(), QCborStreamReader::readString() \sa QCborStreamReader::isString(), QCborStreamReader::readString()
*/ */
void QCborStreamWriter::append(QLatin1String str) void QCborStreamWriter::append(QLatin1StringView str)
{ {
// We've got Latin-1 but CBOR wants UTF-8, so check if the string is the // We've got Latin-1 but CBOR wants UTF-8, so check if the string is the
// common subset (US-ASCII). // common subset (US-ASCII).
@ -639,11 +639,11 @@ void QCborStreamWriter::appendByteString(const char *data, qsizetype len)
The string pointed to by \a utf8 is expected to be properly encoded UTF-8. The string pointed to by \a utf8 is expected to be properly encoded UTF-8.
QCborStreamWriter performs no validation that this is the case. QCborStreamWriter performs no validation that this is the case.
Unlike the QLatin1String overload of append(), this function is not limited Unlike the QLatin1StringView overload of append(), this function is not limited
to 2 GB. However, note that neither QCborStreamReader::readString() nor to 2 GB. However, note that neither QCborStreamReader::readString() nor
QCborValue support reading CBOR streams with text strings larger than 2 GB. QCborValue support reading CBOR streams with text strings larger than 2 GB.
\sa append(QLatin1String), append(QStringView), \sa append(QLatin1StringView), append(QStringView),
QCborStreamReader::isString(), QCborStreamReader::readString() QCborStreamReader::isString(), QCborStreamReader::readString()
*/ */
void QCborStreamWriter::appendTextString(const char *utf8, qsizetype len) void QCborStreamWriter::appendTextString(const char *utf8, qsizetype len)
@ -663,11 +663,11 @@ void QCborStreamWriter::appendTextString(const char *utf8, qsizetype len)
The string pointed to by \a str is expected to be properly encoded UTF-8. The string pointed to by \a str is expected to be properly encoded UTF-8.
QCborStreamWriter performs no validation that this is the case. QCborStreamWriter performs no validation that this is the case.
Unlike the QLatin1String overload of append(), this function is not limited Unlike the QLatin1StringView overload of append(), this function is not limited
to 2 GB. However, note that neither QCborStreamReader nor QCborValue support to 2 GB. However, note that neither QCborStreamReader nor QCborValue support
reading CBOR streams with text strings larger than 2 GB. reading CBOR streams with text strings larger than 2 GB.
\sa append(QLatin1String), append(QStringView), \sa append(QLatin1StringView), append(QStringView),
QCborStreamReader::isString(), QCborStreamReader::readString() QCborStreamReader::isString(), QCborStreamReader::readString()
*/ */

View File

@ -77,7 +77,7 @@ public:
void append(qint64 i); void append(qint64 i);
void append(QCborNegativeInteger n); void append(QCborNegativeInteger n);
void append(const QByteArray &ba) { appendByteString(ba.constData(), ba.size()); } void append(const QByteArray &ba) { appendByteString(ba.constData(), ba.size()); }
void append(QLatin1String str); void append(QLatin1StringView str);
void append(QStringView str); void append(QStringView str);
void append(QCborTag tag); void append(QCborTag tag);
void append(QCborKnownTags tag) { append(QCborTag(tag)); } void append(QCborKnownTags tag) { append(QCborTag(tag)); }

View File

@ -1395,7 +1395,7 @@ static void encodeToCbor(QCborStreamWriter &writer, const QCborContainerPrivate
return writer.append(b->asStringView()); return writer.append(b->asStringView());
return writer.appendTextString(b->byte(), b->len); return writer.appendTextString(b->byte(), b->len);
} }
return writer.append(QLatin1String()); return writer.append(QLatin1StringView());
case QCborValue::Array: case QCborValue::Array:
case QCborValue::Map: case QCborValue::Map:
@ -1755,7 +1755,7 @@ QCborValue::QCborValue(QStringView s)
\sa toString(), isString(), isByteArray() \sa toString(), isString(), isByteArray()
*/ */
QCborValue::QCborValue(QLatin1String s) QCborValue::QCborValue(QLatin1StringView s)
: n(0), container(new QCborContainerPrivate), t(String) : n(0), container(new QCborContainerPrivate), t(String)
{ {
container->append(s); container->append(s);
@ -2192,7 +2192,7 @@ const QCborValue QCborValue::operator[](const QString &key) const
\sa operator[](qint64), QCborMap::operator[], QCborMap::value(), \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
QCborMap::find() QCborMap::find()
*/ */
const QCborValue QCborValue::operator[](QLatin1String key) const const QCborValue QCborValue::operator[](QLatin1StringView key) const
{ {
return QCborContainerPrivate::findCborMapKey(*this, key); return QCborContainerPrivate::findCborMapKey(*this, key);
} }
@ -2349,7 +2349,7 @@ QCborValueRef QCborValue::operator[](const QString &key)
\sa operator[](qint64), QCborMap::operator[], QCborMap::value(), \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
QCborMap::find() QCborMap::find()
*/ */
QCborValueRef QCborValue::operator[](QLatin1String key) QCborValueRef QCborValue::operator[](QLatin1StringView key)
{ {
return QCborContainerPrivate::findOrAddMapKey(*this, key); return QCborContainerPrivate::findOrAddMapKey(*this, key);
} }
@ -2703,7 +2703,7 @@ const QCborValue QCborValueConstRef::operator[](const QString &key) const
return item[key]; return item[key];
} }
const QCborValue QCborValueConstRef::operator[](const QLatin1String key) const const QCborValue QCborValueConstRef::operator[](const QLatin1StringView key) const
{ {
const QCborValue item = d->valueAt(i); const QCborValue item = d->valueAt(i);
return item[key]; return item[key];
@ -2761,7 +2761,7 @@ const QCborValue QCborValueRef::operator[](const QString &key) const
\sa operator[](qint64), QCborMap::operator[], QCborMap::value(), \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
QCborMap::find() QCborMap::find()
*/ */
const QCborValue QCborValueRef::operator[](QLatin1String key) const const QCborValue QCborValueRef::operator[](QLatin1StringView key) const
{ {
return QCborValueConstRef::operator[](key); return QCborValueConstRef::operator[](key);
} }
@ -2817,7 +2817,7 @@ QCborValueRef QCborValueRef::operator[](const QString &key)
\sa operator[](qint64), QCborMap::operator[], QCborMap::value(), \sa operator[](qint64), QCborMap::operator[], QCborMap::value(),
QCborMap::find() QCborMap::find()
*/ */
QCborValueRef QCborValueRef::operator[](QLatin1String key) QCborValueRef QCborValueRef::operator[](QLatin1StringView key)
{ {
return QCborContainerPrivate::findOrAddMapKey(*this, key); return QCborContainerPrivate::findOrAddMapKey(*this, key);
} }

View File

@ -150,7 +150,7 @@ public:
QCborValue(const QString &s); QCborValue(const QString &s);
#endif #endif
QCborValue(QStringView s); QCborValue(QStringView s);
QCborValue(QLatin1String s); QCborValue(QLatin1StringView s);
#ifndef QT_NO_CAST_FROM_ASCII #ifndef QT_NO_CAST_FROM_ASCII
QT_ASCII_CAST_WARN QCborValue(const char *s) : QCborValue(QString::fromUtf8(s)) {} QT_ASCII_CAST_WARN QCborValue(const char *s) : QCborValue(QString::fromUtf8(s)) {}
#endif #endif
@ -253,10 +253,10 @@ public:
QCborMap toMap(const QCborMap &defaultValue) const; QCborMap toMap(const QCborMap &defaultValue) const;
const QCborValue operator[](const QString &key) const; const QCborValue operator[](const QString &key) const;
const QCborValue operator[](QLatin1String key) const; const QCborValue operator[](QLatin1StringView key) const;
const QCborValue operator[](qint64 key) const; const QCborValue operator[](qint64 key) const;
QCborValueRef operator[](qint64 key); QCborValueRef operator[](qint64 key);
QCborValueRef operator[](QLatin1String key); QCborValueRef operator[](QLatin1StringView key);
QCborValueRef operator[](const QString & key); QCborValueRef operator[](const QString & key);
int compare(const QCborValue &other) const; int compare(const QCborValue &other) const;
@ -402,7 +402,7 @@ public:
inline QCborMap toMap(const QCborMap &m) const; inline QCborMap toMap(const QCborMap &m) const;
Q_CORE_EXPORT const QCborValue operator[](const QString &key) const; Q_CORE_EXPORT const QCborValue operator[](const QString &key) const;
Q_CORE_EXPORT const QCborValue operator[](QLatin1String key) const; Q_CORE_EXPORT const QCborValue operator[](QLatin1StringView key) const;
Q_CORE_EXPORT const QCborValue operator[](qint64 key) const; Q_CORE_EXPORT const QCborValue operator[](qint64 key) const;
int compare(const QCborValue &other) const int compare(const QCborValue &other) const
@ -479,7 +479,7 @@ public:
{ assign(*this, other); return *this; } { assign(*this, other); return *this; }
QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](qint64 key); QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](qint64 key);
QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](QLatin1String key); QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](QLatin1StringView key);
QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](const QString & key); QT7_ONLY(Q_CORE_EXPORT) QCborValueRef operator[](const QString & key);
#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED) #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
@ -555,7 +555,7 @@ public:
QCborMap toMap(const QCborMap &m) const; QCborMap toMap(const QCborMap &m) const;
const QCborValue operator[](const QString &key) const; const QCborValue operator[](const QString &key) const;
const QCborValue operator[](QLatin1String key) const; const QCborValue operator[](QLatin1StringView key) const;
const QCborValue operator[](qint64 key) const; const QCborValue operator[](qint64 key) const;
int compare(const QCborValue &other) const int compare(const QCborValue &other) const

View File

@ -115,7 +115,7 @@ struct ByteData
QString toUtf8String() const { return QString::fromUtf8(byte(), len); } QString toUtf8String() const { return QString::fromUtf8(byte(), len); }
QByteArray asByteArrayView() const { return QByteArray::fromRawData(byte(), len); } QByteArray asByteArrayView() const { return QByteArray::fromRawData(byte(), len); }
QLatin1String asLatin1() const { return QLatin1String(byte(), len); } QLatin1StringView asLatin1() const { return QLatin1StringView(byte(), len); }
QUtf8StringView asUtf8StringView() const { return QUtf8StringView(byte(), len); } QUtf8StringView asUtf8StringView() const { return QUtf8StringView(byte(), len); }
QStringView asStringView() const{ return QStringView(utf16(), len / 2); } QStringView asStringView() const{ return QStringView(utf16(), len / 2); }
QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); } QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); }
@ -250,7 +250,7 @@ public:
{ {
appendByteData(str, len, QCborValue::String); appendByteData(str, len, QCborValue::String);
} }
void append(QLatin1String s) void append(QLatin1StringView s)
{ {
if (!QtPrivate::isAscii(s)) if (!QtPrivate::isAscii(s))
return append(QString(s)); return append(QString(s));
@ -367,7 +367,7 @@ public:
return e; return e;
} }
static int compareUtf8(const QtCbor::ByteData *b, const QLatin1String &s) static int compareUtf8(const QtCbor::ByteData *b, QLatin1StringView s)
{ {
return QUtf8::compareUtf8(QByteArrayView(b->byte(), b->len), s); return QUtf8::compareUtf8(QByteArrayView(b->byte(), b->len), s);
} }

View File

@ -462,7 +462,7 @@ const QJsonValue QJsonDocument::operator[](QStringView key) const
\overload \overload
\since 5.10 \since 5.10
*/ */
const QJsonValue QJsonDocument::operator[](QLatin1String key) const const QJsonValue QJsonDocument::operator[](QLatin1StringView key) const
{ {
if (!isObject()) if (!isObject())
return QJsonValue(QJsonValue::Undefined); return QJsonValue(QJsonValue::Undefined);

View File

@ -134,7 +134,7 @@ public:
const QJsonValue operator[](const QString &key) const; const QJsonValue operator[](const QString &key) const;
#endif #endif
const QJsonValue operator[](QStringView key) const; const QJsonValue operator[](QStringView key) const;
const QJsonValue operator[](QLatin1String key) const; const QJsonValue operator[](QLatin1StringView key) const;
const QJsonValue operator[](qsizetype i) const; const QJsonValue operator[](qsizetype i) const;
bool operator==(const QJsonDocument &other) const; bool operator==(const QJsonDocument &other) const;

View File

@ -342,7 +342,7 @@ QJsonValue QJsonObject::value(QStringView key) const
\overload \overload
\since 5.7 \since 5.7
*/ */
QJsonValue QJsonObject::value(QLatin1String key) const QJsonValue QJsonObject::value(QLatin1StringView key) const
{ {
return valueImpl(key); return valueImpl(key);
} }
@ -387,7 +387,7 @@ QJsonValue QJsonObject::operator [](const QString &key) const
*/ */
/*! /*!
\fn QJsonValue QJsonObject::operator [](QLatin1String key) const \fn QJsonValue QJsonObject::operator [](QLatin1StringView key) const
\overload \overload
\since 5.7 \since 5.7
@ -426,7 +426,7 @@ QJsonValueRef QJsonObject::operator [](QStringView key)
\overload \overload
\since 5.7 \since 5.7
*/ */
QJsonValueRef QJsonObject::operator [](QLatin1String key) QJsonValueRef QJsonObject::operator [](QLatin1StringView key)
{ {
return atImpl(key); return atImpl(key);
} }
@ -484,7 +484,7 @@ QJsonObject::iterator QJsonObject::insert(QStringView key, const QJsonValue &val
\overload \overload
\since 5.14 \since 5.14
*/ */
QJsonObject::iterator QJsonObject::insert(QLatin1String key, const QJsonValue &value) QJsonObject::iterator QJsonObject::insert(QLatin1StringView key, const QJsonValue &value)
{ {
return insertImpl(key, value); return insertImpl(key, value);
} }
@ -549,7 +549,7 @@ void QJsonObject::remove(QStringView key)
\overload \overload
\since 5.14 \since 5.14
*/ */
void QJsonObject::remove(QLatin1String key) void QJsonObject::remove(QLatin1StringView key)
{ {
removeImpl(key); removeImpl(key);
} }
@ -600,7 +600,7 @@ QJsonValue QJsonObject::take(QStringView key)
\overload \overload
\since 5.14 \since 5.14
*/ */
QJsonValue QJsonObject::take(QLatin1String key) QJsonValue QJsonObject::take(QLatin1StringView key)
{ {
return takeImpl(key); return takeImpl(key);
} }
@ -650,7 +650,7 @@ bool QJsonObject::contains(QStringView key) const
\overload \overload
\since 5.7 \since 5.7
*/ */
bool QJsonObject::contains(QLatin1String key) const bool QJsonObject::contains(QLatin1StringView key) const
{ {
return containsImpl(key); return containsImpl(key);
} }
@ -744,7 +744,7 @@ QJsonObject::iterator QJsonObject::find(QStringView key)
\overload \overload
\since 5.7 \since 5.7
*/ */
QJsonObject::iterator QJsonObject::find(QLatin1String key) QJsonObject::iterator QJsonObject::find(QLatin1StringView key)
{ {
return findImpl(key); return findImpl(key);
} }
@ -776,7 +776,7 @@ QJsonObject::iterator QJsonObject::findImpl(T key)
\since 5.14 \since 5.14
*/ */
/*! \fn QJsonObject::const_iterator QJsonObject::find(QLatin1String key) const /*! \fn QJsonObject::const_iterator QJsonObject::find(QLatin1StringView key) const
\overload \overload
\since 5.7 \since 5.7
@ -809,7 +809,7 @@ QJsonObject::const_iterator QJsonObject::constFind(QStringView key) const
\overload \overload
\since 5.7 \since 5.7
*/ */
QJsonObject::const_iterator QJsonObject::constFind(QLatin1String key) const QJsonObject::const_iterator QJsonObject::constFind(QLatin1StringView key) const
{ {
return constFindImpl(key); return constFindImpl(key);
} }

View File

@ -94,11 +94,11 @@ public:
QJsonValueRef operator[] (const QString &key); QJsonValueRef operator[] (const QString &key);
#endif #endif
QJsonValue value(QStringView key) const; QJsonValue value(QStringView key) const;
QJsonValue value(QLatin1String key) const; QJsonValue value(QLatin1StringView key) const;
QJsonValue operator[] (QStringView key) const { return value(key); } QJsonValue operator[] (QStringView key) const { return value(key); }
QJsonValue operator[] (QLatin1String key) const { return value(key); } QJsonValue operator[] (QLatin1StringView key) const { return value(key); }
QJsonValueRef operator[] (QStringView key); QJsonValueRef operator[] (QStringView key);
QJsonValueRef operator[] (QLatin1String key); QJsonValueRef operator[] (QLatin1StringView key);
#if QT_STRINGVIEW_LEVEL < 2 #if QT_STRINGVIEW_LEVEL < 2
void remove(const QString &key); void remove(const QString &key);
@ -106,11 +106,11 @@ public:
bool contains(const QString &key) const; bool contains(const QString &key) const;
#endif #endif
void remove(QStringView key); void remove(QStringView key);
void remove(QLatin1String key); void remove(QLatin1StringView key);
QJsonValue take(QStringView key); QJsonValue take(QStringView key);
QJsonValue take(QLatin1String key); QJsonValue take(QLatin1StringView key);
bool contains(QStringView key) const; bool contains(QStringView key) const;
bool contains(QLatin1String key) const; bool contains(QLatin1StringView key) const;
bool operator==(const QJsonObject &other) const; bool operator==(const QJsonObject &other) const;
bool operator!=(const QJsonObject &other) const; bool operator!=(const QJsonObject &other) const;
@ -262,13 +262,13 @@ public:
iterator insert(const QString &key, const QJsonValue &value); iterator insert(const QString &key, const QJsonValue &value);
#endif #endif
iterator find(QStringView key); iterator find(QStringView key);
iterator find(QLatin1String key); iterator find(QLatin1StringView key);
const_iterator find(QStringView key) const { return constFind(key); } const_iterator find(QStringView key) const { return constFind(key); }
const_iterator find(QLatin1String key) const { return constFind(key); } const_iterator find(QLatin1StringView key) const { return constFind(key); }
const_iterator constFind(QStringView key) const; const_iterator constFind(QStringView key) const;
const_iterator constFind(QLatin1String key) const; const_iterator constFind(QLatin1StringView key) const;
iterator insert(QStringView key, const QJsonValue &value); iterator insert(QStringView key, const QJsonValue &value);
iterator insert(QLatin1String key, const QJsonValue &value); iterator insert(QLatin1StringView key, const QJsonValue &value);
// STL compatibility // STL compatibility
typedef QJsonValue mapped_type; typedef QJsonValue mapped_type;

View File

@ -193,7 +193,7 @@ QString QJsonParseError::errorString() const
#ifndef QT_BOOTSTRAPPED #ifndef QT_BOOTSTRAPPED
return QCoreApplication::translate("QJsonParseError", sz); return QCoreApplication::translate("QJsonParseError", sz);
#else #else
return QLatin1String(sz); return QLatin1StringView(sz);
#endif #endif
} }

View File

@ -235,7 +235,7 @@ QJsonValue::QJsonValue(const QString &s)
/*! /*!
Creates a value of type String, with value \a s. Creates a value of type String, with value \a s.
*/ */
QJsonValue::QJsonValue(QLatin1String s) QJsonValue::QJsonValue(QLatin1StringView s)
: value(s) : value(s)
{ {
} }
@ -826,7 +826,7 @@ const QJsonValue QJsonValue::operator[](QStringView key) const
\overload \overload
\since 5.10 \since 5.10
*/ */
const QJsonValue QJsonValue::operator[](QLatin1String key) const const QJsonValue QJsonValue::operator[](QLatin1StringView key) const
{ {
if (!isObject()) if (!isObject())
return QJsonValue(QJsonValue::Undefined); return QJsonValue(QJsonValue::Undefined);

View File

@ -75,7 +75,7 @@ public:
QJsonValue(int n); QJsonValue(int n);
QJsonValue(qint64 v); QJsonValue(qint64 v);
QJsonValue(const QString &s); QJsonValue(const QString &s);
QJsonValue(QLatin1String s); QJsonValue(QLatin1StringView s);
#ifndef QT_NO_CAST_FROM_ASCII #ifndef QT_NO_CAST_FROM_ASCII
QT_ASCII_CAST_WARN inline QJsonValue(const char *s) QT_ASCII_CAST_WARN inline QJsonValue(const char *s)
: QJsonValue(QString::fromUtf8(s)) {} : QJsonValue(QString::fromUtf8(s)) {}
@ -127,7 +127,7 @@ public:
const QJsonValue operator[](const QString &key) const; const QJsonValue operator[](const QString &key) const;
#endif #endif
const QJsonValue operator[](QStringView key) const; const QJsonValue operator[](QStringView key) const;
const QJsonValue operator[](QLatin1String key) const; const QJsonValue operator[](QLatin1StringView key) const;
const QJsonValue operator[](qsizetype i) const; const QJsonValue operator[](qsizetype i) const;
bool operator==(const QJsonValue &other) const; bool operator==(const QJsonValue &other) const;
@ -183,7 +183,7 @@ public:
Q_CORE_EXPORT QJsonObject toObject() const; Q_CORE_EXPORT QJsonObject toObject() const;
const QJsonValue operator[](QStringView key) const { return concrete(*this)[key]; } const QJsonValue operator[](QStringView key) const { return concrete(*this)[key]; }
const QJsonValue operator[](QLatin1String key) const { return concrete(*this)[key]; } const QJsonValue operator[](QLatin1StringView key) const { return concrete(*this)[key]; }
const QJsonValue operator[](qsizetype i) const { return concrete(*this)[i]; } const QJsonValue operator[](qsizetype i) const { return concrete(*this)[i]; }
inline bool operator==(const QJsonValue &other) const { return concrete(*this) == other; } inline bool operator==(const QJsonValue &other) const { return concrete(*this) == other; }
@ -290,7 +290,7 @@ public:
QJsonObject toObject() const; QJsonObject toObject() const;
const QJsonValue operator[](QStringView key) const { return QJsonValueConstRef::operator[](key); } const QJsonValue operator[](QStringView key) const { return QJsonValueConstRef::operator[](key); }
const QJsonValue operator[](QLatin1String key) const { return QJsonValueConstRef::operator[](key); } const QJsonValue operator[](QLatin1StringView key) const { return QJsonValueConstRef::operator[](key); }
const QJsonValue operator[](qsizetype i) const { return QJsonValueConstRef::operator[](i); } const QJsonValue operator[](qsizetype i) const { return QJsonValueConstRef::operator[](i); }
inline bool operator==(const QJsonValue &other) const { return QJsonValueConstRef::operator==(other); } inline bool operator==(const QJsonValue &other) const { return QJsonValueConstRef::operator==(other); }

View File

@ -744,7 +744,7 @@ inline void QTextStreamPrivate::write(QChar ch)
/*! /*!
\internal \internal
*/ */
void QTextStreamPrivate::write(QLatin1String data) void QTextStreamPrivate::write(QLatin1StringView data)
{ {
if (string) { if (string) {
// ### What about seek()?? // ### What about seek()??
@ -880,7 +880,7 @@ void QTextStreamPrivate::putString(const QChar *data, qsizetype len, bool number
/*! /*!
\internal \internal
*/ */
void QTextStreamPrivate::putString(QLatin1String data, bool number) void QTextStreamPrivate::putString(QLatin1StringView data, bool number)
{ {
if (Q_UNLIKELY(params.fieldWidth > data.size())) { if (Q_UNLIKELY(params.fieldWidth > data.size())) {
@ -893,7 +893,7 @@ void QTextStreamPrivate::putString(QLatin1String data, bool number)
if (sign == locale.negativeSign() || sign == locale.positiveSign()) { if (sign == locale.negativeSign() || sign == locale.positiveSign()) {
// write the sign before the padding, then skip it later // write the sign before the padding, then skip it later
write(&sign, 1); write(&sign, 1);
data = QLatin1String(data.data() + 1, data.size() - 1); data = QLatin1StringView(data.data() + 1, data.size() - 1);
} }
} }
@ -2498,7 +2498,7 @@ QTextStream &QTextStream::operator<<(QStringView string)
Writes \a string to the stream, and returns a reference to the Writes \a string to the stream, and returns a reference to the
QTextStream. QTextStream.
*/ */
QTextStream &QTextStream::operator<<(QLatin1String string) QTextStream &QTextStream::operator<<(QLatin1StringView string)
{ {
Q_D(QTextStream); Q_D(QTextStream);
CHECK_VALID_STREAM(*this); CHECK_VALID_STREAM(*this);

View File

@ -181,7 +181,7 @@ public:
QTextStream &operator<<(double f); QTextStream &operator<<(double f);
QTextStream &operator<<(const QString &s); QTextStream &operator<<(const QString &s);
QTextStream &operator<<(QStringView s); QTextStream &operator<<(QStringView s);
QTextStream &operator<<(QLatin1String s); QTextStream &operator<<(QLatin1StringView s);
QTextStream &operator<<(const QByteArray &array); QTextStream &operator<<(const QByteArray &array);
QTextStream &operator<<(const char *c); QTextStream &operator<<(const char *c);
QTextStream &operator<<(const void *ptr); QTextStream &operator<<(const void *ptr);

View File

@ -178,14 +178,14 @@ public:
inline void write(QStringView data) { write(data.begin(), data.length()); } inline void write(QStringView data) { write(data.begin(), data.length()); }
inline void write(QChar ch); inline void write(QChar ch);
void write(const QChar *data, qsizetype len); void write(const QChar *data, qsizetype len);
void write(QLatin1String data); void write(QLatin1StringView data);
void writePadding(qsizetype len); void writePadding(qsizetype len);
inline void putString(QStringView string, bool number = false) inline void putString(QStringView string, bool number = false)
{ {
putString(string.constData(), string.length(), number); putString(string.constData(), string.length(), number);
} }
void putString(const QChar *data, qsizetype len, bool number = false); void putString(const QChar *data, qsizetype len, bool number = false);
void putString(QLatin1String data, bool number = false); void putString(QLatin1StringView data, bool number = false);
void putString(QUtf8StringView data, bool number = false); void putString(QUtf8StringView data, bool number = false);
inline void putChar(QChar ch); inline void putChar(QChar ch);
void putNumber(qulonglong number, bool negative); void putNumber(qulonglong number, bool negative);

View File

@ -757,7 +757,7 @@ bool QXmlStreamReader::namespaceProcessing() const
QString QXmlStreamReader::tokenString() const QString QXmlStreamReader::tokenString() const
{ {
Q_D(const QXmlStreamReader); Q_D(const QXmlStreamReader);
return QLatin1String(QXmlStreamReader_tokenTypeString_string + return QLatin1StringView(QXmlStreamReader_tokenTypeString_string +
QXmlStreamReader_tokenTypeString_indices[d->type]); QXmlStreamReader_tokenTypeString_indices[d->type]);
} }
@ -1853,22 +1853,27 @@ void QXmlStreamReaderPrivate::parseError()
if (nexpected && nexpected < nmax) { if (nexpected && nexpected < nmax) {
//: '<first option>' //: '<first option>'
QString exp_str = QXmlStream::tr("'%1'", "expected").arg(QLatin1String(spell[expected[0]])); QString exp_str = QXmlStream::tr("'%1'", "expected")
.arg(QLatin1StringView(spell[expected[0]]));
if (nexpected == 2) { if (nexpected == 2) {
//: <first option>, '<second option>' //: <first option>, '<second option>'
exp_str = QXmlStream::tr("%1 or '%2'", "expected").arg(exp_str, QLatin1String(spell[expected[1]])); exp_str = QXmlStream::tr("%1 or '%2'", "expected")
.arg(exp_str, QLatin1StringView(spell[expected[1]]));
} else if (nexpected > 2) { } else if (nexpected > 2) {
int s = 1; int s = 1;
for (; s < nexpected - 1; ++s) { for (; s < nexpected - 1; ++s) {
//: <options so far>, '<next option>' //: <options so far>, '<next option>'
exp_str = QXmlStream::tr("%1, '%2'", "expected").arg(exp_str, QLatin1String(spell[expected[s]])); exp_str = QXmlStream::tr("%1, '%2'", "expected")
.arg(exp_str, QLatin1StringView(spell[expected[s]]));
} }
//: <options so far>, or '<final option>' //: <options so far>, or '<final option>'
exp_str = QXmlStream::tr("%1, or '%2'", "expected").arg(exp_str, QLatin1String(spell[expected[s]])); exp_str = QXmlStream::tr("%1, or '%2'", "expected")
.arg(exp_str, QLatin1StringView(spell[expected[s]]));
} }
error_message = QXmlStream::tr("Expected %1, but got '%2'.").arg(exp_str, QLatin1String(spell[token])); error_message = QXmlStream::tr("Expected %1, but got '%2'.")
.arg(exp_str, QLatin1StringView(spell[token]));
} else { } else {
error_message = QXmlStream::tr("Unexpected '%1'.").arg(QLatin1String(spell[token])); error_message = QXmlStream::tr("Unexpected '%1'.").arg(QLatin1StringView(spell[token]));
} }
raiseWellFormedError(error_message); raiseWellFormedError(error_message);
@ -2572,7 +2577,7 @@ QStringView QXmlStreamAttributes::value(const QString &namespaceUri, const QStri
described with \a namespaceUri, or an empty string reference if the described with \a namespaceUri, or an empty string reference if the
attribute is not defined. The \a namespaceUri can be empty. attribute is not defined. The \a namespaceUri can be empty.
*/ */
QStringView QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const QStringView QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1StringView name) const
{ {
for (const QXmlStreamAttribute &attribute : *this) { for (const QXmlStreamAttribute &attribute : *this) {
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri) if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
@ -2586,7 +2591,8 @@ QStringView QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1Stri
described with \a namespaceUri, or an empty string reference if the described with \a namespaceUri, or an empty string reference if the
attribute is not defined. The \a namespaceUri can be empty. attribute is not defined. The \a namespaceUri can be empty.
*/ */
QStringView QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const QStringView QXmlStreamAttributes::value(QLatin1StringView namespaceUri,
QLatin1StringView name) const
{ {
for (const QXmlStreamAttribute &attribute : *this) { for (const QXmlStreamAttribute &attribute : *this) {
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri) if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
@ -2628,7 +2634,7 @@ QStringView QXmlStreamAttributes::value(const QString &qualifiedName) const
use qualified names, but a resolved namespaceUri and the attribute's use qualified names, but a resolved namespaceUri and the attribute's
local name. local name.
*/ */
QStringView QXmlStreamAttributes::value(QLatin1String qualifiedName) const QStringView QXmlStreamAttributes::value(QLatin1StringView qualifiedName) const
{ {
for (const QXmlStreamAttribute &attribute : *this) { for (const QXmlStreamAttribute &attribute : *this) {
if (attribute.qualifiedName() == qualifiedName) if (attribute.qualifiedName() == qualifiedName)
@ -3765,7 +3771,7 @@ void QXmlStreamWriter::writeCurrentToken(const QXmlStreamReader &reader)
*/ */
/*! /*!
\fn bool QXmlStreamAttributes::hasAttribute(QLatin1String qualifiedName) const \fn bool QXmlStreamAttributes::hasAttribute(QLatin1StringView qualifiedName) const
\overload \overload
\since 4.5 \since 4.5
*/ */

View File

@ -112,10 +112,10 @@ class QXmlStreamAttributes : public QList<QXmlStreamAttribute>
public: public:
inline QXmlStreamAttributes() {} inline QXmlStreamAttributes() {}
Q_CORE_EXPORT QStringView value(const QString &namespaceUri, const QString &name) const; Q_CORE_EXPORT QStringView value(const QString &namespaceUri, const QString &name) const;
Q_CORE_EXPORT QStringView value(const QString &namespaceUri, QLatin1String name) const; Q_CORE_EXPORT QStringView value(const QString &namespaceUri, QLatin1StringView name) const;
Q_CORE_EXPORT QStringView value(QLatin1String namespaceUri, QLatin1String name) const; Q_CORE_EXPORT QStringView value(QLatin1StringView namespaceUri, QLatin1StringView name) const;
Q_CORE_EXPORT QStringView value(const QString &qualifiedName) const; Q_CORE_EXPORT QStringView value(const QString &qualifiedName) const;
Q_CORE_EXPORT QStringView value(QLatin1String qualifiedName) const; Q_CORE_EXPORT QStringView value(QLatin1StringView qualifiedName) const;
Q_CORE_EXPORT void append(const QString &namespaceUri, const QString &name, const QString &value); Q_CORE_EXPORT void append(const QString &namespaceUri, const QString &name, const QString &value);
Q_CORE_EXPORT void append(const QString &qualifiedName, const QString &value); Q_CORE_EXPORT void append(const QString &qualifiedName, const QString &value);
@ -124,7 +124,7 @@ public:
return !value(qualifiedName).isNull(); return !value(qualifiedName).isNull();
} }
inline bool hasAttribute(QLatin1String qualifiedName) const inline bool hasAttribute(QLatin1StringView qualifiedName) const
{ {
return !value(qualifiedName).isNull(); return !value(qualifiedName).isNull();
} }

View File

@ -255,7 +255,7 @@ public:
Entity(const QString &name, const QString &value) Entity(const QString &name, const QString &value)
: name(name), value(value), external(false), unparsed(false), literal(false), : name(name), value(value), external(false), unparsed(false), literal(false),
hasBeenParsed(false), isCurrentlyReferenced(false){} hasBeenParsed(false), isCurrentlyReferenced(false){}
static inline Entity createLiteral(QLatin1String name, QLatin1String value) static inline Entity createLiteral(QLatin1StringView name, QLatin1StringView value)
{ Entity result(name, value); result.literal = result.hasBeenParsed = true; return result; } { Entity result(name, value); result.literal = result.hasBeenParsed = true; return result; }
QString name, value; QString name, value;
uint external : 1; uint external : 1;

View File

@ -189,7 +189,7 @@ public:
// defined in qstring.h // defined in qstring.h
inline QAnyStringView(const QByteArray &str) noexcept; // TODO: Should we have this at all? Remove? inline QAnyStringView(const QByteArray &str) noexcept; // TODO: Should we have this at all? Remove?
inline QAnyStringView(const QString &str) noexcept; inline QAnyStringView(const QString &str) noexcept;
inline constexpr QAnyStringView(QLatin1String str) noexcept; inline constexpr QAnyStringView(QLatin1StringView str) noexcept;
// defined in qstringbuilder.h // defined in qstringbuilder.h
template <typename A, typename B> template <typename A, typename B>
@ -308,7 +308,7 @@ private:
{ return Q_ASSERT(isUtf16()), QStringView{m_data_utf16, size()}; } { return Q_ASSERT(isUtf16()), QStringView{m_data_utf16, size()}; }
[[nodiscard]] constexpr q_no_char8_t::QUtf8StringView asUtf8StringView() const [[nodiscard]] constexpr q_no_char8_t::QUtf8StringView asUtf8StringView() const
{ return Q_ASSERT(isUtf8()), q_no_char8_t::QUtf8StringView{m_data_utf8, size()}; } { return Q_ASSERT(isUtf8()), q_no_char8_t::QUtf8StringView{m_data_utf8, size()}; }
[[nodiscard]] inline constexpr QLatin1String asLatin1StringView() const; [[nodiscard]] inline constexpr QLatin1StringView asLatin1StringView() const;
[[nodiscard]] constexpr size_t charSize() const noexcept { return isUtf16() ? 2 : 1; } [[nodiscard]] constexpr size_t charSize() const noexcept { return isUtf16() ? 2 : 1; }
Q_ALWAYS_INLINE constexpr void verify(qsizetype pos, qsizetype n = 0) const Q_ALWAYS_INLINE constexpr void verify(qsizetype pos, qsizetype n = 0) const
{ {

View File

@ -61,13 +61,13 @@
function to accept a wide variety of string data sources. One function to accept a wide variety of string data sources. One
function accepting QAnyStringView thus replaces five function function accepting QAnyStringView thus replaces five function
overloads (taking QString, \c{(const QChar*, int)}, overloads (taking QString, \c{(const QChar*, int)},
QUtf8StringView, QLatin1String (but see above), and QChar), while QUtf8StringView, QLatin1StringView (but see above), and QChar), while
at the same time enabling even more string data sources to be at the same time enabling even more string data sources to be
passed to the function, such as \c{u8"Hello World"}, a \c char8_t passed to the function, such as \c{u8"Hello World"}, a \c char8_t
string literal. string literal.
Like elsewhere in Qt, QAnyStringView assumes \c char data is encoded Like elsewhere in Qt, QAnyStringView assumes \c char data is encoded
in UTF-8, unless it is presented as a QLatin1String. in UTF-8, unless it is presented as a QLatin1StringView.
QAnyStringViews should be passed by value, not by reference-to-const: QAnyStringViews should be passed by value, not by reference-to-const:
\snippet code/src_corelib_text_qanystringview.cpp 0 \snippet code/src_corelib_text_qanystringview.cpp 0
@ -97,7 +97,7 @@
\endlist \endlist
The 8-bit character types are interpreted as UTF-8 data (except when The 8-bit character types are interpreted as UTF-8 data (except when
presented as a QLatin1String) while the 16-bit character types are presented as a QLatin1StringView) while the 16-bit character types are
interpreted as UTF-16 data in host byte order (the same as QString). interpreted as UTF-16 data in host byte order (the same as QString).
\section2 Sizes and Sub-Strings \section2 Sizes and Sub-Strings

View File

@ -98,7 +98,7 @@ struct IsContainerCompatibleWithQByteArrayView<T, std::enable_if_t<
// Don't make an accidental copy constructor // Don't make an accidental copy constructor
std::negation<std::is_same<std::decay_t<T>, QByteArrayView>>>>> : std::true_type {}; std::negation<std::is_same<std::decay_t<T>, QByteArrayView>>>>> : std::true_type {};
// Used by QLatin1String too // Used by QLatin1StringView too
template <typename Char> template <typename Char>
static constexpr qsizetype lengthHelperPointer(const Char *data) noexcept static constexpr qsizetype lengthHelperPointer(const Char *data) noexcept
{ {

View File

@ -68,7 +68,7 @@ QT_BEGIN_NAMESPACE
This class is only useful to construct a QChar with 8-bit character. This class is only useful to construct a QChar with 8-bit character.
\sa QChar, QLatin1String, QString \sa QChar, QLatin1StringView, QString
*/ */
/*! /*!

View File

@ -217,46 +217,46 @@ QLocale::Territory QLocalePrivate::codeToTerritory(QStringView code) noexcept
return QLocale::AnyTerritory; return QLocale::AnyTerritory;
} }
QLatin1String QLocalePrivate::languageToCode(QLocale::Language language, QLatin1StringView QLocalePrivate::languageToCode(QLocale::Language language,
QLocale::LanguageCodeTypes codeTypes) QLocale::LanguageCodeTypes codeTypes)
{ {
if (language == QLocale::AnyLanguage || language > QLocale::LastLanguage) if (language == QLocale::AnyLanguage || language > QLocale::LastLanguage)
return QLatin1String(); return {};
if (language == QLocale::C) if (language == QLocale::C)
return "C"_L1; return "C"_L1;
const LanguageCodeEntry &i = languageCodeList[language]; const LanguageCodeEntry &i = languageCodeList[language];
if (codeTypes.testFlag(QLocale::ISO639Part1) && i.part1.isValid()) if (codeTypes.testFlag(QLocale::ISO639Part1) && i.part1.isValid())
return QLatin1String(i.part1.code, 2); return QLatin1StringView(i.part1.code, 2);
if (codeTypes.testFlag(QLocale::ISO639Part2B) && i.part2B.isValid()) if (codeTypes.testFlag(QLocale::ISO639Part2B) && i.part2B.isValid())
return QLatin1String(i.part2B.code, 3); return QLatin1StringView(i.part2B.code, 3);
if (codeTypes.testFlag(QLocale::ISO639Part2T) && i.part2T.isValid()) if (codeTypes.testFlag(QLocale::ISO639Part2T) && i.part2T.isValid())
return QLatin1String(i.part2T.code, 3); return QLatin1StringView(i.part2T.code, 3);
if (codeTypes.testFlag(QLocale::ISO639Part3)) if (codeTypes.testFlag(QLocale::ISO639Part3))
return QLatin1String(i.part3.code, 3); return QLatin1StringView(i.part3.code, 3);
return QLatin1String(); return {};
} }
QLatin1String QLocalePrivate::scriptToCode(QLocale::Script script) QLatin1StringView QLocalePrivate::scriptToCode(QLocale::Script script)
{ {
if (script == QLocale::AnyScript || script > QLocale::LastScript) if (script == QLocale::AnyScript || script > QLocale::LastScript)
return QLatin1String(); return {};
const unsigned char *c = script_code_list + 4 * script; const unsigned char *c = script_code_list + 4 * script;
return QLatin1String(reinterpret_cast<const char *>(c), 4); return QLatin1StringView(reinterpret_cast<const char *>(c), 4);
} }
QLatin1String QLocalePrivate::territoryToCode(QLocale::Territory territory) QLatin1StringView QLocalePrivate::territoryToCode(QLocale::Territory territory)
{ {
if (territory == QLocale::AnyTerritory || territory > QLocale::LastTerritory) if (territory == QLocale::AnyTerritory || territory > QLocale::LastTerritory)
return QLatin1String(); return {};
const unsigned char *c = territory_code_list + 3 * territory; const unsigned char *c = territory_code_list + 3 * territory;
return QLatin1String(reinterpret_cast<const char*>(c), c[2] == 0 ? 2 : 3); return QLatin1StringView(reinterpret_cast<const char*>(c), c[2] == 0 ? 2 : 3);
} }
namespace { namespace {
@ -1553,7 +1553,7 @@ QString QLocale::languageToString(Language language)
{ {
if (language > QLocale::LastLanguage) if (language > QLocale::LastLanguage)
return "Unknown"_L1; return "Unknown"_L1;
return QLatin1String(language_name_list + language_name_index[language]); return QLatin1StringView(language_name_list + language_name_index[language]);
} }
/*! /*!
@ -1567,7 +1567,7 @@ QString QLocale::territoryToString(QLocale::Territory territory)
{ {
if (territory > QLocale::LastTerritory) if (territory > QLocale::LastTerritory)
return "Unknown"_L1; return "Unknown"_L1;
return QLatin1String(territory_name_list + territory_name_index[territory]); return QLatin1StringView(territory_name_list + territory_name_index[territory]);
} }
#if QT_DEPRECATED_SINCE(6, 6) #if QT_DEPRECATED_SINCE(6, 6)
@ -1595,7 +1595,7 @@ QString QLocale::scriptToString(QLocale::Script script)
{ {
if (script > QLocale::LastScript) if (script > QLocale::LastScript)
return "Unknown"_L1; return "Unknown"_L1;
return QLatin1String(script_name_list + script_name_index[script]); return QLatin1StringView(script_name_list + script_name_index[script]);
} }
#if QT_STRINGVIEW_LEVEL < 2 #if QT_STRINGVIEW_LEVEL < 2

View File

@ -419,22 +419,22 @@ public:
[[nodiscard]] QByteArray bcp47Name(char separator = '-') const; [[nodiscard]] QByteArray bcp47Name(char separator = '-') const;
[[nodiscard]] inline QLatin1String [[nodiscard]] inline QLatin1StringView
languageCode(QLocale::LanguageCodeTypes codeTypes = QLocale::AnyLanguageCode) const languageCode(QLocale::LanguageCodeTypes codeTypes = QLocale::AnyLanguageCode) const
{ {
return languageToCode(QLocale::Language(m_data->m_language_id), codeTypes); return languageToCode(QLocale::Language(m_data->m_language_id), codeTypes);
} }
[[nodiscard]] inline QLatin1String scriptCode() const [[nodiscard]] inline QLatin1StringView scriptCode() const
{ return scriptToCode(QLocale::Script(m_data->m_script_id)); } { return scriptToCode(QLocale::Script(m_data->m_script_id)); }
[[nodiscard]] inline QLatin1String territoryCode() const [[nodiscard]] inline QLatin1StringView territoryCode() const
{ return territoryToCode(QLocale::Territory(m_data->m_territory_id)); } { return territoryToCode(QLocale::Territory(m_data->m_territory_id)); }
[[nodiscard]] static const QLocalePrivate *get(const QLocale &l) { return l.d; } [[nodiscard]] static const QLocalePrivate *get(const QLocale &l) { return l.d; }
[[nodiscard]] static QLatin1String [[nodiscard]] static QLatin1StringView
languageToCode(QLocale::Language language, languageToCode(QLocale::Language language,
QLocale::LanguageCodeTypes codeTypes = QLocale::AnyLanguageCode); QLocale::LanguageCodeTypes codeTypes = QLocale::AnyLanguageCode);
[[nodiscard]] static QLatin1String scriptToCode(QLocale::Script script); [[nodiscard]] static QLatin1StringView scriptToCode(QLocale::Script script);
[[nodiscard]] static QLatin1String territoryToCode(QLocale::Territory territory); [[nodiscard]] static QLatin1StringView territoryToCode(QLocale::Territory territory);
[[nodiscard]] static QLocale::Language [[nodiscard]] static QLocale::Language
codeToLanguage(QStringView code, codeToLanguage(QStringView code,
QLocale::LanguageCodeTypes codeTypes = QLocale::AnyLanguageCode) noexcept; QLocale::LanguageCodeTypes codeTypes = QLocale::AnyLanguageCode) noexcept;

View File

@ -629,7 +629,7 @@ QString qdtoa(qreal d, int *decpt, int *sign)
if (decpt) if (decpt)
*decpt = nonNullDecpt; *decpt = nonNullDecpt;
return QLatin1String(result, length); return QLatin1StringView(result, length);
} }
static QLocaleData::DoubleForm resolveFormat(int precision, int decpt, qsizetype length) static QLocaleData::DoubleForm resolveFormat(int precision, int decpt, qsizetype length)
@ -706,7 +706,7 @@ static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool u
int length = 0; int length = 0;
int decpt = 0; int decpt = 0;
qt_doubleToAscii(d, form, precision, buffer.data(), buffer.length(), negative, length, decpt); qt_doubleToAscii(d, form, precision, buffer.data(), buffer.length(), negative, length, decpt);
QLatin1String view(buffer.data(), buffer.data() + length); QLatin1StringView view(buffer.data(), length);
const bool succinct = form == QLocaleData::DFSignificantDigits; const bool succinct = form == QLocaleData::DFSignificantDigits;
qsizetype total = (negative ? 1 : 0) + length; qsizetype total = (negative ? 1 : 0) + length;
if (qIsFinite(d)) { if (qIsFinite(d)) {

View File

@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
\list \list
\li QString, (since 5.10:) QStringView \li QString, (since 5.10:) QStringView
\li QChar, QLatin1Char, (since 5.10:) \c char16_t, \li QChar, QLatin1Char, (since 5.10:) \c char16_t,
\li QLatin1String, \li QLatin1StringView,
\li (since 5.10:) \c{const char16_t[]} (\c{u"foo"}), \li (since 5.10:) \c{const char16_t[]} (\c{u"foo"}),
\li QByteArray, \c char, \c{const char[]}. \li QByteArray, \c char, \c{const char[]}.
\endlist \endlist
@ -93,7 +93,7 @@ QT_BEGIN_NAMESPACE
if there are three or more of them, and performs equally well in other if there are three or more of them, and performs equally well in other
cases. cases.
\sa QLatin1String, QString \sa QLatin1StringView, QString
*/ */
/*! \fn template <typename A, typename B> QStringBuilder<A, B>::QStringBuilder(const A &a, const B &b) /*! \fn template <typename A, typename B> QStringBuilder<A, B>::QStringBuilder(const A &a, const B &b)
@ -107,7 +107,7 @@ QT_BEGIN_NAMESPACE
takes a QString parameter. takes a QString parameter.
This function is usable with arguments of type \c QString, This function is usable with arguments of type \c QString,
\c QLatin1String, \c QLatin1StringView,
\c QChar, \c QLatin1Char, and \c char. \c QChar, \c QLatin1Char, and \c char.
*/ */

View File

@ -63,7 +63,7 @@ protected:
{ {
*out++ = QLatin1Char(a); *out++ = QLatin1Char(a);
} }
static void appendLatin1To(QLatin1String in, QChar *out) noexcept; static void appendLatin1To(QLatin1StringView in, QChar *out) noexcept;
}; };
template <typename T> struct QConcatenable {}; template <typename T> struct QConcatenable {};
@ -250,18 +250,18 @@ template <> struct QConcatenable<QChar::SpecialCharacter> : private QAbstractCon
{ *out++ = c; } { *out++ = c; }
}; };
template <> struct QConcatenable<QLatin1String> : private QAbstractConcatenable template <> struct QConcatenable<QLatin1StringView> : private QAbstractConcatenable
{ {
typedef QLatin1String type; typedef QLatin1StringView type;
typedef QString ConvertTo; typedef QString ConvertTo;
enum { ExactSize = true }; enum { ExactSize = true };
static qsizetype size(const QLatin1String a) { return a.size(); } static qsizetype size(const QLatin1StringView a) { return a.size(); }
static inline void appendTo(const QLatin1String a, QChar *&out) static inline void appendTo(const QLatin1StringView a, QChar *&out)
{ {
appendLatin1To(a, out); appendLatin1To(a, out);
out += a.size(); out += a.size();
} }
static inline void appendTo(const QLatin1String a, char *&out) static inline void appendTo(const QLatin1StringView a, char *&out)
{ {
if (const char *data = a.data()) { if (const char *data = a.data()) {
memcpy(out, data, a.size()); memcpy(out, data, a.size());

View File

@ -353,7 +353,7 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QStringView str,
} }
/*! /*!
\fn bool QStringList::contains(QLatin1String str, Qt::CaseSensitivity cs) const \fn bool QStringList::contains(QLatin1StringView str, Qt::CaseSensitivity cs) const
\overload \overload
\since 5.10 \since 5.10
@ -363,7 +363,7 @@ bool QtPrivate::QStringList_contains(const QStringList *that, QStringView str,
\sa indexOf(), lastIndexOf(), QString::contains() \sa indexOf(), lastIndexOf(), QString::contains()
*/ */
bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1String str, bool QtPrivate::QStringList_contains(const QStringList *that, QLatin1StringView str,
Qt::CaseSensitivity cs) Qt::CaseSensitivity cs)
{ {
return stringList_contains(*that, str, cs); return stringList_contains(*that, str, cs);
@ -509,11 +509,11 @@ QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, q
} }
/*! /*!
\fn QString QStringList::join(QLatin1String separator) const \fn QString QStringList::join(QLatin1StringView separator) const
\since 5.8 \since 5.8
\overload join() \overload join()
*/ */
QString QtPrivate::QStringList_join(const QStringList &list, QLatin1String sep) QString QtPrivate::QStringList_join(const QStringList &list, QLatin1StringView sep)
{ {
QString result; QString result;
if (!list.isEmpty()) { if (!list.isEmpty()) {

View File

@ -63,11 +63,11 @@ namespace QtPrivate {
qsizetype Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that); qsizetype Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep); QString Q_CORE_EXPORT QStringList_join(const QStringList *that, QStringView sep);
QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, qsizetype seplen); QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, qsizetype seplen);
Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1String sep); Q_CORE_EXPORT QString QStringList_join(const QStringList &list, QLatin1StringView sep);
QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str, QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, QStringView str,
Qt::CaseSensitivity cs); Qt::CaseSensitivity cs);
bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QStringView str, Qt::CaseSensitivity cs); bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QStringView str, Qt::CaseSensitivity cs);
bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QLatin1String str, Qt::CaseSensitivity cs); bool Q_CORE_EXPORT QStringList_contains(const QStringList *that, QLatin1StringView str, Qt::CaseSensitivity cs);
void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, QStringView before, QStringView after, void Q_CORE_EXPORT QStringList_replaceInStrings(QStringList *that, QStringView before, QStringView after,
Qt::CaseSensitivity cs); Qt::CaseSensitivity cs);
@ -109,7 +109,7 @@ public:
inline QString join(QStringView sep) const inline QString join(QStringView sep) const
{ return QtPrivate::QStringList_join(self(), sep); } { return QtPrivate::QStringList_join(self(), sep); }
inline QString join(QLatin1String sep) const inline QString join(QLatin1StringView sep) const
{ return QtPrivate::QStringList_join(*self(), sep); } { return QtPrivate::QStringList_join(*self(), sep); }
inline QString join(QChar sep) const inline QString join(QChar sep) const
{ return QtPrivate::QStringList_join(self(), &sep, 1); } { return QtPrivate::QStringList_join(self(), &sep, 1); }
@ -147,7 +147,7 @@ public:
using QListSpecialMethodsBase<QString>::indexOf; using QListSpecialMethodsBase<QString>::indexOf;
using QListSpecialMethodsBase<QString>::lastIndexOf; using QListSpecialMethodsBase<QString>::lastIndexOf;
inline bool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept inline bool contains(QLatin1StringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::QStringList_contains(self(), str, cs); } { return QtPrivate::QStringList_contains(self(), str, cs); }
inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept inline bool contains(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::QStringList_contains(self(), str, cs); } { return QtPrivate::QStringList_contains(self(), str, cs); }

View File

@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
Argument Deduction (CTAD), you may write Argument Deduction (CTAD), you may write
\c{QStringTokenizer{string, separator}} (without template \c{QStringTokenizer{string, separator}} (without template
arguments). If you can't use C++17 CTAD, you must use the arguments). If you can't use C++17 CTAD, you must use the
QStringView::split() or QLatin1String::split() member functions QStringView::split() or QLatin1StringView::split() member functions
and store the return value only in \c{auto} variables: and store the return value only in \c{auto} variables:
\code \code
@ -149,7 +149,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\typealias QStringTokenizer::value_type \typealias QStringTokenizer::value_type
Alias for \c{const QStringView} or \c{const QLatin1String}, Alias for \c{const QStringView} or \c{const QLatin1StringView},
depending on the tokenizer's \c Haystack template argument. depending on the tokenizer's \c Haystack template argument.
*/ */

View File

@ -168,7 +168,7 @@ namespace Tok {
template <typename String> struct ViewForImpl {}; template <typename String> struct ViewForImpl {};
template <> struct ViewForImpl<QStringView> { using type = QStringView; }; template <> struct ViewForImpl<QStringView> { using type = QStringView; };
template <> struct ViewForImpl<QLatin1String> { using type = QLatin1String; }; template <> struct ViewForImpl<QLatin1StringView> { using type = QLatin1StringView; };
template <> struct ViewForImpl<QChar> { using type = QChar; }; template <> struct ViewForImpl<QChar> { using type = QChar; };
template <> struct ViewForImpl<QString> : ViewForImpl<QStringView> {}; template <> struct ViewForImpl<QString> : ViewForImpl<QStringView> {};
template <> struct ViewForImpl<QLatin1Char> : ViewForImpl<QChar> {}; template <> struct ViewForImpl<QLatin1Char> : ViewForImpl<QChar> {};
@ -185,7 +185,7 @@ namespace Tok {
#endif #endif
// This metafunction maps a StringLike to a View (currently, QChar, // This metafunction maps a StringLike to a View (currently, QChar,
// QStringView, QLatin1String). This is what QStringTokenizerBase // QStringView, QLatin1StringView). This is what QStringTokenizerBase
// operates on. QStringTokenizer adds pinning to keep rvalues alive // operates on. QStringTokenizer adds pinning to keep rvalues alive
// for the duration of the algorithm. // for the duration of the algorithm.
template <typename String> template <typename String>

View File

@ -87,11 +87,11 @@ QT_BEGIN_NAMESPACE
QChar constructor by itself. QChar constructor by itself.
\li \e QString: if you store an unmodified copy of the string and thus would \li \e QString: if you store an unmodified copy of the string and thus would
like to take advantage of QString's implicit sharing. like to take advantage of QString's implicit sharing.
\li QLatin1String: if you can implement the function without converting the \li QLatin1StringView: if you can implement the function without converting the
QLatin1String to UTF-16 first; users expect a function overloaded on QLatin1StringView to UTF-16 first; users expect a function overloaded on
QLatin1String to perform strictly less memory allocations than the QLatin1StringView to perform strictly less memory allocations than the
semantically equivalent call of the QStringView version, involving semantically equivalent call of the QStringView version, involving
construction of a QString from the QLatin1String. construction of a QString from the QLatin1StringView.
\endlist \endlist
QStringView can also be used as the return value of a function. If you call a QStringView can also be used as the return value of a function. If you call a
@ -564,7 +564,7 @@ QT_BEGIN_NAMESPACE
second of the \a args the \c{%N} with the next-lowest \c{N} etc. second of the \a args the \c{%N} with the next-lowest \c{N} etc.
\c Args can consist of anything that implicitly converts to QString, \c Args can consist of anything that implicitly converts to QString,
QStringView or QLatin1String. QStringView or QLatin1StringView.
In addition, the following types are also supported: QChar, QLatin1Char. In addition, the following types are also supported: QChar, QLatin1Char.
@ -779,7 +779,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn int QStringView::compare(QLatin1String l1, Qt::CaseSensitivity cs) const \fn int QStringView::compare(QLatin1StringView l1, Qt::CaseSensitivity cs) const
\fn int QStringView::compare(QChar ch) const \fn int QStringView::compare(QChar ch) const
\fn int QStringView::compare(QChar ch, Qt::CaseSensitivity cs) const \fn int QStringView::compare(QChar ch, Qt::CaseSensitivity cs) const
\since 5.15 \since 5.15
@ -823,7 +823,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn bool QStringView::startsWith(QStringView str, Qt::CaseSensitivity cs) const \fn bool QStringView::startsWith(QStringView str, Qt::CaseSensitivity cs) const
\fn bool QStringView::startsWith(QLatin1String l1, Qt::CaseSensitivity cs) const \fn bool QStringView::startsWith(QLatin1StringView l1, Qt::CaseSensitivity cs) const
\fn bool QStringView::startsWith(QChar ch) const \fn bool QStringView::startsWith(QChar ch) const
\fn bool QStringView::startsWith(QChar ch, Qt::CaseSensitivity cs) const \fn bool QStringView::startsWith(QChar ch, Qt::CaseSensitivity cs) const
@ -839,7 +839,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn bool QStringView::endsWith(QStringView str, Qt::CaseSensitivity cs) const \fn bool QStringView::endsWith(QStringView str, Qt::CaseSensitivity cs) const
\fn bool QStringView::endsWith(QLatin1String l1, Qt::CaseSensitivity cs) const \fn bool QStringView::endsWith(QLatin1StringView l1, Qt::CaseSensitivity cs) const
\fn bool QStringView::endsWith(QChar ch) const \fn bool QStringView::endsWith(QChar ch) const
\fn bool QStringView::endsWith(QChar ch, Qt::CaseSensitivity cs) const \fn bool QStringView::endsWith(QChar ch, Qt::CaseSensitivity cs) const
@ -855,7 +855,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn qsizetype QStringView::indexOf(QStringView str, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const \fn qsizetype QStringView::indexOf(QStringView str, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\fn qsizetype QStringView::indexOf(QLatin1String l1, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const \fn qsizetype QStringView::indexOf(QLatin1StringView l1, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\fn qsizetype QStringView::indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const \fn qsizetype QStringView::indexOf(QChar c, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\since 5.14 \since 5.14
@ -874,7 +874,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn bool QStringView::contains(QStringView str, Qt::CaseSensitivity cs) const \fn bool QStringView::contains(QStringView str, Qt::CaseSensitivity cs) const
\fn bool QStringView::contains(QLatin1String l1, Qt::CaseSensitivity cs) const \fn bool QStringView::contains(QLatin1StringView l1, Qt::CaseSensitivity cs) const
\fn bool QStringView::contains(QChar c, Qt::CaseSensitivity cs) const \fn bool QStringView::contains(QChar c, Qt::CaseSensitivity cs) const
\since 5.14 \since 5.14
@ -889,7 +889,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn qsizetype QStringView::lastIndexOf(QStringView str, qsizetype from, Qt::CaseSensitivity cs) const \fn qsizetype QStringView::lastIndexOf(QStringView str, qsizetype from, Qt::CaseSensitivity cs) const
\fn qsizetype QStringView::lastIndexOf(QLatin1String l1, qsizetype from, Qt::CaseSensitivity cs) const \fn qsizetype QStringView::lastIndexOf(QLatin1StringView l1, qsizetype from, Qt::CaseSensitivity cs) const
\fn qsizetype QStringView::lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs) const \fn qsizetype QStringView::lastIndexOf(QChar c, qsizetype from, Qt::CaseSensitivity cs) const
\since 5.14 \since 5.14
@ -915,7 +915,7 @@ QT_BEGIN_NAMESPACE
/*! /*!
\fn qsizetype QStringView::lastIndexOf(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const \fn qsizetype QStringView::lastIndexOf(QStringView str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\fn qsizetype QStringView::lastIndexOf(QLatin1String l1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const \fn qsizetype QStringView::lastIndexOf(QLatin1StringView l1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
\since 6.2 \since 6.2
\overload lastIndexOf() \overload lastIndexOf()
@ -1168,7 +1168,7 @@ QT_BEGIN_NAMESPACE
*/ */
/*! /*!
\fn qsizetype QStringView::count(QLatin1String l1, Qt::CaseSensitivity cs) const noexcept \fn qsizetype QStringView::count(QLatin1StringView l1, Qt::CaseSensitivity cs) const noexcept
\since 6.4 \since 6.4
\overload count() \overload count()

View File

@ -303,7 +303,7 @@ public:
[[nodiscard]] int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] int compare(QStringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::compareStrings(*this, other, cs); } { return QtPrivate::compareStrings(*this, other, cs); }
[[nodiscard]] inline int compare(QLatin1String other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] inline int compare(QLatin1StringView other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] constexpr int compare(QChar c) const noexcept [[nodiscard]] constexpr int compare(QChar c) const noexcept
{ return size() >= 1 ? compare_single_char_helper(*utf16() - c.unicode()) : -1; } { return size() >= 1 ? compare_single_char_helper(*utf16() - c.unicode()) : -1; }
[[nodiscard]] int compare(QChar c, Qt::CaseSensitivity cs) const noexcept [[nodiscard]] int compare(QChar c, Qt::CaseSensitivity cs) const noexcept
@ -313,7 +313,7 @@ public:
[[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] bool startsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::startsWith(*this, s, cs); } { return QtPrivate::startsWith(*this, s, cs); }
[[nodiscard]] inline bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] inline bool startsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] bool startsWith(QChar c) const noexcept [[nodiscard]] bool startsWith(QChar c) const noexcept
{ return !empty() && front() == c; } { return !empty() && front() == c; }
[[nodiscard]] bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept [[nodiscard]] bool startsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
@ -321,7 +321,7 @@ public:
[[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] bool endsWith(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::endsWith(*this, s, cs); } { return QtPrivate::endsWith(*this, s, cs); }
[[nodiscard]] inline bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] inline bool endsWith(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] bool endsWith(QChar c) const noexcept [[nodiscard]] bool endsWith(QChar c) const noexcept
{ return !empty() && back() == c; } { return !empty() && back() == c; }
[[nodiscard]] bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept [[nodiscard]] bool endsWith(QChar c, Qt::CaseSensitivity cs) const noexcept
@ -331,19 +331,19 @@ public:
{ return QtPrivate::findString(*this, from, QStringView(&c, 1), cs); } { return QtPrivate::findString(*this, from, QStringView(&c, 1), cs); }
[[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] qsizetype indexOf(QStringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::findString(*this, from, s, cs); } { return QtPrivate::findString(*this, from, s, cs); }
[[nodiscard]] inline qsizetype indexOf(QLatin1String s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] inline qsizetype indexOf(QLatin1StringView s, qsizetype from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] bool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(QStringView(&c, 1), 0, cs) != qsizetype(-1); } { return indexOf(QStringView(&c, 1), 0, cs) != qsizetype(-1); }
[[nodiscard]] bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] bool contains(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return indexOf(s, 0, cs) != qsizetype(-1); } { return indexOf(s, 0, cs) != qsizetype(-1); }
[[nodiscard]] inline bool contains(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] inline bool contains(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] qsizetype count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::count(*this, c, cs); } { return QtPrivate::count(*this, c, cs); }
[[nodiscard]] qsizetype count(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] qsizetype count(QStringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::count(*this, s, cs); } { return QtPrivate::count(*this, s, cs); }
[[nodiscard]] inline qsizetype count(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; [[nodiscard]] inline qsizetype count(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
[[nodiscard]] qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return lastIndexOf(c, -1, cs); } { return lastIndexOf(c, -1, cs); }
@ -353,8 +353,8 @@ public:
{ return lastIndexOf(s, size(), cs); } { return lastIndexOf(s, size(), cs); }
[[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept [[nodiscard]] qsizetype lastIndexOf(QStringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept
{ return QtPrivate::lastIndexOf(*this, from, s, cs); } { return QtPrivate::lastIndexOf(*this, from, s, cs); }
[[nodiscard]] inline qsizetype lastIndexOf(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] inline qsizetype lastIndexOf(QLatin1StringView s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
[[nodiscard]] inline qsizetype lastIndexOf(QLatin1String s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept; [[nodiscard]] inline qsizetype lastIndexOf(QLatin1StringView s, qsizetype from, Qt::CaseSensitivity cs = Qt::CaseSensitive) const noexcept;
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
[[nodiscard]] qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0, QRegularExpressionMatch *rmatch = nullptr) const [[nodiscard]] qsizetype indexOf(const QRegularExpression &re, qsizetype from = 0, QRegularExpressionMatch *rmatch = nullptr) const

View File

@ -96,7 +96,7 @@ struct IsContainerCompatibleWithQUtf8StringView<T, std::enable_if_t<std::conjunc
std::negation<std::is_same<std::decay_t<T>, QByteArray>>, std::negation<std::is_same<std::decay_t<T>, QByteArray>>,
// This has a compatible value_type, but explicitly a different encoding // This has a compatible value_type, but explicitly a different encoding
std::negation<std::is_same<std::decay_t<T>, QLatin1String>>, std::negation<std::is_same<std::decay_t<T>, QLatin1StringView>>,
// Don't make an accidental copy constructor // Don't make an accidental copy constructor
std::negation<std::disjunction< std::negation<std::disjunction<

View File

@ -147,7 +147,7 @@ public:
explicit QCalendar(); // Gregorian, optimised explicit QCalendar(); // Gregorian, optimised
explicit QCalendar(System system); explicit QCalendar(System system);
#if QT_CORE_REMOVED_SINCE(6, 4) #if QT_CORE_REMOVED_SINCE(6, 4)
explicit QCalendar(QLatin1String name); explicit QCalendar(QLatin1StringView name);
explicit QCalendar(QStringView name); explicit QCalendar(QStringView name);
#endif #endif
explicit QCalendar(QAnyStringView name); explicit QCalendar(QAnyStringView name);

View File

@ -123,7 +123,7 @@ static const char qt_shortMonthNames[][4] = {
static int fromShortMonthName(QStringView monthName) static int fromShortMonthName(QStringView monthName)
{ {
for (unsigned int i = 0; i < sizeof(qt_shortMonthNames) / sizeof(qt_shortMonthNames[0]); ++i) { for (unsigned int i = 0; i < sizeof(qt_shortMonthNames) / sizeof(qt_shortMonthNames[0]); ++i) {
if (monthName == QLatin1String(qt_shortMonthNames[i], 3)) if (monthName == QLatin1StringView(qt_shortMonthNames[i], 3))
return i + 1; return i + 1;
} }
return -1; return -1;

View File

@ -121,9 +121,9 @@ QByteArray QTimeZonePrivate::id() const
QLocale::Territory QTimeZonePrivate::territory() const QLocale::Territory QTimeZonePrivate::territory() const
{ {
// Default fall-back mode, use the zoneTable to find Region of known Zones // Default fall-back mode, use the zoneTable to find Region of known Zones
const QLatin1String sought(m_id.data(), m_id.size()); const QLatin1StringView sought(m_id.data(), m_id.size());
for (const QZoneData &data : zoneDataTable) { for (const QZoneData &data : zoneDataTable) {
for (QLatin1String token : data.ids()) { for (QLatin1StringView token : data.ids()) {
if (token == sought) if (token == sought)
return QLocale::Territory(data.territory); return QLocale::Territory(data.territory);
} }

View File

@ -80,7 +80,7 @@ struct QZoneData
quint16 windowsIdKey; // Windows ID Key quint16 windowsIdKey; // Windows ID Key
quint16 territory; // Territory of IANA ID's, AnyTerritory means No Territory quint16 territory; // Territory of IANA ID's, AnyTerritory means No Territory
quint16 ianaIdIndex; // All IANA ID's for the Windows ID and Country, space separated quint16 ianaIdIndex; // All IANA ID's for the Windows ID and Country, space separated
inline QLatin1String id() const; inline QLatin1StringView id() const;
inline auto ids() const { return id().tokenize(u' '); } inline auto ids() const { return id().tokenize(u' '); }
}; };
@ -1272,7 +1272,8 @@ static const char ianaIdData[] = {
inline QByteArrayView QWindowsData::windowsId() const { return windowsIdData + windowsIdIndex; } inline QByteArrayView QWindowsData::windowsId() const { return windowsIdData + windowsIdIndex; }
inline QByteArrayView QWindowsData::ianaId() const { return ianaIdData + ianaIdIndex; } inline QByteArrayView QWindowsData::ianaId() const { return ianaIdData + ianaIdIndex; }
inline QByteArrayView QUtcData::id() const { return ianaIdData + ianaIdIndex; } inline QByteArrayView QUtcData::id() const { return ianaIdData + ianaIdIndex; }
inline QLatin1String QZoneData::id() const { return QLatin1String(ianaIdData + ianaIdIndex); } inline QLatin1StringView QZoneData::id() const
{ return QLatin1StringView(ianaIdData + ianaIdIndex); }
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -491,7 +491,7 @@ QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds() const
QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(QLocale::Territory territory) const
{ {
const QLatin1String regionCode = QLocalePrivate::territoryToCode(territory); const QLatin1StringView regionCode = QLocalePrivate::territoryToCode(territory);
const QByteArray regionCodeUtf8 = QString(regionCode).toUtf8(); const QByteArray regionCodeUtf8 = QString(regionCode).toUtf8();
UErrorCode status = U_ZERO_ERROR; UErrorCode status = U_ZERO_ERROR;
UEnumeration *uenum = ucal_openCountryTimeZones(regionCodeUtf8.data(), &status); UEnumeration *uenum = ucal_openCountryTimeZones(regionCodeUtf8.data(), &status);

View File

@ -1153,7 +1153,7 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const
QString optionNamesString; QString optionNamesString;
for (const QString &optionName : optionNames) { for (const QString &optionName : optionNames) {
const int numDashes = optionName.length() == 1 ? 1 : 2; const int numDashes = optionName.length() == 1 ? 1 : 2;
optionNamesString += QLatin1String("--", numDashes) + optionName + ", "_L1; optionNamesString += QLatin1StringView("--", numDashes) + optionName + ", "_L1;
} }
if (!optionNames.isEmpty()) if (!optionNames.isEmpty())
optionNamesString.chop(2); // remove trailing ", " optionNamesString.chop(2); // remove trailing ", "

View File

@ -1019,7 +1019,7 @@ size_t qHash(const QBitArray &bitArray, size_t seed) noexcept
return result; return result;
} }
size_t qHash(QLatin1String key, size_t seed) noexcept size_t qHash(QLatin1StringView key, size_t seed) noexcept
{ {
return qHashBits(reinterpret_cast<const uchar *>(key.data()), size_t(key.size()), seed); return qHashBits(reinterpret_cast<const uchar *>(key.data()), size_t(key.size()), seed);
} }
@ -1541,7 +1541,7 @@ size_t qHash(long double key, size_t seed) noexcept
Returns the hash value for the \a key, using \a seed to seed the calculation. Returns the hash value for the \a key, using \a seed to seed the calculation.
*/ */
/*! \fn size_t qHash(QLatin1String key, size_t seed = 0) /*! \fn size_t qHash(QLatin1StringView key, size_t seed = 0)
\relates QHash \relates QHash
\since 5.0 \since 5.0

View File

@ -188,7 +188,7 @@ inline Q_DECL_PURE_FUNCTION size_t qHash(const QString &key, size_t seed = 0) no
{ return qHash(QStringView{key}, seed); } { return qHash(QStringView{key}, seed); }
#endif #endif
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(const QBitArray &key, size_t seed = 0) noexcept;
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1String key, size_t seed = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION size_t qHash(QLatin1StringView key, size_t seed = 0) noexcept;
Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(QKeyCombination key, size_t seed = 0) noexcept Q_DECL_CONST_FUNCTION constexpr inline size_t qHash(QKeyCombination key, size_t seed = 0) noexcept
{ return qHash(key.toCombined(), seed); } { return qHash(key.toCombined(), seed); }
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) noexcept; Q_CORE_EXPORT Q_DECL_PURE_FUNCTION uint qt_hash(QStringView key, uint chained = 0) noexcept;
@ -340,7 +340,7 @@ template <typename T1, typename T2> inline size_t qHash(const std::pair<T1, T2>
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QString) QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QString)
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QStringView) QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QStringView)
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QLatin1String) QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_VALUE(QLatin1StringView)
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QByteArray) QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QByteArray)
QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QBitArray) QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH_BY_CREF(QBitArray)

View File

@ -424,12 +424,12 @@ QString QVersionNumber::toString() const
\snippet qversionnumber/main.cpp 3-latin1-1 \snippet qversionnumber/main.cpp 3-latin1-1
\note In versions prior to Qt 6.4, this function was overloaded for QString, \note In versions prior to Qt 6.4, this function was overloaded for QString,
QLatin1String and QStringView instead, and \a suffixIndex was an \c{int*}. QLatin1StringView and QStringView instead, and \a suffixIndex was an \c{int*}.
\sa isNull() \sa isNull()
*/ */
static QVersionNumber from_string(QLatin1String string, qsizetype *suffixIndex) static QVersionNumber from_string(QLatin1StringView string, qsizetype *suffixIndex)
{ {
// 32 should be more than enough, and, crucially, it means we're allocating // 32 should be more than enough, and, crucially, it means we're allocating
// not more (and often less) often when compared with direct QList usage // not more (and often less) often when compared with direct QList usage
@ -462,7 +462,7 @@ static QVersionNumber from_string(QLatin1String string, qsizetype *suffixIndex)
static QVersionNumber from_string(q_no_char8_t::QUtf8StringView string, qsizetype *suffixIndex) static QVersionNumber from_string(q_no_char8_t::QUtf8StringView string, qsizetype *suffixIndex)
{ {
return from_string(QLatin1String(string.data(), string.size()), suffixIndex); return from_string(QLatin1StringView(string.data(), string.size()), suffixIndex);
} }
// in qstring.cpp // in qstring.cpp
@ -473,7 +473,7 @@ static QVersionNumber from_string(QStringView string, qsizetype *suffixIndex)
QVarLengthArray<char> copy; QVarLengthArray<char> copy;
copy.resize(string.size()); copy.resize(string.size());
qt_to_latin1(reinterpret_cast<uchar*>(copy.data()), string.utf16(), string.size()); qt_to_latin1(reinterpret_cast<uchar*>(copy.data()), string.utf16(), string.size());
return from_string(QLatin1String(copy.data(), copy.size()), suffixIndex); return from_string(QLatin1StringView(copy.data(), copy.size()), suffixIndex);
} }
QVersionNumber QVersionNumber::fromString(QAnyStringView string, qsizetype *suffixIndex) QVersionNumber QVersionNumber::fromString(QAnyStringView string, qsizetype *suffixIndex)

View File

@ -307,7 +307,7 @@ public:
#if QT_CORE_REMOVED_SINCE(6, 4) #if QT_CORE_REMOVED_SINCE(6, 4)
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex); [[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(const QString &string, int *suffixIndex);
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QLatin1String string, int *suffixIndex); [[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QLatin1StringView string, int *suffixIndex);
[[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex); [[nodiscard]] Q_CORE_EXPORT static QVersionNumber fromString(QStringView string, int *suffixIndex);
#endif #endif