summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp4
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp18
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp16
-rw-r--r--src/corelib/doc/snippets/hellotrmain.cpp4
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp6
-rw-r--r--src/corelib/doc/snippets/qstring/stringbuilder.cpp4
-rw-r--r--src/corelib/global/qconfig.cpp.in2
-rw-r--r--src/corelib/global/qglobal.cpp33
-rw-r--r--src/corelib/global/qlibraryinfo.cpp37
-rw-r--r--src/corelib/global/qlogging.cpp62
-rw-r--r--src/corelib/io/qabstractfileengine.cpp4
-rw-r--r--src/corelib/io/qdataurl.cpp2
-rw-r--r--src/corelib/io/qdebug.cpp10
-rw-r--r--src/corelib/io/qdir.cpp133
-rw-r--r--src/corelib/io/qdiriterator.cpp10
-rw-r--r--src/corelib/io/qfile.cpp6
-rw-r--r--src/corelib/io/qfileinfo.cpp41
-rw-r--r--src/corelib/io/qfileselector.cpp18
-rw-r--r--src/corelib/io/qfilesystemengine.cpp11
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp38
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp61
-rw-r--r--src/corelib/io/qfilesystementry.cpp40
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp20
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp8
-rw-r--r--src/corelib/io/qfilesystemwatcher_polling.cpp8
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp20
-rw-r--r--src/corelib/io/qfsfileengine.cpp10
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp16
-rw-r--r--src/corelib/io/qiodevice.cpp18
-rw-r--r--src/corelib/io/qipaddress.cpp14
-rw-r--r--src/corelib/io/qlockfile.cpp4
-rw-r--r--src/corelib/io/qlockfile_win.cpp4
-rw-r--r--src/corelib/io/qloggingregistry.cpp33
-rw-r--r--src/corelib/io/qprocess.cpp6
-rw-r--r--src/corelib/io/qprocess_unix.cpp12
-rw-r--r--src/corelib/io/qprocess_win.cpp36
-rw-r--r--src/corelib/io/qresource.cpp54
-rw-r--r--src/corelib/io/qsavefile.cpp6
-rw-r--r--src/corelib/io/qsettings.cpp106
-rw-r--r--src/corelib/io/qsettings_mac.cpp53
-rw-r--r--src/corelib/io/qsettings_wasm.cpp4
-rw-r--r--src/corelib/io/qsettings_win.cpp48
-rw-r--r--src/corelib/io/qstandardpaths.cpp23
-rw-r--r--src/corelib/io/qstandardpaths_android.cpp12
-rw-r--r--src/corelib/io/qstandardpaths_haiku.cpp4
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm28
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp82
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp14
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp17
-rw-r--r--src/corelib/io/qstorageinfo_win.cpp10
-rw-r--r--src/corelib/io/qtemporarydir.cpp10
-rw-r--r--src/corelib/io/qtemporaryfile.cpp12
-rw-r--r--src/corelib/io/qurl.cpp128
-rw-r--r--src/corelib/io/qurlidna.cpp20
-rw-r--r--src/corelib/io/qwindowspipereader.cpp4
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp20
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp52
-rw-r--r--src/corelib/kernel/qjniobject.cpp4
-rw-r--r--src/corelib/kernel/qmetaobject.cpp6
-rw-r--r--src/corelib/kernel/qmimedata.cpp12
-rw-r--r--src/corelib/kernel/qsharedmemory.cpp24
-rw-r--r--src/corelib/kernel/qsharedmemory_posix.cpp18
-rw-r--r--src/corelib/kernel/qsharedmemory_systemv.cpp24
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp14
-rw-r--r--src/corelib/kernel/qsystemerror.cpp8
-rw-r--r--src/corelib/kernel/qsystemsemaphore_posix.cpp16
-rw-r--r--src/corelib/kernel/qsystemsemaphore_systemv.cpp18
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp8
-rw-r--r--src/corelib/kernel/qtranslator.cpp14
-rw-r--r--src/corelib/kernel/qvariant.cpp6
-rw-r--r--src/corelib/mimetypes/qmimedatabase.cpp24
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern.cpp44
-rw-r--r--src/corelib/mimetypes/qmimemagicrule.cpp12
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp35
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp26
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp8
-rw-r--r--src/corelib/plugin/qcoffpeparser.cpp9
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp4
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp16
-rw-r--r--src/corelib/plugin/qlibrary.cpp24
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp42
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp8
-rw-r--r--src/corelib/plugin/qmachparser.cpp5
-rw-r--r--src/corelib/plugin/qpluginloader.cpp8
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp10
-rw-r--r--src/corelib/plugin/quuid.cpp2
-rw-r--r--src/corelib/serialization/qcbordiagnostic.cpp36
-rw-r--r--src/corelib/serialization/qtextstream.cpp36
-rw-r--r--src/corelib/serialization/qxmlstream.cpp83
-rw-r--r--src/corelib/serialization/qxmlstream.g26
-rw-r--r--src/corelib/serialization/qxmlstreamparser_p.h26
-rw-r--r--src/corelib/serialization/qxmlutils.cpp2
-rw-r--r--src/corelib/text/qlocale.cpp26
-rw-r--r--src/corelib/text/qlocale_mac.mm42
-rw-r--r--src/corelib/text/qlocale_unix.cpp14
-rw-r--r--src/corelib/text/qlocale_win.cpp33
-rw-r--r--src/corelib/text/qregularexpression.cpp57
-rw-r--r--src/corelib/text/qstring.cpp46
-rw-r--r--src/corelib/text/qunicodetools.cpp6
-rw-r--r--src/corelib/thread/qthreadpool.cpp4
-rw-r--r--src/corelib/time/qdatetime.cpp14
-rw-r--r--src/corelib/time/qdatetimeparser.cpp105
-rw-r--r--src/corelib/time/qtimezone.cpp4
-rw-r--r--src/corelib/time/qtimezoneprivate_data_p.h2
-rw-r--r--src/corelib/time/qtimezoneprivate_tz.cpp10
-rw-r--r--src/corelib/time/qtimezoneprivate_win.cpp8
-rw-r--r--src/corelib/tools/qcommandlineoption.cpp6
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp22
-rw-r--r--src/corelib/tools/qversionnumber.cpp2
109 files changed, 1351 insertions, 1184 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp b/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
index 3092e32f6f..2c18b6e00d 100644
--- a/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_mimetype_qmimedatabase.cpp
@@ -48,6 +48,8 @@
**
****************************************************************************/
+using namespace Qt::StringLiterals;
+
//! [0]
QMimeDatabase db;
QMimeType mime = db.mimeTypeForFile(fileName);
@@ -57,7 +59,7 @@ if (mime.inherits("text/plain")) {
//! [0]
//! [1]
-QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QLatin1String("mime/packages"),
+QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "mime/packages"_L1,
QStandardPaths::LocateDirectory);
//! [1]
diff --git a/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp
index cb6928b129..7edc040073 100644
--- a/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp
@@ -48,6 +48,8 @@
**
****************************************************************************/
+using namespace Qt::StringLiterals;
+
//! [0]
QCborValue(QCborTag(2), QByteArray("\x01\0\0\0\0\0\0\0\0", 9));
//! [0]
@@ -55,18 +57,18 @@
//! [1]
writer.startMap(4); // 4 elements in the map
- writer.append(QLatin1String("label"));
- writer.append(QLatin1String("journald"));
+ writer.append("label"_L1);
+ writer.append("journald"_L1);
- writer.append(QLatin1String("autoDetect"));
+ writer.append("autoDetect"_L1);
writer.append(false);
- writer.append(QLatin1String("condition"));
- writer.append(QLatin1String("libs.journald"));
+ writer.append("condition"_L1);
+ writer.append("libs.journald"_L1);
- writer.append(QLatin1String("output"));
+ writer.append("output"_L1);
writer.startArray(1);
- writer.append(QLatin1String("privateFeature"));
+ writer.append("privateFeature"_L1);
writer.endArray();
writer.endMap();
@@ -118,7 +120,7 @@
//! [7]
//! [8]
- writer.append(QLatin1String("Hello, World"));
+ writer.append("Hello, World"_L1);
//! [8]
//! [9]
diff --git a/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp b/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
index fe44bee4a8..1f7f1835a7 100644
--- a/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_text_qstring.cpp
@@ -48,8 +48,10 @@
**
****************************************************************************/
+using namespace Qt::StringLiterals;
+
//! [1]
-QString url = QLatin1String("https://www.unicode.org/");
+QString url = "https://www.unicode.org/"_L1;
//! [1]
@@ -77,17 +79,17 @@ if (str == QString("auto") || str == QString("extern")
//! [5]
-if (str == QLatin1String("auto")
- || str == QLatin1String("extern")
- || str == QLatin1String("static")
- || str == QLatin1String("register") {
+if (str == "auto"_L1
+ || str == "extern"_L1
+ || str == "static"_L1
+ || str == "register"_L1 {
...
}
//! [5]
//! [6]
-QLabel *label = new QLabel(QLatin1String("MOD"), this);
+QLabel *label = new QLabel("MOD"_L1, this);
//! [6]
@@ -112,5 +114,5 @@ if (node.hasAttribute(QStringLiteral(u"http-contents-length"))) //...
//! [10]
//! [11]
-if (attribute.name() == QLatin1String("http-contents-length")) //...
+if (attribute.name() == "http-contents-length"_L1) //...
//! [11]
diff --git a/src/corelib/doc/snippets/hellotrmain.cpp b/src/corelib/doc/snippets/hellotrmain.cpp
index 526da44701..975cacace0 100644
--- a/src/corelib/doc/snippets/hellotrmain.cpp
+++ b/src/corelib/doc/snippets/hellotrmain.cpp
@@ -48,6 +48,8 @@
**
****************************************************************************/
+using namespace Qt::StringLiterals;
+
//! [0]
int main(int argc, char *argv[])
{
@@ -55,7 +57,7 @@ int main(int argc, char *argv[])
QTranslator translator;
// look up e.g. :/i18n/myapp_de.qm
- if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/i18n")))
+ if (translator.load(QLocale(), "myapp"_L1, "_"_L1, ":/i18n"_L1))
QCoreApplication::installTranslator(&translator);
QPushButton hello(QCoreApplication::translate("main", "Hello world!"));
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index d0a1b9c9ba..da6b3ad1fa 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -735,10 +735,10 @@ void Widget::splitCaseSensitiveFunction()
//! [62]
QString str = QStringLiteral("a,,b,c");
- QStringList list1 = str.split(QLatin1Char(','));
+ QStringList list1 = str.split(u',');
// list1: [ "a", "", "b", "c" ]
- QStringList list2 = str.split(QLatin1Char(','), Qt::SkipEmptyParts);
+ QStringList list2 = str.split(u',', Qt::SkipEmptyParts);
// list2: [ "a", "b", "c" ]
//! [62]
@@ -750,7 +750,7 @@ void Widget::splitCaseSensitiveFunction()
//! [62-slashes]
QString str = "/a/b/c/";
- auto parts = str.split(QLatin1Char('/'));
+ auto parts = str.split(u'/');
// parts: {"", "a", "b", "c", ""}
//! [62-slashes]
}
diff --git a/src/corelib/doc/snippets/qstring/stringbuilder.cpp b/src/corelib/doc/snippets/qstring/stringbuilder.cpp
index b81b40e10e..10a3fe1945 100644
--- a/src/corelib/doc/snippets/qstring/stringbuilder.cpp
+++ b/src/corelib/doc/snippets/qstring/stringbuilder.cpp
@@ -48,11 +48,13 @@
**
****************************************************************************/
+using namespace Qt::StringLiterals;
+
//! [0]
QString foo;
QString type = "long";
- foo = QLatin1String("vector<") + type + QLatin1String(">::iterator");
+ foo = "vector<"_L1 + type + ">::iterator"_L1;
if (foo.startsWith("(" + type + ") 0x"))
...
diff --git a/src/corelib/global/qconfig.cpp.in b/src/corelib/global/qconfig.cpp.in
index 7c79d9073d..016bdf40d1 100644
--- a/src/corelib/global/qconfig.cpp.in
+++ b/src/corelib/global/qconfig.cpp.in
@@ -16,5 +16,5 @@ static constexpr auto qt_configure_strs = QT_PREPEND_NAMESPACE(qOffsetStringArra
);
#define QT_CONFIGURE_SETTINGS_PATH "@QT_SYS_CONF_DIR@"
-#define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "@QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH@"
+#define QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH "@QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH@"_L1
#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index c47de69e5b..3ae14b6e13 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -125,6 +125,8 @@ extern "C" {
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// Statically check assumptions about the environment we're running
// in. The idea here is to error or warn if otherwise implicit Qt
// assumptions are not fulfilled on new hardware or compilers
@@ -2200,7 +2202,7 @@ static QString winSp_helper()
QString sp = QStringLiteral("SP ") + QString::number(major);
const qint16 minor = osv.wServicePackMinor;
if (minor)
- sp += QLatin1Char('.') + QString::number(minor);
+ sp += u'.' + QString::number(minor);
return sp;
}
@@ -2392,7 +2394,7 @@ static bool readEtcRedHatRelease(QUnixOSVersion &v)
const char keyword[] = "release ";
int releaseIndex = line.indexOf(keyword);
- v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(QLatin1Char(' '));
+ v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(u' ');
int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword));
v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword),
spaceIndex > -1 ? spaceIndex - releaseIndex - int(strlen(keyword)) : -1));
@@ -2615,11 +2617,11 @@ QString QSysInfo::currentCpuArchitecture()
# if defined(Q_PROCESSOR_POWER) || defined(QT_BUILD_INTERNAL)
// harmonize "powerpc" and "ppc" to "power"
if (strncmp(u.machine, "ppc", 3) == 0)
- return QLatin1String("power") + QLatin1String(u.machine + 3);
+ return "power"_L1 + QLatin1String(u.machine + 3);
if (strncmp(u.machine, "powerpc", 7) == 0)
- return QLatin1String("power") + QLatin1String(u.machine + 7);
+ return "power"_L1 + QLatin1String(u.machine + 7);
if (strcmp(u.machine, "Power Macintosh") == 0)
- return QLatin1String("power");
+ return "power"_L1;
# endif
# if defined(Q_PROCESSOR_SPARC) || defined(QT_BUILD_INTERNAL)
// Solaris sysinfo(2) (above) uses "sparcv9", but uname -m says "sun4u";
@@ -2743,8 +2745,8 @@ QString QSysInfo::kernelVersion()
{
#ifdef Q_OS_WIN
const auto osver = QOperatingSystemVersion::current();
- return QString::number(osver.majorVersion()) + QLatin1Char('.') + QString::number(osver.minorVersion())
- + QLatin1Char('.') + QString::number(osver.microVersion());
+ return QString::asprintf("%d.%d.%d",
+ osver.majorVersion(), osver.minorVersion(), osver.microVersion());
#else
struct utsname u;
if (uname(&u) == 0)
@@ -2861,7 +2863,7 @@ QString QSysInfo::productVersion()
{
#if defined(Q_OS_ANDROID) || defined(Q_OS_DARWIN)
const auto version = QOperatingSystemVersion::current();
- return QString::number(version.majorVersion()) + QLatin1Char('.') + QString::number(version.minorVersion());
+ return QString::asprintf("%d.%d", version.majorVersion(), version.minorVersion());
#elif defined(Q_OS_WIN)
const char *version = osVer_helper();
if (version) {
@@ -2900,24 +2902,23 @@ QString QSysInfo::prettyProductName()
#if defined(Q_OS_ANDROID) || defined(Q_OS_DARWIN) || defined(Q_OS_WIN)
const auto version = QOperatingSystemVersion::current();
const int majorVersion = version.majorVersion();
- const QString versionString = QString::number(majorVersion) + QLatin1Char('.')
- + QString::number(version.minorVersion());
- QString result = version.name() + QLatin1Char(' ');
+ const QString versionString = QString::asprintf("%d.%d", majorVersion, version.minorVersion());
+ QString result = version.name() + u' ';
const char *name = osVer_helper(version);
if (!name)
return result + versionString;
result += QLatin1String(name);
# if !defined(Q_OS_WIN)
- return result + QLatin1String(" (") + versionString + QLatin1Char(')');
+ return result + " ("_L1 + versionString + u')';
# else
// (resembling winver.exe): Windows 10 "Windows 10 Version 1809"
const auto releaseId = windows10ReleaseId();
if (!releaseId.isEmpty())
- result += QLatin1String(" Version ") + releaseId;
+ result += " Version "_L1 + releaseId;
return result;
# endif // Windows
#elif defined(Q_OS_HAIKU)
- return QLatin1String("Haiku ") + productVersion();
+ return "Haiku "_L1 + productVersion();
#elif defined(Q_OS_UNIX)
# ifdef USE_ETC_OS_RELEASE
QUnixOSVersion unixOsVersion;
@@ -2927,7 +2928,7 @@ QString QSysInfo::prettyProductName()
# endif
struct utsname u;
if (uname(&u) == 0)
- return QString::fromLatin1(u.sysname) + QLatin1Char(' ') + QString::fromLatin1(u.release);
+ return QString::fromLatin1(u.sysname) + u' ' + QString::fromLatin1(u.release);
#endif
return unknownText();
}
@@ -3506,7 +3507,7 @@ QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
_wgetenv_s(&requiredSize, reinterpret_cast<wchar_t *>(buffer.data()), requiredSize,
wname.data());
// requiredSize includes the terminating null, which we don't want.
- Q_ASSERT(buffer.endsWith(QLatin1Char('\0')));
+ Q_ASSERT(buffer.endsWith(u'\0'));
buffer.chop(1);
return buffer;
#else
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index a4764713c4..1a540d40f7 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -68,6 +68,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
extern void qDumpCPUFeatures(); // in qsimd.cpp
#if QT_CONFIG(settings)
@@ -116,8 +118,8 @@ void QLibrarySettings::load()
// This code needs to be in the regular library, as otherwise a qt.conf that
// works for qmake would break things for dynamically built Qt tools.
QStringList children = settings->childGroups();
- paths = !children.contains(QLatin1String("Platforms"))
- || children.contains(QLatin1String("Paths"));
+ paths = !children.contains("Platforms"_L1)
+ || children.contains("Paths"_L1);
}
}
@@ -133,7 +135,7 @@ static QSettings *findConfiguration()
CFBundleRef bundleRef = CFBundleGetMainBundle();
if (bundleRef) {
QCFType<CFURLRef> urlRef = CFBundleCopyResourceURL(bundleRef,
- QCFString(QLatin1String("qt.conf")),
+ QCFString("qt.conf"_L1),
0,
0);
if (urlRef) {
@@ -149,7 +151,7 @@ static QSettings *findConfiguration()
qtconfig = pwd.filePath(QLatin1String("qt" QT_STRINGIFY(QT_VERSION_MAJOR) ".conf"));
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
- qtconfig = pwd.filePath(QLatin1String("qt.conf"));
+ qtconfig = pwd.filePath("qt.conf"_L1);
if (QFile::exists(qtconfig))
return new QSettings(qtconfig, QSettings::IniFormat);
}
@@ -326,7 +328,7 @@ static QString prefixFromAppDirHelper()
if (urlRef) {
QCFString path = CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle);
#ifdef Q_OS_MACOS
- QString bundleContentsDir = QString(path) + QLatin1String("/Contents/");
+ QString bundleContentsDir = QString(path) + "/Contents/"_L1;
if (QDir(bundleContentsDir).exists())
return QDir::cleanPath(bundleContentsDir);
#else
@@ -351,8 +353,7 @@ static QString prefixFromQtCoreLibraryHelper(const QString &qtCoreLibraryPath)
{
const QString qtCoreLibrary = QDir::fromNativeSeparators(qtCoreLibraryPath);
const QString libDir = QFileInfo(qtCoreLibrary).absolutePath();
- const QString prefixDir = libDir + QLatin1Char('/')
- + QLatin1String(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH);
+ const QString prefixDir = libDir + "/" QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH;
return QDir::cleanPath(prefixDir);
}
#endif
@@ -411,8 +412,7 @@ static QString getRelocatablePrefix()
const QCFString libDirCFString = CFURLCopyFileSystemPath(libDirCFPath, kCFURLPOSIXPathStyle);
- const QString prefixDir = QString(libDirCFString) + QLatin1Char('/')
- + QLatin1String(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH);
+ const QString prefixDir = QString(libDirCFString) + "/" QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH;
prefixPath = QDir::cleanPath(prefixDir);
#elif QT_CONFIG(dlopen)
@@ -446,7 +446,7 @@ static QString getRelocatablePrefix()
const QString qtCoreImpLibFileName = implibPrefix
+ QFileInfo(qtCoreFilePath).completeBaseName() + implibSuffix;
const QString qtCoreImpLibPath = qtCoreDirPath
- + slash + QLatin1String(QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH)
+ + slash + QT_CONFIGURE_LIBLOCATION_TO_PREFIX_PATH
+ slash + libdir
+ slash + qtCoreImpLibFileName;
if (!QFileInfo::exists(qtCoreImpLibPath)) {
@@ -535,7 +535,7 @@ QLibraryInfoPrivate::LocationInfo QLibraryInfoPrivate::locationInfo(QLibraryInfo
result.fallbackKey = u"Qml2Imports"_qs;
#ifndef Q_OS_WIN // On Windows we use the registry
} else if (loc == QLibraryInfo::SettingsPath) {
- result.key = QLatin1String("Settings");
+ result.key = "Settings"_L1;
result.defaultValue = QLatin1String(dot);
#endif
}
@@ -566,7 +566,7 @@ QString QLibraryInfo::path(LibraryPath p)
if (!li.key.isNull()) {
QSettings *config = QLibraryInfoPrivate::configuration();
Q_ASSERT(config != nullptr);
- config->beginGroup(QLatin1String("Paths"));
+ config->beginGroup("Paths"_L1);
if (li.fallbackKey.isNull()) {
ret = config->value(li.key, li.defaultValue).toString();
@@ -579,16 +579,16 @@ QString QLibraryInfo::path(LibraryPath p)
int startIndex = 0;
forever {
- startIndex = ret.indexOf(QLatin1Char('$'), startIndex);
+ startIndex = ret.indexOf(u'$', startIndex);
if (startIndex < 0)
break;
if (ret.length() < startIndex + 3)
break;
- if (ret.at(startIndex + 1) != QLatin1Char('(')) {
+ if (ret.at(startIndex + 1) != u'(') {
startIndex++;
continue;
}
- int endIndex = ret.indexOf(QLatin1Char(')'), startIndex + 2);
+ int endIndex = ret.indexOf(u')', startIndex + 2);
if (endIndex < 0)
break;
auto envVarName = QStringView{ret}.mid(startIndex + 2, endIndex - startIndex - 2);
@@ -629,7 +629,7 @@ QString QLibraryInfo::path(LibraryPath p)
// we make any other path absolute to the prefix directory
baseDir = path(PrefixPath);
}
- ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret);
+ ret = QDir::cleanPath(baseDir + u'/' + ret);
}
return ret;
}
@@ -652,10 +652,9 @@ QStringList QLibraryInfo::platformPluginArguments(const QString &platformName)
#if QT_CONFIG(settings)
QScopedPointer<const QSettings> settings(findConfiguration());
if (!settings.isNull()) {
- const QString key = QLatin1String("Platforms")
- + QLatin1Char('/')
+ const QString key = "Platforms/"_L1
+ platformName
- + QLatin1String("Arguments");
+ + "Arguments"_L1;
return settings->value(key).toStringList();
}
#else
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index c6bd52668b..71332ea6cf 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -163,6 +163,8 @@ static QT_PREPEND_NAMESPACE(qint64) qt_gettid()
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if !defined(Q_CC_MSVC)
Q_NORETURN
#endif
@@ -1126,10 +1128,9 @@ void QMessagePattern::setPattern(const QString &pattern)
bool inPlaceholder = false;
for (int i = 0; i < pattern.size(); ++i) {
const QChar c = pattern.at(i);
- if ((c == QLatin1Char('%'))
- && !inPlaceholder) {
+ if (c == u'%' && !inPlaceholder) {
if ((i + 1 < pattern.size())
- && pattern.at(i + 1) == QLatin1Char('{')) {
+ && pattern.at(i + 1) == u'{') {
// beginning of placeholder
if (!lexeme.isEmpty()) {
lexemes.append(lexeme);
@@ -1141,7 +1142,7 @@ void QMessagePattern::setPattern(const QString &pattern)
lexeme.append(c);
- if ((c == QLatin1Char('}') && inPlaceholder)) {
+ if (c == u'}' && inPlaceholder) {
// end of placeholder
lexemes.append(lexeme);
lexeme.clear();
@@ -1162,8 +1163,7 @@ void QMessagePattern::setPattern(const QString &pattern)
for (int i = 0; i < lexemes.size(); ++i) {
const QString lexeme = lexemes.at(i);
- if (lexeme.startsWith(QLatin1String("%{"))
- && lexeme.endsWith(QLatin1Char('}'))) {
+ if (lexeme.startsWith("%{"_L1) && lexeme.endsWith(u'}')) {
// placeholder
if (lexeme == QLatin1String(typeTokenC)) {
tokens[i] = typeTokenC;
@@ -1203,7 +1203,7 @@ void QMessagePattern::setPattern(const QString &pattern)
if (m.hasMatch()) {
int depth = m.capturedView(1).toInt();
if (depth <= 0)
- error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n");
+ error += "QT_MESSAGE_PATTERN: %{backtrace} depth must be a number greater than 0\n"_L1;
else
backtraceDepth = depth;
}
@@ -1215,7 +1215,7 @@ void QMessagePattern::setPattern(const QString &pattern)
backtraceParams.backtraceSeparator = backtraceSeparator;
backtraceArgs.append(backtraceParams);
#else
- error += QLatin1String("QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n");
+ error += "QT_MESSAGE_PATTERN: %{backtrace} is not supported by this Qt build\n"_L1;
tokens[i] = "";
#endif
}
@@ -1237,7 +1237,7 @@ void QMessagePattern::setPattern(const QString &pattern)
else if (lexeme == QLatin1String(endifTokenC)) {
tokens[i] = endifTokenC;
if (!inIf && !nestedIfError)
- error += QLatin1String("QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n");
+ error += "QT_MESSAGE_PATTERN: %{endif} without an %{if-*}\n"_L1;
inIf = false;
} else {
tokens[i] = emptyTokenC;
@@ -1253,9 +1253,9 @@ void QMessagePattern::setPattern(const QString &pattern)
}
}
if (nestedIfError)
- error += QLatin1String("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n");
+ error += "QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n"_L1;
else if (inIf)
- error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n");
+ error += "QT_MESSAGE_PATTERN: missing %{endif}\n"_L1;
if (!error.isEmpty())
qt_message_print(error);
@@ -1303,19 +1303,19 @@ static QStringList backtraceFramesForLogMessage(int frameCount)
buffer.resize(n);
auto shouldSkipFrame = [&result](const auto &library, const auto &function) {
- if (!result.isEmpty() || !library.contains(QLatin1String("Qt6Core")))
+ if (!result.isEmpty() || !library.contains("Qt6Core"_L1))
return false;
if (function.isEmpty())
return true;
- if (function.contains(QLatin1String("6QDebug")))
+ if (function.contains("6QDebug"_L1))
return true;
- if (function.contains(QLatin1String("Message")) || function.contains(QLatin1String("_message")))
+ if (function.contains("Message"_L1) || function.contains("_message"_L1))
return true;
return false;
};
auto demangled = [](auto &function) -> QString {
- if (!function.startsWith(QLatin1String("_Z")))
+ if (!function.startsWith("_Z"_L1))
return function;
// we optimize for the case where __cxa_demangle succeeds
@@ -1392,7 +1392,7 @@ static QStringList backtraceFramesForLogMessage(int frameCount)
DecodedFrame frame = decodeFrame(addr);
if (!frame.library.isEmpty()) {
if (frame.function.isEmpty())
- result.append(QLatin1Char('?') + frame.library + QLatin1Char('?'));
+ result.append(u'?' + frame.library + u'?');
else
result.append(frame.function);
} else {
@@ -1418,7 +1418,7 @@ static QString formatBacktraceForLogMessage(const QMessagePattern::BacktracePara
return QString();
// if the first frame is unknown, replace it with the context function
- if (function && frames.at(0).startsWith(QLatin1Char('?')))
+ if (function && frames.at(0).startsWith(u'?'))
frames[0] = QString::fromUtf8(qCleanupFuncinfo(function));
return frames.join(backtraceSeparator);
@@ -1492,24 +1492,24 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
#endif
} else if (token == typeTokenC) {
switch (type) {
- case QtDebugMsg: message.append(QLatin1String("debug")); break;
- case QtInfoMsg: message.append(QLatin1String("info")); break;
- case QtWarningMsg: message.append(QLatin1String("warning")); break;
- case QtCriticalMsg:message.append(QLatin1String("critical")); break;
- case QtFatalMsg: message.append(QLatin1String("fatal")); break;
+ case QtDebugMsg: message.append("debug"_L1); break;
+ case QtInfoMsg: message.append("info"_L1); break;
+ case QtWarningMsg: message.append("warning"_L1); break;
+ case QtCriticalMsg:message.append("critical"_L1); break;
+ case QtFatalMsg: message.append("fatal"_L1); break;
}
} else if (token == fileTokenC) {
if (context.file)
message.append(QLatin1String(context.file));
else
- message.append(QLatin1String("unknown"));
+ message.append("unknown"_L1);
} else if (token == lineTokenC) {
message.append(QString::number(context.line));
} else if (token == functionTokenC) {
if (context.function)
message.append(QString::fromLatin1(qCleanupFuncinfo(context.function)));
else
- message.append(QLatin1String("unknown"));
+ message.append("unknown"_L1);
#ifndef QT_BOOTSTRAPPED
} else if (token == pidTokenC) {
message.append(QString::number(QCoreApplication::applicationPid()));
@@ -1519,7 +1519,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
// print the TID as decimal
message.append(QString::number(qt_gettid()));
} else if (token == qthreadptrTokenC) {
- message.append(QLatin1String("0x"));
+ message.append("0x"_L1);
message.append(QString::number(qlonglong(QThread::currentThread()->currentThread()), 16));
#ifdef QLOGGING_HAVE_BACKTRACE
} else if (token == backtraceTokenC) {
@@ -1530,10 +1530,10 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
} else if (token == timeTokenC) {
QString timeFormat = pattern->timeArgs.at(timeArgsIdx);
timeArgsIdx++;
- if (timeFormat == QLatin1String("process")) {
+ if (timeFormat == "process"_L1) {
quint64 ms = pattern->timer.elapsed();
message.append(QString::asprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000)));
- } else if (timeFormat == QLatin1String("boot")) {
+ } else if (timeFormat == "boot"_L1) {
// just print the milliseconds since the elapsed timer reference
// like the Linux kernel does
uint ms = QDeadlineTimer::current().deadline();
@@ -1587,7 +1587,7 @@ static bool slog2_default_handler(QtMsgType type, const QMessageLogContext &cont
return false; // Leave logging up to stderr handler
QString formattedMessage = qFormatLogMessage(type, context, message);
- formattedMessage.append(QLatin1Char('\n'));
+ formattedMessage.append(u'\n');
if (slog2_set_default_buffer((slog2_buffer_t)-1) == 0) {
slog2_buffer_set_config_t buffer_config;
slog2_buffer_t buffer_handle;
@@ -1773,7 +1773,7 @@ static bool win_message_handler(QtMsgType type, const QMessageLogContext &contex
if (shouldLogToStderr())
return false; // Leave logging up to stderr handler
- const QString formattedMessage = qFormatLogMessage(type, context, message).append(QLatin1Char('\n'));
+ const QString formattedMessage = qFormatLogMessage(type, context, message).append(u'\n');
win_outputDebugString_helper(formattedMessage);
return true; // Prevent further output to stderr
@@ -1980,7 +1980,7 @@ void qErrnoWarning(const char *msg, ...)
QString buf = QString::vasprintf(msg, ap);
va_end(ap);
- buf += QLatin1String(" (") + error_string + QLatin1Char(')');
+ buf += " ("_L1 + error_string + u')';
QMessageLogContext context;
qt_message_output(QtCriticalMsg, context, buf);
}
@@ -1994,7 +1994,7 @@ void qErrnoWarning(int code, const char *msg, ...)
QString buf = QString::vasprintf(msg, ap);
va_end(ap);
- buf += QLatin1String(" (") + qt_error_string(code) + QLatin1Char(')');
+ buf += " ("_L1 + qt_error_string(code) + u')';
QMessageLogContext context;
qt_message_output(QtCriticalMsg, context, buf);
}
diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp
index d6b2b6a10e..d077e68161 100644
--- a/src/corelib/io/qabstractfileengine.cpp
+++ b/src/corelib/io/qabstractfileengine.cpp
@@ -1017,8 +1017,8 @@ QString QAbstractFileEngineIterator::currentFilePath() const
if (!name.isNull()) {
QString tmp = path();
if (!tmp.isEmpty()) {
- if (!tmp.endsWith(QLatin1Char('/')))
- tmp.append(QLatin1Char('/'));
+ if (!tmp.endsWith(u'/'))
+ tmp.append(u'/');
name.prepend(tmp);
}
}
diff --git a/src/corelib/io/qdataurl.cpp b/src/corelib/io/qdataurl.cpp
index 1d91933e75..f58c04cef2 100644
--- a/src/corelib/io/qdataurl.cpp
+++ b/src/corelib/io/qdataurl.cpp
@@ -53,7 +53,7 @@ using namespace Qt::Literals;
*/
Q_CORE_EXPORT bool qDecodeDataUrl(const QUrl &uri, QString &mimeType, QByteArray &payload)
{
- if (uri.scheme() != QLatin1String("data") || !uri.host().isEmpty())
+ if (uri.scheme() != "data"_L1 || !uri.host().isEmpty())
return false;
mimeType = QStringLiteral("text/plain;charset=US-ASCII");
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index 4956b2a59c..525f032368 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -196,7 +196,7 @@ QByteArray QtDebugUtils::toPrintable(const char *data, int len, int maxSize)
QDebug::~QDebug()
{
if (stream && !--stream->ref) {
- if (stream->space && stream->buffer.endsWith(QLatin1Char(' ')))
+ if (stream->space && stream->buffer.endsWith(u' '))
stream->buffer.chop(1);
if (stream->message_output) {
qt_message_output(stream->type,
@@ -222,7 +222,7 @@ void QDebug::putUcs4(uint ucs4)
stream->ts << "\\u" << qSetFieldWidth(4);
else
stream->ts << "\\U" << qSetFieldWidth(8);
- stream->ts << Qt::hex << qSetPadChar(QLatin1Char('0')) << ucs4 << Qt::reset;
+ stream->ts << Qt::hex << qSetPadChar(u'0') << ucs4 << Qt::reset;
}
maybeQuote('\'');
}
@@ -240,7 +240,7 @@ static inline bool isPrintable(uchar c)
template <typename Char>
static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, int length, bool isUnicode = true)
{
- QChar quote(QLatin1Char('"'));
+ QChar quote(u'"');
d->write(&quote, 1);
bool lastWasHexEscape = false;
@@ -250,7 +250,7 @@ static inline void putEscapedString(QTextStreamPrivate *d, const Char *begin, in
if (Q_UNLIKELY(lastWasHexEscape)) {
if (fromHex(*p) != -1) {
// yes, insert it
- QChar quotes[] = { QLatin1Char('"'), QLatin1Char('"') };
+ QChar quotes[] = { quote, quote };
d->write(quotes, 2);
}
lastWasHexEscape = false;
@@ -983,7 +983,7 @@ public:
{
const bool currentSpaces = m_stream->space;
if (currentSpaces && !m_spaces)
- if (m_stream->buffer.endsWith(QLatin1Char(' ')))
+ if (m_stream->buffer.endsWith(u' '))
m_stream->buffer.chop(1);
m_stream->space = m_spaces;
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 5fba6619e6..a88ddc837c 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -68,6 +68,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if defined(Q_OS_WIN)
static QString driveSpec(const QString &path)
{
@@ -95,18 +97,18 @@ static int rootLength(const QString &name, bool allowUncPaths)
{
const int len = name.length();
// starts with double slash
- if (allowUncPaths && name.startsWith(QLatin1String("//"))) {
+ if (allowUncPaths && name.startsWith("//"_L1)) {
// Server name '//server/path' is part of the prefix.
- const int nextSlash = name.indexOf(QLatin1Char('/'), 2);
+ const int nextSlash = name.indexOf(u'/', 2);
return nextSlash >= 0 ? nextSlash + 1 : len;
}
#if defined(Q_OS_WIN)
- if (len >= 2 && name.at(1) == QLatin1Char(':')) {
+ if (len >= 2 && name.at(1) == u':') {
// Handle a possible drive letter
- return len > 2 && name.at(2) == QLatin1Char('/') ? 3 : 2;
+ return len > 2 && name.at(2) == u'/' ? 3 : 2;
}
#endif
- if (name.at(0) == QLatin1Char('/'))
+ if (name.at(0) == u'/')
return 1;
return 0;
}
@@ -165,10 +167,10 @@ bool QDirPrivate::exists() const
// static
inline QChar QDirPrivate::getFilterSepChar(const QString &nameFilter)
{
- QChar sep(QLatin1Char(';'));
+ QChar sep(u';');
int i = nameFilter.indexOf(sep, 0);
- if (i == -1 && nameFilter.indexOf(QLatin1Char(' '), 0) != -1)
- sep = QChar(QLatin1Char(' '));
+ if (i == -1 && nameFilter.indexOf(u' ', 0) != -1)
+ sep = QChar(u' ');
return sep;
}
@@ -186,7 +188,7 @@ inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar se
inline void QDirPrivate::setPath(const QString &path)
{
QString p = QDir::fromNativeSeparators(path);
- if (p.endsWith(QLatin1Char('/'))
+ if (p.endsWith(u'/')
&& p.length() > 1
#if defined(Q_OS_WIN)
&& (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter()))
@@ -717,7 +719,7 @@ static int drivePrefixLength(const QString &path)
if (size > 1 && path.at(1).unicode() == ':') {
if (Q_UNLIKELY(!path.at(0).isLetter()))
return 0;
- } else if (path.startsWith(QLatin1String("//"))) {
+ } else if (path.startsWith("//"_L1)) {
// UNC path; use its //server/share part as "drive" - it's as sane a
// thing as we can do.
for (int i = 2; i-- > 0; ) { // Scan two "path fragments":
@@ -749,7 +751,7 @@ static bool treatAsAbsolute(const QString &path)
// a colon in the path.
// FIXME: relies on virtual file-systems having colons in their prefixes.
// The case of an MS-absolute C:/... path happens to work either way.
- return (path.contains(QLatin1Char(':')) && QFileInfo(path).isAbsolute())
+ return (path.contains(u':') && QFileInfo(path).isAbsolute())
|| QFileSystemEntry(path).isAbsolute();
}
@@ -773,16 +775,16 @@ QString QDir::filePath(const QString &fileName) const
return ret;
#ifdef Q_OS_WIN
- if (fileName.startsWith(QLatin1Char('/')) || fileName.startsWith(QLatin1Char('\\'))) {
+ if (fileName.startsWith(u'/') || fileName.startsWith(u'\\')) {
// Handle the "absolute except for drive" case (i.e. \blah not c:\blah):
const int drive = drivePrefixLength(ret);
return drive > 0 ? QStringView{ret}.left(drive) % fileName : fileName;
}
#endif // Q_OS_WIN
- if (ret.isEmpty() || ret.endsWith(QLatin1Char('/')))
+ if (ret.isEmpty() || ret.endsWith(u'/'))
return ret % fileName;
- return ret % QLatin1Char('/') % fileName;
+ return ret % u'/' % fileName;
}
/*!
@@ -805,7 +807,7 @@ QString QDir::absoluteFilePath(const QString &fileName) const
return absoluteDirPath;
#ifdef Q_OS_WIN
// Handle the "absolute except for drive" case (i.e. \blah not c:\blah):
- if (fileName.startsWith(QLatin1Char('/')) || fileName.startsWith(QLatin1Char('\\'))) {
+ if (fileName.startsWith(u'/') || fileName.startsWith(u'\\')) {
// Combine absoluteDirPath's drive with fileName
const int drive = drivePrefixLength(absoluteDirPath);
if (Q_LIKELY(drive))
@@ -816,8 +818,8 @@ QString QDir::absoluteFilePath(const QString &fileName) const
return QString();
}
#endif // Q_OS_WIN
- if (!absoluteDirPath.endsWith(QLatin1Char('/')))
- return absoluteDirPath % QLatin1Char('/') % fileName;
+ if (!absoluteDirPath.endsWith(u'/'))
+ return absoluteDirPath % u'/' % fileName;
return absoluteDirPath % fileName;
}
@@ -847,9 +849,10 @@ QString QDir::relativeFilePath(const QString &fileName) const
}
if (fileDrive.toLower() != dirDrive.toLower()
- || (file.startsWith(QLatin1String("//"))
- && !dir.startsWith(QLatin1String("//"))))
+ || (file.startsWith("//"_L1)
+ && !dir.startsWith("//"_L1))) {
return file;
+ }
dir.remove(0, dirDrive.size());
if (!fileDriveMissing)
@@ -857,8 +860,8 @@ QString QDir::relativeFilePath(const QString &fileName) const
#endif
QString result;
- const auto dirElts = dir.tokenize(QLatin1Char('/'), Qt::SkipEmptyParts);
- const auto fileElts = file.tokenize(QLatin1Char('/'), Qt::SkipEmptyParts);
+ const auto dirElts = dir.tokenize(u'/', Qt::SkipEmptyParts);
+ const auto fileElts = file.tokenize(u'/', Qt::SkipEmptyParts);
const auto dend = dirElts.end();
const auto fend = fileElts.end();
@@ -881,20 +884,20 @@ QString QDir::relativeFilePath(const QString &fileName) const
}
while (dit != dend) {
- result += QLatin1String("../");
+ result += "../"_L1;
++dit;
}
if (fit != fend) {
while (fit != fend) {
result += *fit++;
- result += QLatin1Char('/');
+ result += u'/';
}
result.chop(1);
}
if (result.isEmpty())
- result = QLatin1String(".");
+ result = "."_L1;
return result;
}
@@ -916,16 +919,16 @@ QString QDir::relativeFilePath(const QString &fileName) const
QString QDir::toNativeSeparators(const QString &pathName)
{
#if defined(Q_OS_WIN)
- int i = pathName.indexOf(QLatin1Char('/'));
+ int i = pathName.indexOf(u'/');
if (i != -1) {
QString n(pathName);
QChar * const data = n.data();
- data[i++] = QLatin1Char('\\');
+ data[i++] = u'\\';
for (; i < n.length(); ++i) {
- if (data[i] == QLatin1Char('/'))
- data[i] = QLatin1Char('\\');
+ if (data[i] == u'/')
+ data[i] = u'\\';
}
return n;
@@ -973,19 +976,19 @@ bool QDir::cd(const QString &dirName)
// Don't detach just yet.
const QDirPrivate * const d = d_ptr.constData();
- if (dirName.isEmpty() || dirName == QLatin1String("."))
+ if (dirName.isEmpty() || dirName == u'.')
return true;
QString newPath;
if (isAbsolutePath(dirName)) {
newPath = qt_cleanPath(dirName);
} else {
newPath = d->dirEntry.filePath();
- if (!newPath.endsWith(QLatin1Char('/')))
- newPath += QLatin1Char('/');
+ if (!newPath.endsWith(u'/'))
+ newPath += u'/';
newPath += dirName;
- if (dirName.indexOf(QLatin1Char('/')) >= 0
- || dirName == QLatin1String("..")
- || d->dirEntry.filePath() == QLatin1String(".")) {
+ if (dirName.indexOf(u'/') >= 0
+ || dirName == ".."_L1
+ || d->dirEntry.filePath() == u'.') {
bool ok;
newPath = qt_cleanPath(newPath, &ok);
if (!ok)
@@ -998,7 +1001,7 @@ bool QDir::cd(const QString &dirName)
while (dir.cdUp())
;
*/
- if (newPath.startsWith(QLatin1String(".."))) {
+ if (newPath.startsWith(".."_L1)) {
newPath = QFileInfo(newPath).absoluteFilePath();
}
}
@@ -2325,9 +2328,9 @@ static QString qt_cleanPath(const QString &path, bool *ok)
QString ret = qt_normalizePathSegments(name, OSSupportsUncPaths ? QDirPrivate::AllowUncPaths : QDirPrivate::DefaultNormalization, ok);
// Strip away last slash except for root directories
- if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) {
+ if (ret.length() > 1 && ret.endsWith(u'/')) {
#if defined (Q_OS_WIN)
- if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':')))
+ if (!(ret.length() == 3 && ret.at(1) == u':'))
#endif
ret.chop(1);
}
@@ -2457,25 +2460,25 @@ QDebug operator<<(QDebug debug, QDir::Filters filters)
debug.resetFormat();
QStringList flags;
if (filters == QDir::NoFilter) {
- flags << QLatin1String("NoFilter");
+ flags << "NoFilter"_L1;
} else {
- if (filters & QDir::Dirs) flags << QLatin1String("Dirs");
- if (filters & QDir::AllDirs) flags << QLatin1String("AllDirs");
- if (filters & QDir::Files) flags << QLatin1String("Files");
- if (filters & QDir::Drives) flags << QLatin1String("Drives");
- if (filters & QDir::NoSymLinks) flags << QLatin1String("NoSymLinks");
- if (filters & QDir::NoDot) flags << QLatin1String("NoDot");
- if (filters & QDir::NoDotDot) flags << QLatin1String("NoDotDot");
- if ((filters & QDir::AllEntries) == QDir::AllEntries) flags << QLatin1String("AllEntries");
- if (filters & QDir::Readable) flags << QLatin1String("Readable");
- if (filters & QDir::Writable) flags << QLatin1String("Writable");
- if (filters & QDir::Executable) flags << QLatin1String("Executable");
- if (filters & QDir::Modified) flags << QLatin1String("Modified");
- if (filters & QDir::Hidden) flags << QLatin1String("Hidden");
- if (filters & QDir::System) flags << QLatin1String("System");
- if (filters & QDir::CaseSensitive) flags << QLatin1String("CaseSensitive");
+ if (filters & QDir::Dirs) flags << "Dirs"_L1;
+ if (filters & QDir::AllDirs) flags << "AllDirs"_L1;
+ if (filters & QDir::Files) flags << "Files"_L1;
+ if (filters & QDir::Drives) flags << "Drives"_L1;
+ if (filters & QDir::NoSymLinks) flags << "NoSymLinks"_L1;
+ if (filters & QDir::NoDot) flags << "NoDot"_L1;
+ if (filters & QDir::NoDotDot) flags << "NoDotDot"_L1;
+ if ((filters & QDir::AllEntries) == QDir::AllEntries) flags << "AllEntries"_L1;
+ if (filters & QDir::Readable) flags << "Readable"_L1;
+ if (filters & QDir::Writable) flags << "Writable"_L1;
+ if (filters & QDir::Executable) flags << "Executable"_L1;
+ if (filters & QDir::Modified) flags << "Modified"_L1;
+ if (filters & QDir::Hidden) flags << "Hidden"_L1;
+ if (filters & QDir::System) flags << "System"_L1;
+ if (filters & QDir::CaseSensitive) flags << "CaseSensitive"_L1;
}
- debug.noquote() << "QDir::Filters(" << flags.join(QLatin1Char('|')) << ')';
+ debug.noquote() << "QDir::Filters(" << flags.join(u'|') << ')';
return debug;
}
@@ -2487,18 +2490,18 @@ static QDebug operator<<(QDebug debug, QDir::SortFlags sorting)
debug << "QDir::SortFlags(NoSort)";
} else {
QString type;
- if ((sorting & QDir::SortByMask) == QDir::Name) type = QLatin1String("Name");
- if ((sorting & QDir::SortByMask) == QDir::Time) type = QLatin1String("Time");
- if ((sorting & QDir::SortByMask) == QDir::Size) type = QLatin1String("Size");
- if ((sorting & QDir::SortByMask) == QDir::Unsorted) type = QLatin1String("Unsorted");
+ if ((sorting & QDir::SortByMask) == QDir::Name) type = "Name"_L1;
+ if ((sorting & QDir::SortByMask) == QDir::Time) type = "Time"_L1;
+ if ((sorting & QDir::SortByMask) == QDir::Size) type = "Size"_L1;
+ if ((sorting & QDir::SortByMask) == QDir::Unsorted) type = "Unsorted"_L1;
QStringList flags;
- if (sorting & QDir::DirsFirst) flags << QLatin1String("DirsFirst");
- if (sorting & QDir::DirsLast) flags << QLatin1String("DirsLast");
- if (sorting & QDir::IgnoreCase) flags << QLatin1String("IgnoreCase");
- if (sorting & QDir::LocaleAware) flags << QLatin1String("LocaleAware");
- if (sorting & QDir::Type) flags << QLatin1String("Type");
- debug.noquote() << "QDir::SortFlags(" << type << '|' << flags.join(QLatin1Char('|')) << ')';
+ if (sorting & QDir::DirsFirst) flags << "DirsFirst"_L1;
+ if (sorting & QDir::DirsLast) flags << "DirsLast"_L1;
+ if (sorting & QDir::IgnoreCase) flags << "IgnoreCase"_L1;
+ if (sorting & QDir::LocaleAware) flags << "LocaleAware"_L1;
+ if (sorting & QDir::Type) flags << "Type"_L1;
+ debug.noquote() << "QDir::SortFlags(" << type << '|' << flags.join(u'|') << ')';
}
return debug;
}
@@ -2508,7 +2511,7 @@ QDebug operator<<(QDebug debug, const QDir &dir)
QDebugStateSaver save(debug);
debug.resetFormat();
debug << "QDir(" << dir.path() << ", nameFilters = {"
- << dir.nameFilters().join(QLatin1Char(','))
+ << dir.nameFilters().join(u',')
<< "}, "
<< dir.sorting()
<< ','
diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp
index 7e86aacdb1..74278092f9 100644
--- a/src/corelib/io/qdiriterator.cpp
+++ b/src/corelib/io/qdiriterator.cpp
@@ -111,6 +111,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
template <class Iterator>
class QDirIteratorPrivateIteratorStack : public QStack<Iterator *>
{
@@ -163,7 +165,7 @@ public:
QDirIteratorPrivate::QDirIteratorPrivate(const QFileSystemEntry &entry, const QStringList &nameFilters,
QDir::Filters _filters, QDirIterator::IteratorFlags flags, bool resolveEngine)
: dirEntry(entry)
- , nameFilters(nameFilters.contains(QLatin1String("*")) ? QStringList() : nameFilters)
+ , nameFilters(nameFilters.contains("*"_L1) ? QStringList() : nameFilters)
, filters(QDir::NoFilter == _filters ? QDir::AllEntries : _filters)
, iteratorFlags(flags)
{
@@ -301,7 +303,7 @@ void QDirIteratorPrivate::checkAndPushDirectory(const QFileInfo &fileInfo)
// Never follow . and ..
QString fileName = fileInfo.fileName();
- if (QLatin1String(".") == fileName || QLatin1String("..") == fileName)
+ if ("."_L1 == fileName || ".."_L1 == fileName)
return;
// No hidden directories unless requested
@@ -329,9 +331,9 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
// filter . and ..?
const int fileNameSize = fileName.size();
- const bool dotOrDotDot = fileName[0] == QLatin1Char('.')
+ const bool dotOrDotDot = fileName[0] == u'.'
&& ((fileNameSize == 1)
- ||(fileNameSize == 2 && fileName[1] == QLatin1Char('.')));
+ ||(fileNameSize == 2 && fileName[1] == u'.'));
if ((filters & QDir::NoDot) && dotOrDotDot && fileNameSize == 1)
return false;
if ((filters & QDir::NoDotDot) && dotOrDotDot && fileNameSize == 2)
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 8d8b579bfc..cecc0b5c4c 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_DECL_COLD_FUNCTION
static bool file_already_open(QFile &file, const char *where = nullptr)
{
@@ -616,7 +618,7 @@ QFile::rename(const QString &newName)
// report both errors
d->setError(QFile::RenameError,
tr("Error while renaming: %1").arg(error.toString())
- + QLatin1Char('\n')
+ + u'\n'
+ tr("Unable to restore from %1: %2").
arg(QDir::toNativeSeparators(tmp.filePath()), error2.toString()));
return false;
@@ -789,7 +791,7 @@ QFile::copy(const QString &newName)
error = true;
d->setError(QFile::CopyError, tr("Cannot open %1 for input").arg(d->fileName));
} else {
- const auto fileTemplate = QLatin1String("%1/qt_temp.XXXXXX");
+ const auto fileTemplate = "%1/qt_temp.XXXXXX"_L1;
#ifdef QT_NO_TEMPORARYFILE
QFile out(fileTemplate.arg(QFileInfo(newName).path()));
if (!out.open(QIODevice::ReadWrite))
diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp
index 5e2b5eb4ad..d1587dcb35 100644
--- a/src/corelib/io/qfileinfo.cpp
+++ b/src/corelib/io/qfileinfo.cpp
@@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
QT_IMPL_METATYPE_EXTERN(QFileInfo)
QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const
@@ -97,7 +99,7 @@ QString QFileInfoPrivate::getFileName(QAbstractFileEngine::FileName name) const
ret = fileEngine->fileName(name);
}
if (ret.isNull())
- ret = QLatin1String("");
+ ret = ""_L1;
if (cache_enabled)
fileNames[(int)name] = ret;
return ret;
@@ -121,7 +123,7 @@ QString QFileInfoPrivate::getFileOwner(QAbstractFileEngine::FileOwner own) const
ret = fileEngine->owner(own);
}
if (ret.isNull())
- ret = QLatin1String("");
+ ret = ""_L1;
if (cache_enabled)
fileOwners[(int)own] = ret;
return ret;
@@ -557,7 +559,7 @@ QString QFileInfo::absoluteFilePath() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileName(QAbstractFileEngine::AbsoluteName);
}
@@ -574,7 +576,7 @@ QString QFileInfo::canonicalFilePath() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileName(QAbstractFileEngine::CanonicalName);
}
@@ -600,9 +602,8 @@ QString QFileInfo::absolutePath() const
{
Q_D(const QFileInfo);
- if (d->isDefaultConstructed) {
- return QLatin1String("");
- }
+ if (d->isDefaultConstructed)
+ return ""_L1;
return d->getFileName(QAbstractFileEngine::AbsolutePathName);
}
@@ -618,7 +619,7 @@ QString QFileInfo::canonicalPath() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileName(QAbstractFileEngine::CanonicalPathName);
}
@@ -635,7 +636,7 @@ QString QFileInfo::path() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->fileEntry.path();
}
@@ -754,7 +755,7 @@ QString QFileInfo::filePath() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->fileEntry.filePath();
}
@@ -773,7 +774,7 @@ QString QFileInfo::fileName() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->fileEntry.fileName();
}
@@ -793,7 +794,7 @@ QString QFileInfo::bundleName() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileName(QAbstractFileEngine::BundleName);
}
@@ -817,7 +818,7 @@ QString QFileInfo::baseName() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->fileEntry.baseName();
}
@@ -836,7 +837,7 @@ QString QFileInfo::completeBaseName() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->fileEntry.completeBaseName();
}
@@ -855,7 +856,7 @@ QString QFileInfo::completeSuffix() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->fileEntry.completeSuffix();
}
@@ -878,7 +879,7 @@ QString QFileInfo::suffix() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->fileEntry.suffix();
}
@@ -1250,7 +1251,7 @@ QString QFileInfo::symLinkTarget() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileName(QAbstractFileEngine::AbsoluteLinkTarget);
}
@@ -1272,7 +1273,7 @@ QString QFileInfo::junctionTarget() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileName(QAbstractFileEngine::JunctionName);
}
@@ -1294,7 +1295,7 @@ QString QFileInfo::owner() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileOwner(QAbstractFileEngine::OwnerUser);
}
@@ -1335,7 +1336,7 @@ QString QFileInfo::group() const
{
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
- return QLatin1String("");
+ return ""_L1;
return d->getFileOwner(QAbstractFileEngine::OwnerGroup);
}
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index dd6257a885..77362c2073 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
//Environment variable to allow tooling full control of file selectors
static const char env_override[] = "QT_NO_BUILTIN_SELECTORS";
@@ -196,9 +198,9 @@ QString QFileSelector::select(const QString &filePath) const
static bool isLocalScheme(const QString &file)
{
- bool local = file == QLatin1String("qrc");
+ bool local = file == "qrc"_L1;
#ifdef Q_OS_ANDROID
- local |= file == QLatin1String("assets");
+ local |= file == "assets"_L1;
#endif
return local;
}
@@ -217,11 +219,11 @@ QUrl QFileSelector::select(const QUrl &filePath) const
return filePath;
QUrl ret(filePath);
if (isLocalScheme(filePath.scheme())) {
- QLatin1String scheme(":");
+ auto scheme = ":"_L1;
#ifdef Q_OS_ANDROID
// use other scheme because ":" means "qrc" here
- if (filePath.scheme() == QLatin1String("assets"))
- scheme = QLatin1String("assets:");
+ if (filePath.scheme() == "assets"_L1)
+ scheme = "assets:"_L1;
#endif
QString equivalentPath = scheme + filePath.path();
@@ -250,13 +252,13 @@ QString QFileSelectorPrivate::selectionHelper(const QString &path, const QString
selector ordering in the API, we can stop checking as soon as we find the file in a directory
which does not contain any other valid selector directories.
*/
- Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
+ Q_ASSERT(path.isEmpty() || path.endsWith(u'/'));
for (const QString &s : selectors) {
QString prospectiveBase = path;
if (!indicator.isNull())
prospectiveBase += indicator;
- prospectiveBase += s + QLatin1Char('/');
+ prospectiveBase += s + u'/';
QStringList remainingSelectors = selectors;
remainingSelectors.removeAll(s);
if (!QDir(prospectiveBase).exists())
@@ -356,7 +358,7 @@ QStringList QFileSelectorPrivate::platformSelectors()
ret << QSysInfo::kernelType();
# endif
QString productName = QSysInfo::productType();
- if (productName != QLatin1String("unknown"))
+ if (productName != "unknown"_L1)
ret << productName; // "opensuse", "fedora", "osx", "ios", "android"
#endif
return ret;
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index f00aba78c3..0b127cfbea 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -61,7 +61,7 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path)
return path;
QFileInfo fi;
- const QChar slash(QLatin1Char('/'));
+ const QChar slash(u'/');
QString tmpPath = path;
int separatorPos = 0;
QSet<QString> nonSymlinks;
@@ -74,7 +74,7 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path)
if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) {
// UNC, skip past the first two elements
separatorPos = tmpPath.indexOf(slash, 2);
- } else if (tmpPath.size() >= 3 && tmpPath.at(1) == QLatin1Char(':') && tmpPath.at(2) == slash) {
+ } else if (tmpPath.size() >= 3 && tmpPath.at(1) == u':' && tmpPath.at(2) == slash) {
// volume root, skip since it can not be a symlink
separatorPos = 2;
}
@@ -142,10 +142,10 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent
#if defined(QT_BUILD_CORE_LIB)
for (int prefixSeparator = 0; prefixSeparator < filePath.size(); ++prefixSeparator) {
QChar const ch = filePath[prefixSeparator];
- if (ch == QLatin1Char('/'))
+ if (ch == u'/')
break;
- if (ch == QLatin1Char(':')) {
+ if (ch == u':') {
if (prefixSeparator == 0) {
engine = new QResourceFileEngine(filePath);
return _q_checkEntry(engine, resolvingEntry);
@@ -156,7 +156,8 @@ static bool _q_resolveEntryAndCreateLegacyEngine_recursive(QFileSystemEntry &ent
const QStringList &paths = QDir::searchPaths(filePath.left(prefixSeparator));
for (int i = 0; i < paths.count(); i++) {
- entry = QFileSystemEntry(QDir::cleanPath(paths.at(i) % QLatin1Char('/') % QStringView{filePath}.mid(prefixSeparator + 1)));
+ entry = QFileSystemEntry(QDir::cleanPath(
+ paths.at(i) % u'/' % QStringView{filePath}.mid(prefixSeparator + 1)));
// Recurse!
if (_q_resolveEntryAndCreateLegacyEngine_recursive(entry, data, engine, true))
return true;
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index ea903fa990..9b34ab6596 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -113,6 +113,8 @@ struct statx { mode_t stx_mode; }; // dummy
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
enum {
#ifdef Q_OS_ANDROID
// On Android, the link(2) system call has been observed to always fail
@@ -180,7 +182,7 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application);
CFStringRef identifier = CFBundleGetIdentifier(bundle);
QString applicationId = QString::fromCFString(identifier);
- if (applicationId != QLatin1String("com.apple.finder"))
+ if (applicationId != "com.apple.finder"_L1)
return true;
}
#endif
@@ -633,15 +635,15 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
QDir parent(link.filePath());
parent.cdUp();
ret = parent.path();
- if (!ret.isEmpty() && !ret.endsWith(QLatin1Char('/')))
- ret += QLatin1Char('/');
+ if (!ret.isEmpty() && !ret.endsWith(u'/'))
+ ret += u'/';
}
ret += QFile::decodeName(s);
- if (!ret.startsWith(QLatin1Char('/')))
- ret.prepend(absoluteName(link).path() + QLatin1Char('/'));
+ if (!ret.startsWith(u'/'))
+ ret.prepend(absoluteName(link).path() + u'/');
ret = QDir::cleanPath(ret);
- if (ret.size() > 1 && ret.endsWith(QLatin1Char('/')))
+ if (ret.size() > 1 && ret.endsWith(u'/'))
ret.chop(1);
return QFileSystemEntry(ret);
}
@@ -764,7 +766,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
QFileSystemEntry resultingEntry(result, QFileSystemEntry::FromNativePath());
QString stringVersion = QDir::cleanPath(resultingEntry.filePath());
if (isDir)
- stringVersion.append(QLatin1Char('/'));
+ stringVersion.append(u'/');
return QFileSystemEntry(stringVersion);
}
@@ -1047,7 +1049,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
if (what & QFileSystemMetaData::HiddenAttribute
&& !data.isHidden()) {
QString fileName = entry.fileName();
- if ((fileName.size() > 0 && fileName.at(0) == QLatin1Char('.'))
+ if (fileName.startsWith(u'.')
#if defined(Q_OS_DARWIN)
|| (entryErrno == 0 && hasResourcePropertyFlag(data, entry, kCFURLIsHiddenKey))
#endif
@@ -1165,7 +1167,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
Q_CHECK_FILE_NAME(dirName, false);
// Darwin doesn't support trailing /'s, so remove for everyone
- while (dirName.size() > 1 && dirName.endsWith(QLatin1Char('/')))
+ while (dirName.size() > 1 && dirName.endsWith(u'/'))
dirName.chop(1);
// try to mkdir this directory
@@ -1250,7 +1252,7 @@ static QString freeDesktopTrashLocation(const QString &sourcePath)
const QStorageInfo homeStorage(QDir::home());
// We support trashing of files outside the users home partition
if (sourceStorage != homeStorage) {
- const QLatin1String dotTrash(".Trash");
+ const auto dotTrash = ".Trash"_L1;
QDir topDir(sourceStorage.rootPath());
/*
Method 1:
@@ -1298,7 +1300,7 @@ static QString freeDesktopTrashLocation(const QString &sourcePath)
*/
if (trash.isEmpty()) {
topDir = QDir(sourceStorage.rootPath());
- const QString userTrashDir = dotTrash + QLatin1Char('-') + userID;
+ const QString userTrashDir = dotTrash + u'-' + userID;
trash = makeTrashDir(topDir, userTrashDir);
}
}
@@ -1314,7 +1316,7 @@ static QString freeDesktopTrashLocation(const QString &sourcePath)
*/
if (trash.isEmpty()) {
QDir topDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
- trash = makeTrashDir(topDir, QLatin1String("Trash"));
+ trash = makeTrashDir(topDir, "Trash"_L1);
if (!QFileInfo(trash).isDir()) {
qWarning("Unable to establish trash directory in %s",
topDir.path().toLocal8Bit().constData());
@@ -1348,8 +1350,8 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
/*
"A trash directory contains two subdirectories, named info and files."
*/
- const QLatin1String filesDir("files");
- const QLatin1String infoDir("info");
+ const auto filesDir = "files"_L1;
+ const auto infoDir = "info"_L1;
trashDir.mkdir(filesDir);
int savedErrno = errno;
trashDir.mkdir(infoDir);
@@ -1369,7 +1371,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
const QString trashedName = sourceInfo.isDir()
? QDir(sourcePath).dirName()
: sourceInfo.fileName();
- QString uniqueTrashedName = QLatin1Char('/') + trashedName;
+ QString uniqueTrashedName = u'/' + trashedName;
QString infoFileName;
int counter = 0;
QFile infoFile;
@@ -1392,7 +1394,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
(at least on the same machine), if it fails you need to pick another filename."
*/
infoFileName = trashDir.filePath(infoDir)
- + uniqueTrashedName + QLatin1String(".trashinfo");
+ + uniqueTrashedName + ".trashinfo"_L1;
infoFile.setFileName(infoFileName);
if (!infoFile.open(QIODevice::NewOnly | QIODevice::WriteOnly | QIODevice::Text))
uniqueTrashedName = makeUniqueTrashedName();
@@ -1415,7 +1417,7 @@ bool QFileSystemEngine::moveFileToTrash(const QFileSystemEntry &source,
QByteArray info =
"[Trash Info]\n"
"Path=" + sourcePath.toUtf8() + "\n"
- "DeletionDate=" + QDateTime::currentDateTime().toString(QLatin1String("yyyy-MM-ddThh:mm:ss")).toUtf8()
+ "DeletionDate=" + QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"_L1).toUtf8()
+ "\n";
infoFile.write(info);
infoFile.close();
@@ -1646,7 +1648,7 @@ QString QFileSystemEngine::homePath()
QString QFileSystemEngine::rootPath()
{
- return QLatin1String("/");
+ return u"/"_qs;
}
QString QFileSystemEngine::tempPath()
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 3da6c06a8d..5d3681e58a 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -72,6 +72,8 @@
#define SECURITY_WIN32
#include <security.h>
+using namespace Qt::StringLiterals;
+
#ifndef SPI_GETPLATFORMTYPE
#define SPI_GETPLATFORMTYPE 257
#endif
@@ -684,14 +686,14 @@ static QString readSymLink(const QFileSystemEntry &link)
#if QT_CONFIG(fslibs) && QT_CONFIG(regularexpression)
initGlobalSid();
- QRegularExpression matchVolumeRe(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"),
+ QRegularExpression matchVolumeRe("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"_L1,
QRegularExpression::CaseInsensitiveOption);
auto matchVolume = matchVolumeRe.match(result);
if (matchVolume.hasMatch()) {
Q_ASSERT(matchVolume.capturedStart() == 0);
DWORD len;
wchar_t buffer[MAX_PATH];
- const QString volumeName = QLatin1String("\\\\?\\") + matchVolume.captured();
+ const QString volumeName = "\\\\?\\"_L1 + matchVolume.captured();
if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()),
buffer, MAX_PATH, &len)
!= 0) {
@@ -751,10 +753,10 @@ static QString readLink(const QFileSystemEntry &link)
static bool uncShareExists(const QString &server)
{
// This code assumes the UNC path is always like \\?\UNC\server...
- const auto parts = QStringView{server}.split(QLatin1Char('\\'), Qt::SkipEmptyParts);
+ const auto parts = QStringView{server}.split(u'\\', Qt::SkipEmptyParts);
if (parts.count() >= 3) {
QStringList shares;
- if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares))
+ if (QFileSystemEngine::uncListSharesOnServer("\\\\"_L1 + parts.at(2), &shares))
return parts.count() < 4
|| shares.contains(parts.at(3).toString(), Qt::CaseInsensitive);
}
@@ -764,11 +766,11 @@ static bool uncShareExists(const QString &server)
static inline bool getFindData(QString path, WIN32_FIND_DATA &findData)
{
// path should not end with a trailing slash
- while (path.endsWith(QLatin1Char('\\')))
+ while (path.endsWith(u'\\'))
path.chop(1);
// can't handle drives
- if (!path.endsWith(QLatin1Char(':'))) {
+ if (!path.endsWith(u':')) {
HANDLE hFind = ::FindFirstFile((wchar_t*)path.utf16(), &findData);
if (hFind != INVALID_HANDLE_VALUE) {
::FindClose(hFind);
@@ -913,7 +915,7 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
target = readSymLink(link);
QFileSystemEntry ret(target);
if (!target.isEmpty() && ret.isRelative()) {
- target.prepend(absoluteName(link).path() + QLatin1Char('/'));
+ target.prepend(absoluteName(link).path() + u'/');
ret = QFileSystemEntry(QDir::cleanPath(target));
}
return ret;
@@ -933,7 +935,7 @@ QFileSystemEntry QFileSystemEngine::junctionTarget(const QFileSystemEntry &link,
target = readSymLink(link);
QFileSystemEntry ret(target);
if (!target.isEmpty() && ret.isRelative()) {
- target.prepend(absoluteName(link).path() + QLatin1Char('/'));
+ target.prepend(absoluteName(link).path() + u'/');
ret = QFileSystemEntry(QDir::cleanPath(target));
}
return ret;
@@ -976,8 +978,8 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
// (which is an invalid filename) this function will strip the space off and viola,
// the file is later reported as existing. Therefore, we re-add the whitespace that
// was at the end of path in order to keep the filename invalid.
- if (!path.isEmpty() && path.at(path.size() - 1) == QLatin1Char(' '))
- absPath.append(QLatin1Char(' '));
+ if (!path.isEmpty() && path.at(path.size() - 1) == u' ')
+ absPath.append(u' ');
return absPath;
}
@@ -994,17 +996,17 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
else
ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath()));
} else {
- ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath());
+ ret = QDir::cleanPath(QDir::currentPath() + u'/' + entry.filePath());
}
// The path should be absolute at this point.
// From the docs :
// Absolute paths begin with the directory separator "/"
// (optionally preceded by a drive specification under Windows).
- if (ret.at(0) != QLatin1Char('/')) {
+ if (ret.at(0) != u'/') {
Q_ASSERT(ret.length() >= 2);
Q_ASSERT(ret.at(0).isLetter());
- Q_ASSERT(ret.at(1) == QLatin1Char(':'));
+ Q_ASSERT(ret.at(1) == u':');
// Force uppercase drive letters.
ret[0] = ret.at(0).toUpper();
@@ -1264,9 +1266,8 @@ bool QFileSystemEngine::fillPermissions(const QFileSystemEntry &entry, QFileSyst
QString fname = entry.filePath();
QString ext = fname.right(4).toLower();
- if (data.isDirectory() || ext == QLatin1String(".exe") || ext == QLatin1String(".com")
- || ext == QLatin1String(".bat") || ext == QLatin1String(".pif")
- || ext == QLatin1String(".cmd")) {
+ if (data.isDirectory() || ext == ".exe"_L1 || ext == ".com"_L1
+ || ext == ".bat"_L1 || ext == ".pif"_L1 || ext == ".cmd"_L1) {
data.entryFlags |= QFileSystemMetaData::OwnerExecutePermission
| QFileSystemMetaData::GroupExecutePermission
| QFileSystemMetaData::OtherExecutePermission
@@ -1301,7 +1302,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
DWORD drivesBitmask = ::GetLogicalDrives();
::SetErrorMode(oldErrorMode);
int drivebit =
- 1 << (fname.filePath().at(0).toUpper().unicode() - QLatin1Char('A').unicode());
+ 1 << (fname.filePath().at(0).toUpper().unicode() - u'A');
if (drivesBitmask & drivebit) {
fileAttrib = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM;
entryExists = true;
@@ -1309,7 +1310,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
} else {
const QString &path = fname.nativeFilePath();
bool is_dir = false;
- if (path.startsWith(QLatin1String("\\\\?\\UNC"))) {
+ if (path.startsWith("\\\\?\\UNC"_L1)) {
// UNC - stat doesn't work for all cases (Windows bug)
int s = path.indexOf(path.at(0),7);
if (s > 0) {
@@ -1398,7 +1399,7 @@ bool QFileSystemEngine::fillMetaData(const QFileSystemEntry &entry, QFileSystemM
// Check for ".lnk": Directories named ".lnk" should be skipped, corrupted
// link files should still be detected as links.
const QString origFilePath = entry.filePath();
- if (origFilePath.endsWith(QLatin1String(".lnk")) && !isDirPath(origFilePath, nullptr)) {
+ if (origFilePath.endsWith(".lnk"_L1) && !isDirPath(origFilePath, nullptr)) {
data.entryFlags |= QFileSystemMetaData::WinLnkType;
fname = QFileSystemEntry(readLink(entry));
} else {
@@ -1471,8 +1472,8 @@ static inline bool rmDir(const QString &path)
bool QFileSystemEngine::isDirPath(const QString &dirPath, bool *existed)
{
QString path = dirPath;
- if (path.length() == 2 && path.at(1) == QLatin1Char(':'))
- path += QLatin1Char('\\');
+ if (path.length() == 2 && path.at(1) == u':')
+ path += u'\\';
const QString longPath = QFSFileEnginePrivate::longFileName(path);
DWORD fileAttrib = ::GetFileAttributes(reinterpret_cast<const wchar_t*>(longPath.utf16()));
@@ -1501,11 +1502,11 @@ static bool createDirectoryWithParents(const QString &nativeName,
bool shouldMkdirFirst = true)
{
const auto isUNCRoot = [](const QString &nativeName) {
- return nativeName.startsWith(QLatin1String("\\\\"))
+ return nativeName.startsWith("\\\\"_L1)
&& nativeName.count(QDir::separator()) <= 3;
};
const auto isDriveName = [](const QString &nativeName) {
- return nativeName.size() == 2 && nativeName.at(1) == QLatin1Char(':');
+ return nativeName.size() == 2 && nativeName.at(1) == u':';
};
const auto isDir = [](const QString &nativeName) {
bool exists = false;
@@ -1573,7 +1574,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
const auto chunkRef = QStringView{dirName}.left(slash);
if (chunkRef.length() == 2 && chunkRef.at(0).isLetter()
- && chunkRef.at(1) == QLatin1Char(':')) {
+ && chunkRef.at(1) == u':') {
break;
}
const QString chunk = chunkRef.toString();
@@ -1593,8 +1594,8 @@ QString QFileSystemEngine::rootPath()
{
QString ret = QString::fromLatin1(qgetenv("SystemDrive"));
if (ret.isEmpty())
- ret = QLatin1String("c:");
- ret.append(QLatin1Char('/'));
+ ret = "c:"_L1;
+ ret.append(u'/');
return ret;
}
@@ -1652,13 +1653,13 @@ QString QFileSystemEngine::tempPath()
QString::fromWCharArray(tempPath, len);
}
if (!ret.isEmpty()) {
- while (ret.endsWith(QLatin1Char('\\')))
+ while (ret.endsWith(u'\\'))
ret.chop(1);
ret = QDir::fromNativeSeparators(ret);
}
if (ret.isEmpty()) {
- ret = QLatin1String("C:/tmp");
- } else if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
+ ret = "C:/tmp"_L1;
+ } else if (ret.length() >= 2 && ret[1] == u':')
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
}
@@ -1695,7 +1696,7 @@ QFileSystemEntry QFileSystemEngine::currentPath()
ret = QString::fromWCharArray(currentName, size);
}
}
- if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
+ if (ret.length() >= 2 && ret[1] == u':')
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath());
}
diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp
index bb39a46642..0c2458c862 100644
--- a/src/corelib/io/qfilesystementry.cpp
+++ b/src/corelib/io/qfilesystementry.cpp
@@ -48,14 +48,16 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifdef Q_OS_WIN
static bool isUncRoot(const QString &server)
{
QString localPath = QDir::toNativeSeparators(server);
- if (!localPath.startsWith(QLatin1String("\\\\")))
+ if (!localPath.startsWith("\\\\"_L1))
return false;
- int idx = localPath.indexOf(QLatin1Char('\\'), 2);
+ int idx = localPath.indexOf(u'\\', 2);
if (idx == -1 || idx + 1 == localPath.length())
return true;
@@ -65,8 +67,8 @@ static bool isUncRoot(const QString &server)
static inline QString fixIfRelativeUncPath(const QString &path)
{
QString currentPath = QDir::currentPath();
- if (currentPath.startsWith(QLatin1String("//")))
- return currentPath % QChar(QLatin1Char('/')) % path;
+ if (currentPath.startsWith("//"_L1))
+ return currentPath % QChar(u'/') % path;
return path;
}
#endif
@@ -166,7 +168,7 @@ QString QFileSystemEntry::fileName() const
{
findLastSeparator();
#if defined(Q_OS_WIN)
- if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == u':')
return m_filePath.mid(2);
#endif
return m_filePath.mid(m_lastSeparator + 1);
@@ -177,15 +179,15 @@ QString QFileSystemEntry::path() const
findLastSeparator();
if (m_lastSeparator == -1) {
#if defined(Q_OS_WIN)
- if (m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ if (m_filePath.length() >= 2 && m_filePath.at(1) == u':')
return m_filePath.left(2);
#endif
- return QString(QLatin1Char('.'));
+ return QString(u'.');
}
if (m_lastSeparator == 0)
- return QString(QLatin1Char('/'));
+ return QString(u'/');
#if defined(Q_OS_WIN)
- if (m_lastSeparator == 2 && m_filePath.at(1) == QLatin1Char(':'))
+ if (m_lastSeparator == 2 && m_filePath.at(1) == u':')
return m_filePath.left(m_lastSeparator + 1);
#endif
return m_filePath.left(m_lastSeparator);
@@ -201,7 +203,7 @@ QString QFileSystemEntry::baseName() const
length--;
}
#if defined(Q_OS_WIN)
- if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == u':')
return m_filePath.mid(2, length - 2);
#endif
return m_filePath.mid(m_lastSeparator + 1, length);
@@ -217,7 +219,7 @@ QString QFileSystemEntry::completeBaseName() const
length--;
}
#if defined(Q_OS_WIN)
- if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == QLatin1Char(':'))
+ if (m_lastSeparator == -1 && m_filePath.length() >= 2 && m_filePath.at(1) == u':')
return m_filePath.mid(2, length - 2);
#endif
return m_filePath.mid(m_lastSeparator + 1, length);
@@ -259,8 +261,8 @@ bool QFileSystemEntry::isAbsolute() const
&& m_filePath.at(1).unicode() == ':'
&& m_filePath.at(2).unicode() == '/')
|| (m_filePath.length() >= 2
- && m_filePath.at(0) == QLatin1Char('/')
- && m_filePath.at(1) == QLatin1Char('/')));
+ && m_filePath.at(0) == u'/'
+ && m_filePath.at(1) == u'/'));
}
#else
bool QFileSystemEntry::isRelative() const
@@ -285,8 +287,8 @@ bool QFileSystemEntry::isDriveRoot() const
bool QFileSystemEntry::isDriveRootPath(const QString &path)
{
return (path.length() == 3
- && path.at(0).isLetter() && path.at(1) == QLatin1Char(':')
- && path.at(2) == QLatin1Char('/'));
+ && path.at(0).isLetter() && path.at(1) == u':'
+ && path.at(2) == u'/');
}
QString QFileSystemEntry::removeUncOrLongPathPrefix(QString path)
@@ -320,7 +322,7 @@ QString QFileSystemEntry::removeUncOrLongPathPrefix(QString path)
bool QFileSystemEntry::isRootPath(const QString &path)
{
- if (path == QLatin1String("/")
+ if (path == "/"_L1
#if defined(Q_OS_WIN)
|| isDriveRootPath(path)
|| isUncRoot(path)
@@ -343,7 +345,7 @@ void QFileSystemEntry::findLastSeparator() const
{
if (m_lastSeparator == -2) {
resolveFilePath();
- m_lastSeparator = m_filePath.lastIndexOf(QLatin1Char('/'));
+ m_lastSeparator = m_filePath.lastIndexOf(u'/');
}
}
@@ -402,7 +404,7 @@ bool QFileSystemEntry::isClean() const
bool dotok = true; // checking for ".." or "." starts to relative paths
bool slashok = true;
for (QString::const_iterator iter = m_filePath.constBegin(); iter != m_filePath.constEnd(); ++iter) {
- if (*iter == QLatin1Char('/')) {
+ if (*iter == u'/') {
if (dots == 1 || dots == 2)
return false; // path contains "./" or "../"
if (!slashok)
@@ -412,7 +414,7 @@ bool QFileSystemEntry::isClean() const
slashok = false;
} else if (dotok) {
slashok = true;
- if (*iter == QLatin1Char('.')) {
+ if (*iter == u'.') {
dots++;
if (dots > 2)
dotok = false;
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index ac52dacdce..91cfef644c 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
bool done = true;
QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Filters filters,
@@ -64,12 +66,12 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
QFileSystemEntry link = QFileSystemEngine::getLinkTarget(entry, metaData);
nativePath = link.nativeFilePath();
}
- if (!nativePath.endsWith(QLatin1Char('\\')))
- nativePath.append(QLatin1Char('\\'));
- nativePath.append(QLatin1Char('*'));
+ if (!nativePath.endsWith(u'\\'))
+ nativePath.append(u'\\');
+ nativePath.append(u'*');
// In MSVC2015+ case we prepend //?/ for longer file-name support
- if (!dirPath.endsWith(QLatin1Char('/')))
- dirPath.append(QLatin1Char('/'));
+ if (!dirPath.endsWith(u'/'))
+ dirPath.append(u'/');
if ((filters & (QDir::Dirs|QDir::Drives)) && (!(filters & (QDir::Files))))
onlyDirs = true;
}
@@ -97,10 +99,10 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
findFileHandle = FindFirstFileEx((const wchar_t *)nativePath.utf16(), FINDEX_INFO_LEVELS(infoLevel), &findData,
FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags);
if (findFileHandle == INVALID_HANDLE_VALUE) {
- if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) {
- const auto parts = QStringView{nativePath}.split(QLatin1Char('\\'), Qt::SkipEmptyParts);
+ if (nativePath.startsWith("\\\\?\\UNC\\"_L1)) {
+ const auto parts = QStringView{nativePath}.split(u'\\', Qt::SkipEmptyParts);
if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer(
- QLatin1String("\\\\") + parts.at(2), &uncShares)) {
+ "\\\\"_L1 + parts.at(2), &uncShares)) {
if (uncShares.isEmpty())
return false; // No shares found in the server
uncFallback = true;
@@ -129,7 +131,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
QString fileName = QString::fromWCharArray(findData.cFileName);
fileEntry = QFileSystemEntry(dirPath + fileName);
metaData = QFileSystemMetaData();
- if (!fileName.endsWith(QLatin1String(".lnk"))) {
+ if (!fileName.endsWith(".lnk"_L1)) {
metaData.fillFromFindData(findData, true);
}
return true;
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index bd5a73da84..4fceb5c1ca 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -67,6 +67,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_LOGGING_CATEGORY(lcWatcher, "qt.core.filesystemwatcher")
QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent)
@@ -364,14 +366,14 @@ QStringList QFileSystemWatcher::addPaths(const QStringList &paths)
#ifdef QT_BUILD_INTERNAL
const QString on = objectName();
- if (Q_UNLIKELY(on.startsWith(QLatin1String("_qt_autotest_force_engine_")))) {
+ if (Q_UNLIKELY(on.startsWith("_qt_autotest_force_engine_"_L1))) {
// Autotest override case - use the explicitly selected engine only
const auto forceName = QStringView{on}.mid(26);
- if (forceName == QLatin1String("poller")) {
+ if (forceName == "poller"_L1) {
qCDebug(lcWatcher, "QFileSystemWatcher: skipping native engine, using only polling engine");
d_func()->initPollerEngine();
return d->poller;
- } else if (forceName == QLatin1String("native")) {
+ } else if (forceName == "native"_L1) {
qCDebug(lcWatcher, "QFileSystemWatcher: skipping polling engine, using only native engine");
return d->native;
}
diff --git a/src/corelib/io/qfilesystemwatcher_polling.cpp b/src/corelib/io/qfilesystemwatcher_polling.cpp
index 6920eab258..330df998b5 100644
--- a/src/corelib/io/qfilesystemwatcher_polling.cpp
+++ b/src/corelib/io/qfilesystemwatcher_polling.cpp
@@ -64,8 +64,8 @@ QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths,
if (directories->contains(path))
continue;
directories->append(path);
- if (!path.endsWith(QLatin1Char('/')))
- fi = QFileInfo(path + QLatin1Char('/'));
+ if (!path.endsWith(u'/'))
+ fi = QFileInfo(path + u'/');
this->directories.insert(path, fi);
} else {
if (files->contains(path))
@@ -127,8 +127,8 @@ void QPollingFileSystemWatcherEngine::timeout()
for (auto it = directories.begin(), end = directories.end(); it != end; /*erasing*/) {
QString path = it.key();
QFileInfo fi(path);
- if (!path.endsWith(QLatin1Char('/')))
- fi = QFileInfo(path + QLatin1Char('/'));
+ if (!path.endsWith(u'/'))
+ fi = QFileInfo(path + u'/');
if (!fi.exists()) {
it = directories.erase(it);
emit directoryChanged(path, true);
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index 5d8a5b3682..a836c56473 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -63,6 +63,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// #define WINQFSW_DEBUG
#ifdef WINQFSW_DEBUG
# define DEBUG qDebug
@@ -75,8 +77,8 @@ static Qt::HANDLE createChangeNotification(const QString &path, uint flags)
// Volume and folder paths need a trailing slash for proper notification
// (e.g. "c:" -> "c:/").
QString nativePath = QDir::toNativeSeparators(path);
- if ((flags & FILE_NOTIFY_CHANGE_ATTRIBUTES) == 0 && !nativePath.endsWith(QLatin1Char('\\')))
- nativePath.append(QLatin1Char('\\'));
+ if ((flags & FILE_NOTIFY_CHANGE_ATTRIBUTES) == 0 && !nativePath.endsWith(u'\\'))
+ nativePath.append(u'\\');
const HANDLE result = FindFirstChangeNotification(reinterpret_cast<const wchar_t *>(nativePath.utf16()),
FALSE, flags);
DEBUG() << __FUNCTION__ << nativePath << Qt::hex << Qt::showbase << flags << "returns" << result;
@@ -274,7 +276,7 @@ bool QWindowsRemovableDriveListener::nativeEventFilter(const QByteArray &, void
// Set up listening for WM_DEVICECHANGE+DBT_CUSTOMEVENT for a removable drive path,
void QWindowsRemovableDriveListener::addPath(const QString &p)
{
- const wchar_t drive = p.size() >= 2 && p.at(0).isLetter() && p.at(1) == QLatin1Char(':')
+ const wchar_t drive = p.size() >= 2 && p.at(0).isLetter() && p.at(1) == u':'
? wchar_t(p.at(0).toUpper().unicode()) : L'\0';
if (!drive)
return;
@@ -367,8 +369,8 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
for (const QString &path : paths) {
auto sg = qScopeGuard([&] { unhandled.push_back(path); });
QString normalPath = path;
- if ((normalPath.endsWith(QLatin1Char('/')) && !normalPath.endsWith(QLatin1String(":/")))
- || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))) {
+ if ((normalPath.endsWith(u'/') && !normalPath.endsWith(":/"_L1))
+ || (normalPath.endsWith(u'\\') && !normalPath.endsWith(":\\"_L1))) {
normalPath.chop(1);
}
QFileInfo fileInfo(normalPath);
@@ -530,7 +532,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path
for (const QString &path : paths) {
auto sg = qScopeGuard([&] { unhandled.push_back(path); });
QString normalPath = path;
- if (normalPath.endsWith(QLatin1Char('/')) || normalPath.endsWith(QLatin1Char('\\')))
+ if (normalPath.endsWith(u'/') || normalPath.endsWith(u'\\'))
normalPath.chop(1);
QFileInfo fileInfo(normalPath);
DEBUG() << "removing" << normalPath;
@@ -631,10 +633,10 @@ Q_DECL_COLD_FUNCTION
static QString msgFindNextFailed(const QWindowsFileSystemWatcherEngineThread::PathInfoHash &pathInfos)
{
QString str;
- str += QLatin1String("QFileSystemWatcher: FindNextChangeNotification failed for");
+ str += "QFileSystemWatcher: FindNextChangeNotification failed for"_L1;
for (const QWindowsFileSystemWatcherEngine::PathInfo &pathInfo : pathInfos)
- str += QLatin1String(" \"") + QDir::toNativeSeparators(pathInfo.absolutePath) + QLatin1Char('"');
- str += QLatin1Char(' ');
+ str += " \""_L1 + QDir::toNativeSeparators(pathInfo.absolutePath) + u'"';
+ str += u' ';
return str;
}
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 4ba35abacb..a28cc823d5 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifdef Q_OS_WIN
# ifndef S_ISREG
# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
@@ -173,14 +175,14 @@ ProcessOpenModeResult processOpenModeFlags(QIODevice::OpenMode openMode)
result.ok = false;
if ((openMode & QFile::NewOnly) && (openMode & QFile::ExistingOnly)) {
qWarning("NewOnly and ExistingOnly are mutually exclusive");
- result.error = QLatin1String("NewOnly and ExistingOnly are mutually exclusive");
+ result.error = "NewOnly and ExistingOnly are mutually exclusive"_L1;
return result;
}
if ((openMode & QFile::ExistingOnly) && !(openMode & (QFile::ReadOnly | QFile::WriteOnly))) {
qWarning("ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite");
- result.error = QLatin1String(
- "ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite");
+ result.error =
+ "ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite"_L1;
return result;
}
@@ -235,7 +237,7 @@ bool QFSFileEngine::open(QIODevice::OpenMode openMode,
Q_D(QFSFileEngine);
if (d->fileEntry.isEmpty()) {
qWarning("QFSFileEngine::open: No file name specified");
- setError(QFile::OpenError, QLatin1String("No file name specified"));
+ setError(QFile::OpenError, "No file name specified"_L1);
return false;
}
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 60e25d34f1..840c0d9f37 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -69,11 +69,13 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static inline bool isUncPath(const QString &path)
{
// Starts with \\, but not \\.
- return (path.startsWith(QLatin1String("\\\\"))
- && path.size() > 2 && path.at(2) != QLatin1Char('.'));
+ return (path.startsWith("\\\\"_L1)
+ && path.size() > 2 && path.at(2) != u'.');
}
/*!
@@ -81,13 +83,13 @@ static inline bool isUncPath(const QString &path)
*/
QString QFSFileEnginePrivate::longFileName(const QString &path)
{
- if (path.startsWith(QLatin1String("\\\\.\\")))
+ if (path.startsWith("\\\\.\\"_L1))
return path;
QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path);
- QString prefix = QLatin1String("\\\\?\\");
+ QString prefix = "\\\\?\\"_L1;
if (isUncPath(absPath)) {
- prefix.append(QLatin1String("UNC\\")); // "\\\\?\\UNC\\"
+ prefix.append("UNC\\"_L1); // "\\\\?\\UNC\\"
absPath.remove(0, 2);
}
return prefix + absPath;
@@ -438,7 +440,7 @@ QString QFSFileEngine::currentPath(const QString &fileName)
QString ret;
//if filename is a drive: then get the pwd of that drive
if (fileName.length() >= 2 &&
- fileName.at(0).isLetter() && fileName.at(1) == QLatin1Char(':')) {
+ fileName.at(0).isLetter() && fileName.at(1) == u':') {
int drv = fileName.toUpper().at(0).toLatin1() - 'A' + 1;
if (_getdrive() != drv) {
wchar_t buf[PATH_MAX];
@@ -450,7 +452,7 @@ QString QFSFileEngine::currentPath(const QString &fileName)
//just the pwd
ret = QFileSystemEngine::currentPath().filePath();
}
- if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
+ if (ret.length() >= 2 && ret[1] == u':')
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
}
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 978c6f2486..fdeed890f4 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -55,6 +55,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifdef QIODEVICE_DEBUG
void debugBinaryString(const QByteArray &input)
{
@@ -2246,23 +2248,23 @@ QDebug operator<<(QDebug debug, QIODevice::OpenMode modes)
debug << "OpenMode(";
QStringList modeList;
if (modes == QIODevice::NotOpen) {
- modeList << QLatin1String("NotOpen");
+ modeList << "NotOpen"_L1;
} else {
if (modes & QIODevice::ReadOnly)
- modeList << QLatin1String("ReadOnly");
+ modeList << "ReadOnly"_L1;
if (modes & QIODevice::WriteOnly)
- modeList << QLatin1String("WriteOnly");
+ modeList << "WriteOnly"_L1;
if (modes & QIODevice::Append)
- modeList << QLatin1String("Append");
+ modeList << "Append"_L1;
if (modes & QIODevice::Truncate)
- modeList << QLatin1String("Truncate");
+ modeList << "Truncate"_L1;
if (modes & QIODevice::Text)
- modeList << QLatin1String("Text");
+ modeList << "Text"_L1;
if (modes & QIODevice::Unbuffered)
- modeList << QLatin1String("Unbuffered");
+ modeList << "Unbuffered"_L1;
}
std::sort(modeList.begin(), modeList.end());
- debug << modeList.join(QLatin1Char('|'));
+ debug << modeList.join(u'|');
debug << ')';
return debug;
}
diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp
index 911d1a54b9..cf77ac2977 100644
--- a/src/corelib/io/qipaddress.cpp
+++ b/src/corelib/io/qipaddress.cpp
@@ -44,6 +44,9 @@
#include "qvarlengtharray.h"
QT_BEGIN_NAMESPACE
+
+using namespace Qt::StringLiterals;
+
namespace QIPAddressUtils {
static QString number(quint8 val, int base = 10)
@@ -130,12 +133,9 @@ void toString(QString &appendTo, IPv4Address address)
{
// reconstructing is easy
// use the fast operator% that pre-calculates the size
- appendTo += number(address >> 24)
- % QLatin1Char('.')
- % number(address >> 16)
- % QLatin1Char('.')
- % number(address >> 8)
- % QLatin1Char('.')
+ appendTo += number(address >> 24) % u'.'
+ % number(address >> 16) % u'.'
+ % number(address >> 8) % u'.'
% number(address);
}
@@ -283,7 +283,7 @@ void toString(QString &appendTo, const IPv6Address address)
if (address[12] != 0 || address[13] != 0 || address[14] != 0) {
embeddedIp4 = true;
} else if (address[15] == 0) {
- appendTo.append(QLatin1String("::"));
+ appendTo.append("::"_L1);
return;
}
}
diff --git a/src/corelib/io/qlockfile.cpp b/src/corelib/io/qlockfile.cpp
index e6812cedde..7ff8e16abb 100644
--- a/src/corelib/io/qlockfile.cpp
+++ b/src/corelib/io/qlockfile.cpp
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
struct LockFileInfo
{
@@ -293,7 +295,7 @@ bool QLockFile::tryLock(int timeout)
qInfo("QLockFile: Lock file '%ls' has a modification time in the future", qUtf16Printable(d->fileName));
// Stale lock from another thread/process
// Ensure two processes don't remove it at the same time
- QLockFile rmlock(d->fileName + QLatin1String(".rmlock"));
+ QLockFile rmlock(d->fileName + ".rmlock"_L1);
if (rmlock.tryLock()) {
if (d->isApparentlyStale() && d->removeStaleLock())
continue;
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index 6c0d2c1f8d..cd52c86866 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -142,10 +142,10 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
if (!length)
return QString();
QString name = QString::fromWCharArray(buf, length);
- int i = name.lastIndexOf(QLatin1Char('\\'));
+ int i = name.lastIndexOf(u'\\');
if (i >= 0)
name.remove(0, i + 1);
- i = name.lastIndexOf(QLatin1Char('.'));
+ i = name.lastIndexOf(u'.');
if (i >= 0)
name.truncate(i);
return name;
diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp
index 52d76d689a..a5c6a3cfed 100644
--- a/src/corelib/io/qloggingregistry.cpp
+++ b/src/corelib/io/qloggingregistry.cpp
@@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_GLOBAL_STATIC(QLoggingRegistry, qtLoggingRegistry)
/*!
@@ -133,34 +135,35 @@ void QLoggingRule::parse(QStringView pattern)
QStringView p;
// strip trailing ".messagetype"
- if (pattern.endsWith(QLatin1String(".debug"))) {
+ if (pattern.endsWith(".debug"_L1)) {
p = pattern.chopped(6); // strlen(".debug")
messageType = QtDebugMsg;
- } else if (pattern.endsWith(QLatin1String(".info"))) {
+ } else if (pattern.endsWith(".info"_L1)) {
p = pattern.chopped(5); // strlen(".info")
messageType = QtInfoMsg;
- } else if (pattern.endsWith(QLatin1String(".warning"))) {
+ } else if (pattern.endsWith(".warning"_L1)) {
p = pattern.chopped(8); // strlen(".warning")
messageType = QtWarningMsg;
- } else if (pattern.endsWith(QLatin1String(".critical"))) {
+ } else if (pattern.endsWith(".critical"_L1)) {
p = pattern.chopped(9); // strlen(".critical")
messageType = QtCriticalMsg;
} else {
p = pattern;
}
- if (!p.contains(QLatin1Char('*'))) {
+ const QChar asterisk = u'*';
+ if (!p.contains(asterisk)) {
flags = FullText;
} else {
- if (p.endsWith(QLatin1Char('*'))) {
+ if (p.endsWith(asterisk)) {
flags |= LeftFilter;
p = p.chopped(1);
}
- if (p.startsWith(QLatin1Char('*'))) {
+ if (p.startsWith(asterisk)) {
flags |= RightFilter;
p = p.mid(1);
}
- if (p.contains(QLatin1Char('*'))) // '*' only supported at start/end
+ if (p.contains(asterisk)) // '*' only supported at start/end
flags = PatternFlags();
}
@@ -216,20 +219,20 @@ void QLoggingSettingsParser::parseNextLine(QStringView line)
line = line.trimmed();
// comment
- if (line.startsWith(QLatin1Char(';')))
+ if (line.startsWith(u';'))
return;
- if (line.startsWith(QLatin1Char('[')) && line.endsWith(QLatin1Char(']'))) {
+ if (line.startsWith(u'[') && line.endsWith(u']')) {
// new section
auto sectionName = line.mid(1).chopped(1).trimmed();
- m_inRulesSection = sectionName.compare(QLatin1String("rules"), Qt::CaseInsensitive) == 0;
+ m_inRulesSection = sectionName.compare("rules"_L1, Qt::CaseInsensitive) == 0;
return;
}
if (m_inRulesSection) {
- int equalPos = line.indexOf(QLatin1Char('='));
+ int equalPos = line.indexOf(u'=');
if (equalPos != -1) {
- if (line.lastIndexOf(QLatin1Char('=')) == equalPos) {
+ if (line.lastIndexOf(u'=') == equalPos) {
const auto key = line.left(equalPos).trimmed();
#if QT_CONFIG(settings)
QString tmp;
@@ -240,9 +243,9 @@ void QLoggingSettingsParser::parseNextLine(QStringView line)
#endif
const auto valueStr = line.mid(equalPos + 1).trimmed();
int value = -1;
- if (valueStr == QLatin1String("true"))
+ if (valueStr == "true"_L1)
value = 1;
- else if (valueStr == QLatin1String("false"))
+ else if (valueStr == "false"_L1)
value = 0;
QLoggingRule rule(pattern, (value == 1));
if (rule.flags != 0 && (value != -1))
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 3378412502..e21827e64e 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -98,7 +98,7 @@ QStringList QProcessEnvironmentPrivate::toList() const
QStringList result;
result.reserve(vars.size());
for (auto it = vars.cbegin(), end = vars.cend(); it != end; ++it)
- result << nameToString(it.key()) + QLatin1Char('=') + valueToString(it.value());
+ result << nameToString(it.key()) + u'=' + valueToString(it.value());
return result;
}
@@ -108,7 +108,7 @@ QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list
QStringList::ConstIterator it = list.constBegin(),
end = list.constEnd();
for ( ; it != end; ++it) {
- int pos = it->indexOf(QLatin1Char('='), 1);
+ int pos = it->indexOf(u'=', 1);
if (pos < 1)
continue;
@@ -2213,7 +2213,7 @@ QStringList QProcess::splitCommand(QStringView command)
// "hello world". three consecutive double quotes represent
// the quote character itself.
for (int i = 0; i < command.size(); ++i) {
- if (command.at(i) == QLatin1Char('"')) {
+ if (command.at(i) == u'"') {
++quoteCount;
if (quoteCount == 3) {
// third consecutive quote
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 9f97bb7af9..9973ab76cd 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -79,6 +79,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if !defined(Q_OS_DARWIN)
QT_BEGIN_INCLUDE_NAMESPACE
@@ -415,7 +417,7 @@ static QString resolveExecutable(const QString &program)
#ifdef Q_OS_DARWIN
// allow invoking of .app bundles on the Mac.
QFileInfo fileInfo(program);
- if (program.endsWith(QLatin1String(".app")) && fileInfo.isDir()) {
+ if (program.endsWith(".app"_L1) && fileInfo.isDir()) {
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0,
QCFString(fileInfo.absoluteFilePath()),
kCFURLPOSIXPathStyle, true);
@@ -437,7 +439,7 @@ static QString resolveExecutable(const QString &program)
}
#endif
- if (!program.contains(QLatin1Char('/'))) {
+ if (!program.contains(u'/')) {
// findExecutable() returns its argument if it's an absolute path,
// otherwise it searches $PATH; returns empty if not found (we handle
// that case much later)
@@ -625,7 +627,7 @@ bool QProcessPrivate::processStarted(QString *errorMessage)
// did we read an error message?
if (errorMessage)
- *errorMessage = QLatin1String(buf.function) + QLatin1String(": ") + qt_error_string(buf.code);
+ *errorMessage = QLatin1String(buf.function) + ": "_L1 + qt_error_string(buf.code);
return false;
}
@@ -946,7 +948,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
AutoPipe startedPipe, pidPipe;
if (!startedPipe || !pidPipe) {
- setErrorAndEmit(QProcess::FailedToStart, QLatin1String("pipe: ") + qt_error_string(errno));
+ setErrorAndEmit(QProcess::FailedToStart, "pipe: "_L1 + qt_error_string(errno));
return false;
}
@@ -1003,7 +1005,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
closeChannels();
if (childPid == -1) {
- setErrorAndEmit(QProcess::FailedToStart, QLatin1String("fork: ") + qt_error_string(savedErrno));
+ setErrorAndEmit(QProcess::FailedToStart, "fork: "_L1 + qt_error_string(savedErrno));
return false;
}
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 3e2257109d..6b29710c84 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -64,6 +64,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
@@ -391,44 +393,44 @@ static QString qt_create_commandline(const QString &program, const QStringList &
QString args;
if (!program.isEmpty()) {
QString programName = program;
- if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
- programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
- programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
+ if (!programName.startsWith(u'\"') && !programName.endsWith(u'\"') && programName.contains(u' '))
+ programName = u'\"' + programName + u'\"';
+ programName.replace(u'/', u'\\');
// add the program as the first arg ... it works better
- args = programName + QLatin1Char(' ');
+ args = programName + u' ';
}
for (qsizetype i = 0; i < arguments.size(); ++i) {
QString tmp = arguments.at(i);
// Quotes are escaped and their preceding backslashes are doubled.
- qsizetype index = tmp.indexOf(QLatin1Char('"'));
+ qsizetype index = tmp.indexOf(u'"');
while (index >= 0) {
// Escape quote
- tmp.insert(index++, QLatin1Char('\\'));
+ tmp.insert(index++, u'\\');
// Double preceding backslashes (ignoring the one we just inserted)
- for (qsizetype i = index - 2 ; i >= 0 && tmp.at(i) == QLatin1Char('\\') ; --i) {
- tmp.insert(i, QLatin1Char('\\'));
+ for (qsizetype i = index - 2 ; i >= 0 && tmp.at(i) == u'\\' ; --i) {
+ tmp.insert(i, u'\\');
index++;
}
- index = tmp.indexOf(QLatin1Char('"'), index + 1);
+ index = tmp.indexOf(u'"', index + 1);
}
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
+ if (tmp.isEmpty() || tmp.contains(u' ') || tmp.contains(u'\t')) {
// The argument must not end with a \ since this would be interpreted
// as escaping the quote -- rather put the \ behind the quote: e.g.
// rather use "foo"\ than "foo\"
qsizetype i = tmp.length();
- while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\'))
+ while (i > 0 && tmp.at(i - 1) == u'\\')
--i;
- tmp.insert(i, QLatin1Char('"'));
- tmp.prepend(QLatin1Char('"'));
+ tmp.insert(i, u'"');
+ tmp.prepend(u'"');
}
- args += QLatin1Char(' ') + tmp;
+ args += u' ' + tmp;
}
if (!nativeArguments.isEmpty()) {
if (!args.isEmpty())
- args += QLatin1Char(' ');
+ args += u' ';
args += nativeArguments;
}
@@ -441,7 +443,7 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Map &e
QProcessEnvironmentPrivate::Map copy = environment;
// add PATH if necessary (for DLL loading)
- QProcessEnvironmentPrivate::Key pathKey(QLatin1String("PATH"));
+ QProcessEnvironmentPrivate::Key pathKey("PATH"_L1);
if (!copy.contains(pathKey)) {
QByteArray path = qgetenv("PATH");
if (!path.isEmpty())
@@ -449,7 +451,7 @@ static QByteArray qt_create_environment(const QProcessEnvironmentPrivate::Map &e
}
// add systemroot if needed
- QProcessEnvironmentPrivate::Key rootKey(QLatin1String("SystemRoot"));
+ QProcessEnvironmentPrivate::Key rootKey("SystemRoot"_L1);
if (!copy.contains(rootKey)) {
QByteArray systemRoot = qgetenv("SystemRoot");
if (!systemRoot.isEmpty())
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index af0b9429af..fe19a8f4f4 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -78,6 +78,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// Symbols used by code generated by RCC.
// They cause compilation errors if the RCC content couldn't
// be interpreted by this QtCore version.
@@ -125,7 +127,7 @@ public:
const QChar *m_data;
qsizetype m_len;
qsizetype m_pos = 0;
- QChar m_splitChar = QLatin1Char('/');
+ QChar m_splitChar = u'/';
};
// resource glue
@@ -189,7 +191,7 @@ static QString cleanPath(const QString &_path)
QString path = QDir::cleanPath(_path);
// QDir::cleanPath does not remove two trailing slashes under _Windows_
// due to support for UNC paths. Remove those manually.
- if (path.startsWith(QLatin1String("//")))
+ if (path.startsWith("//"_L1))
path.remove(0, 1);
return path;
}
@@ -381,26 +383,26 @@ void QResourcePrivate::ensureInitialized() const
if (!related.isEmpty())
return;
QResourcePrivate *that = const_cast<QResourcePrivate *>(this);
- if (fileName == QLatin1String(":"))
- that->fileName += QLatin1Char('/');
+ if (fileName == ":"_L1)
+ that->fileName += u'/';
that->absoluteFilePath = fileName;
- if (!that->absoluteFilePath.startsWith(QLatin1Char(':')))
- that->absoluteFilePath.prepend(QLatin1Char(':'));
+ if (!that->absoluteFilePath.startsWith(u':'))
+ that->absoluteFilePath.prepend(u':');
QStringView path(fileName);
- if (path.startsWith(QLatin1Char(':')))
+ if (path.startsWith(u':'))
path = path.mid(1);
- if (path.startsWith(QLatin1Char('/'))) {
+ if (path.startsWith(u'/')) {
that->load(path.toString());
} else {
const auto locker = qt_scoped_lock(resourceMutex());
QStringList searchPaths = *resourceSearchPaths();
- searchPaths << QLatin1String("");
+ searchPaths << ""_L1;
for (int i = 0; i < searchPaths.size(); ++i) {
- const QString searchPath(searchPaths.at(i) + QLatin1Char('/') + path);
+ const QString searchPath(searchPaths.at(i) + u'/' + path);
if (that->load(searchPath)) {
- that->absoluteFilePath = QLatin1Char(':') + searchPath;
+ that->absoluteFilePath = u':' + searchPath;
break;
}
}
@@ -414,7 +416,7 @@ void QResourcePrivate::ensureChildren() const
return;
QString path = absoluteFilePath, k;
- if (path.startsWith(QLatin1Char(':')))
+ if (path.startsWith(u':'))
path = path.mid(1);
QDuplicateTracker<QString> kids(related.size());
QString cleaned = cleanPath(path);
@@ -808,14 +810,14 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
QString root = mappingRoot();
if (!root.isEmpty()) {
if (root == path) {
- path = QLatin1Char('/');
+ path = u'/';
} else {
- if (!root.endsWith(QLatin1Char('/')))
- root += QLatin1Char('/');
+ if (!root.endsWith(u'/'))
+ root += u'/';
if (path.size() >= root.size() && path.startsWith(root))
path = path.mid(root.length() - 1);
if (path.isEmpty())
- path = QLatin1Char('/');
+ path = u'/';
}
}
}
@@ -823,7 +825,7 @@ int QResourceRoot::findNode(const QString &_path, const QLocale &locale) const
qDebug() << "!!!!" << "START" << path << locale.territory() << locale.language();
#endif
- if (path == QLatin1String("/"))
+ if (path == "/"_L1)
return 0;
// the root node is always first
@@ -1228,7 +1230,7 @@ bool QDynamicFileResourceRoot::registerSelf(const QString &f)
static QString qt_resource_fixResourceRoot(QString r)
{
if (!r.isEmpty()) {
- if (r.startsWith(QLatin1Char(':')))
+ if (r.startsWith(u':'))
r = r.mid(1);
if (!r.isEmpty())
r = QDir::cleanPath(r);
@@ -1249,7 +1251,7 @@ static QString qt_resource_fixResourceRoot(QString r)
bool QResource::registerResource(const QString &rccFilename, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
- if (!r.isEmpty() && r[0] != QLatin1Char('/')) {
+ if (!r.isEmpty() && r[0] != u'/') {
qWarning("QDir::registerResource: Registering a resource [%ls] must be rooted in an "
"absolute path (start with /) [%ls]",
qUtf16Printable(rccFilename), qUtf16Printable(resourceRoot));
@@ -1318,7 +1320,7 @@ bool QResource::unregisterResource(const QString &rccFilename, const QString &re
bool QResource::registerResource(const uchar *rccData, const QString &resourceRoot)
{
QString r = qt_resource_fixResourceRoot(resourceRoot);
- if (!r.isEmpty() && r[0] != QLatin1Char('/')) {
+ if (!r.isEmpty() && r[0] != u'/') {
qWarning("QDir::registerResource: Registering a resource [%p] must be rooted in an "
"absolute path (start with /) [%ls]",
rccData, qUtf16Printable(resourceRoot));
@@ -1512,7 +1514,7 @@ QAbstractFileEngine::FileFlags QResourceFileEngine::fileFlags(QAbstractFileEngin
}
if (type & FlagsMask) {
ret |= ExistsFlag;
- if (d->resource.absoluteFilePath() == QLatin1String(":/"))
+ if (d->resource.absoluteFilePath() == ":/"_L1)
ret |= RootFlag;
}
return ret;
@@ -1522,24 +1524,24 @@ QString QResourceFileEngine::fileName(FileName file) const
{
Q_D(const QResourceFileEngine);
if (file == BaseName) {
- int slash = d->resource.fileName().lastIndexOf(QLatin1Char('/'));
+ int slash = d->resource.fileName().lastIndexOf(u'/');
if (slash == -1)
return d->resource.fileName();
return d->resource.fileName().mid(slash + 1);
} else if (file == PathName || file == AbsolutePathName) {
const QString path = (file == AbsolutePathName) ? d->resource.absoluteFilePath()
: d->resource.fileName();
- const int slash = path.lastIndexOf(QLatin1Char('/'));
+ const int slash = path.lastIndexOf(u'/');
if (slash == -1)
- return QLatin1String(":");
+ return ":"_L1;
else if (slash <= 1)
- return QLatin1String(":/");
+ return ":/"_L1;
return path.left(slash);
} else if (file == CanonicalName || file == CanonicalPathName) {
const QString absoluteFilePath = d->resource.absoluteFilePath();
if (file == CanonicalPathName) {
- const int slash = absoluteFilePath.lastIndexOf(QLatin1Char('/'));
+ const int slash = absoluteFilePath.lastIndexOf(u'/');
if (slash != -1)
return absoluteFilePath.left(slash);
}
diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp
index afe39287bd..a1518fa83a 100644
--- a/src/corelib/io/qsavefile.cpp
+++ b/src/corelib/io/qsavefile.cpp
@@ -55,6 +55,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
QSaveFilePrivate::QSaveFilePrivate()
: writeError(QFileDevice::NoError),
useTemporaryFile(true),
@@ -246,10 +248,10 @@ bool QSaveFile::open(OpenMode mode)
bool requiresDirectWrite = false;
#ifdef Q_OS_WIN
// check if it is an Alternate Data Stream
- requiresDirectWrite = d->finalFileName == d->fileName && d->fileName.indexOf(QLatin1Char(':'), 2) > 1;
+ requiresDirectWrite = d->finalFileName == d->fileName && d->fileName.indexOf(u':', 2) > 1;
#elif defined(Q_OS_ANDROID)
// check if it is a content:// URL
- requiresDirectWrite = d->fileName.startsWith(QLatin1String("content://"));
+ requiresDirectWrite = d->fileName.startsWith("content://"_L1);
#endif
if (requiresDirectWrite) {
// yes, we can't rename onto it...
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index d3868a92a5..e90ada20db 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -100,6 +100,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
struct QConfFileCustomFormat
{
QString extension;
@@ -323,7 +325,7 @@ QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::F
void QSettingsPrivate::processChild(QStringView key, ChildSpec spec, QStringList &result)
{
if (spec != AllKeys) {
- int slashPos = key.indexOf(QLatin1Char('/'));
+ int slashPos = key.indexOf(u'/');
if (slashPos == -1) {
if (spec != ChildKeys)
return;
@@ -341,7 +343,7 @@ void QSettingsPrivate::beginGroupOrArray(const QSettingsGroup &group)
groupStack.push(group);
const QString name = group.name();
if (!name.isEmpty())
- groupPrefix += name + QLatin1Char('/');
+ groupPrefix += name + u'/';
}
/*
@@ -390,8 +392,8 @@ QVariant QSettingsPrivate::stringListToVariantList(const QStringList &l)
for (int i = 0; i < outStringList.count(); ++i) {
const QString &str = outStringList.at(i);
- if (str.startsWith(QLatin1Char('@'))) {
- if (str.length() >= 2 && str.at(1) == QLatin1Char('@')) {
+ if (str.startsWith(u'@')) {
+ if (str.length() >= 2 && str.at(1) == u'@') {
outStringList[i].remove(0, 1);
} else {
QVariantList variantList;
@@ -412,14 +414,14 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
switch (v.metaType().id()) {
case QMetaType::UnknownType:
- result = QLatin1String("@Invalid()");
+ result = "@Invalid()"_L1;
break;
case QMetaType::QByteArray: {
QByteArray a = v.toByteArray();
- result = QLatin1String("@ByteArray(")
+ result = "@ByteArray("_L1
+ QLatin1String(a.constData(), a.size())
- + QLatin1Char(')');
+ + u')';
break;
}
@@ -436,9 +438,9 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
case QMetaType::Double: {
result = v.toString();
if (result.contains(QChar::Null))
- result = QLatin1String("@String(") + result + QLatin1Char(')');
- else if (result.startsWith(QLatin1Char('@')))
- result.prepend(QLatin1Char('@'));
+ result = "@String("_L1 + result + u')';
+ else if (result.startsWith(u'@'))
+ result.prepend(u'@');
break;
}
#ifndef QT_NO_GEOM_VARIANT
@@ -479,7 +481,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
result = QLatin1String(typeSpec)
+ QLatin1String(a.constData(), a.size())
- + QLatin1Char(')');
+ + u')';
#else
Q_ASSERT(!"QSettings: Cannot save custom types without QDataStream support");
#endif
@@ -493,18 +495,18 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
QVariant QSettingsPrivate::stringToVariant(const QString &s)
{
- if (s.startsWith(QLatin1Char('@'))) {
- if (s.endsWith(QLatin1Char(')'))) {
- if (s.startsWith(QLatin1String("@ByteArray("))) {
+ if (s.startsWith(u'@')) {
+ if (s.endsWith(u')')) {
+ if (s.startsWith("@ByteArray("_L1)) {
return QVariant(QStringView{s}.mid(11, s.size() - 12).toLatin1());
- } else if (s.startsWith(QLatin1String("@String("))) {
+ } else if (s.startsWith("@String("_L1)) {
return QVariant(QStringView{s}.mid(8, s.size() - 9).toString());
- } else if (s.startsWith(QLatin1String("@Variant("))
- || s.startsWith(QLatin1String("@DateTime("))) {
+ } else if (s.startsWith("@Variant("_L1)
+ || s.startsWith("@DateTime("_L1)) {
#ifndef QT_NO_DATASTREAM
QDataStream::Version version;
int offset;
- if (s.at(1) == QLatin1Char('D')) {
+ if (s.at(1) == u'D') {
version = QDataStream::Qt_5_6;
offset = 10;
} else {
@@ -521,25 +523,25 @@ QVariant QSettingsPrivate::stringToVariant(const QString &s)
Q_ASSERT(!"QSettings: Cannot load custom types without QDataStream support");
#endif
#ifndef QT_NO_GEOM_VARIANT
- } else if (s.startsWith(QLatin1String("@Rect("))) {
+ } else if (s.startsWith("@Rect("_L1)) {
QStringList args = QSettingsPrivate::splitArgs(s, 5);
if (args.size() == 4)
return QVariant(QRect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt()));
- } else if (s.startsWith(QLatin1String("@Size("))) {
+ } else if (s.startsWith("@Size("_L1)) {
QStringList args = QSettingsPrivate::splitArgs(s, 5);
if (args.size() == 2)
return QVariant(QSize(args[0].toInt(), args[1].toInt()));
- } else if (s.startsWith(QLatin1String("@Point("))) {
+ } else if (s.startsWith("@Point("_L1)) {
QStringList args = QSettingsPrivate::splitArgs(s, 6);
if (args.size() == 2)
return QVariant(QPoint(args[0].toInt(), args[1].toInt()));
#endif
- } else if (s == QLatin1String("@Invalid()")) {
+ } else if (s == "@Invalid()"_L1) {
return QVariant();
}
}
- if (s.startsWith(QLatin1String("@@")))
+ if (s.startsWith("@@"_L1))
return QVariant(s.mid(1));
}
@@ -584,7 +586,7 @@ bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to,
char16_t ch = decoded.at(i).unicode();
if (ch == '\\') {
- result += QLatin1Char('/');
+ result += u'/';
++i;
continue;
}
@@ -608,7 +610,7 @@ bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to,
}
if (firstDigitPos + numDigits > size) {
- result += QLatin1Char('%');
+ result += u'%';
++i;
continue;
}
@@ -616,7 +618,7 @@ bool QSettingsPrivate::iniUnescapedKey(const QByteArray &key, int from, int to,
bool ok;
ch = QStringView(decoded).sliced(firstDigitPos, numDigits).toUShort(&ok, 16);
if (!ok) {
- result += QLatin1Char('%');
+ result += u'%';
++i;
continue;
}
@@ -634,8 +636,8 @@ void QSettingsPrivate::iniEscapedString(const QString &str, QByteArray &result)
{
bool needsQuotes = false;
bool escapeNextIfDigit = false;
- bool useCodec = !str.startsWith(QLatin1String("@ByteArray("))
- && !str.startsWith(QLatin1String("@Variant("));
+ bool useCodec = !str.startsWith("@ByteArray("_L1)
+ && !str.startsWith("@Variant("_L1);
int i;
int startPos = result.size();
@@ -715,7 +717,7 @@ inline static void iniChopTrailingSpaces(QString &str, int limit)
{
int n = str.size() - 1;
QChar ch;
- while (n >= limit && ((ch = str.at(n)) == QLatin1Char(' ') || ch == QLatin1Char('\t')))
+ while (n >= limit && ((ch = str.at(n)) == u' ' || ch == u'\t'))
str.truncate(n--);
}
@@ -899,18 +901,18 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx)
{
int l = s.length();
Q_ASSERT(l > 0);
- Q_ASSERT(s.at(idx) == QLatin1Char('('));
- Q_ASSERT(s.at(l - 1) == QLatin1Char(')'));
+ Q_ASSERT(s.at(idx) == u'(');
+ Q_ASSERT(s.at(l - 1) == u')');
QStringList result;
QString item;
for (++idx; idx < l; ++idx) {
QChar c = s.at(idx);
- if (c == QLatin1Char(')')) {
+ if (c == u')') {
Q_ASSERT(idx == l - 1);
result.append(item);
- } else if (c == QLatin1Char(' ')) {
+ } else if (c == u' ') {
result.append(item);
item.clear();
} else {
@@ -926,7 +928,7 @@ QStringList QSettingsPrivate::splitArgs(const QString &s, int idx)
void QConfFileSettingsPrivate::initFormat()
{
- extension = (format == QSettings::NativeFormat) ? QLatin1String(".conf") : QLatin1String(".ini");
+ extension = (format == QSettings::NativeFormat) ? ".conf"_L1 : ".ini"_L1;
readFunc = nullptr;
writeFunc = nullptr;
#if defined(Q_OS_MAC)
@@ -975,9 +977,9 @@ static QString windowsConfigPath(const KNOWNFOLDERID &type)
if (result.isEmpty()) {
if (type == FOLDERID_ProgramData) {
- result = QLatin1String("C:\\temp\\qt-common");
+ result = "C:\\temp\\qt-common"_L1;
} else if (type == FOLDERID_RoamingAppData) {
- result = QLatin1String("C:\\temp\\qt-user");
+ result = "C:\\temp\\qt-user"_L1;
}
}
@@ -993,13 +995,13 @@ static inline int pathHashKey(QSettings::Format format, QSettings::Scope scope)
#ifndef Q_OS_WIN
static QString make_user_path()
{
- static constexpr QChar sep = QLatin1Char('/');
+ static constexpr QChar sep = u'/';
#ifndef QSETTINGS_USE_QSTANDARDPATHS
// Non XDG platforms (OS X, iOS, Android...) have used this code path erroneously
// for some time now. Moving away from that would require migrating existing settings.
QByteArray env = qgetenv("XDG_CONFIG_HOME");
if (env.isEmpty()) {
- return QDir::homePath() + QLatin1String("/.config/");
+ return QDir::homePath() + "/.config/"_L1;
} else if (env.startsWith('/')) {
return QFile::decodeName(env) + sep;
} else {
@@ -1025,7 +1027,7 @@ static std::unique_lock<QBasicMutex> initDefaultPaths(std::unique_lock<QBasicMut
avoid a dead-lock, we can't hold the global mutex while
calling it.
*/
- QString systemPath = QLibraryInfo::path(QLibraryInfo::SettingsPath) + QLatin1Char('/');
+ QString systemPath = QLibraryInfo::path(QLibraryInfo::SettingsPath) + u'/';
locker.lock();
if (pathHash->isEmpty()) {
@@ -1095,7 +1097,7 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
QString org = organization;
if (org.isEmpty()) {
setStatus(QSettings::AccessError);
- org = QLatin1String("Unknown Organization");
+ org = "Unknown Organization"_L1;
}
QString appFile = org + QDir::separator() + application + extension;
@@ -1123,12 +1125,12 @@ QConfFileSettingsPrivate::QConfFileSettingsPrivate(QSettings::Format format,
if (!application.isEmpty()) {
paths.reserve(dirs.size() * 2);
for (const auto &dir : qAsConst(dirs))
- paths.append(dir + QLatin1Char('/') + appFile);
+ paths.append(dir + u'/' + appFile);
} else {
paths.reserve(dirs.size());
}
for (const auto &dir : qAsConst(dirs))
- paths.append(dir + QLatin1Char('/') + orgFile);
+ paths.append(dir + u'/' + orgFile);
// Note: No check for existence of files is done intentionally.
for (const auto &path : qAsConst(paths))
@@ -1198,7 +1200,7 @@ void QConfFileSettingsPrivate::remove(const QString &key)
QConfFile *confFile = confFiles.at(0);
QSettingsKey theKey(key, caseSensitivity);
- QSettingsKey prefix(key + QLatin1Char('/'), caseSensitivity);
+ QSettingsKey prefix(key + u'/', caseSensitivity);
const auto locker = qt_scoped_lock(confFile->mutex);
ensureSectionParsed(confFile, theKey);
@@ -1377,7 +1379,7 @@ void QConfFileSettingsPrivate::syncConfFile(QConfFile *confFile)
We only need to lock if we are actually writing as only concurrent writes are a problem.
Concurrent read and write are not a problem because the writing operation is atomic.
*/
- QLockFile lockFile(confFile->name + QLatin1String(".lock"));
+ QLockFile lockFile(confFile->name + ".lock"_L1);
if (!readOnly && !lockFile.lock() && atomicSyncOnly) {
setStatus(QSettings::AccessError);
return;
@@ -1661,7 +1663,7 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data,
currentSection.clear();
iniUnescapedKey(iniSection, 0, iniSection.size(), currentSection);
}
- currentSection += QLatin1Char('/');
+ currentSection += u'/';
}
currentSectionStart = dataPos;
}
@@ -1784,7 +1786,7 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti
QSettingsIniKey key(j.key().originalCaseKey(), j.key().originalKeyPosition());
int slashPos;
- if ((slashPos = key.indexOf(QLatin1Char('/'))) != -1) {
+ if ((slashPos = key.indexOf(u'/')) != -1) {
section = key.left(slashPos);
key.remove(0, slashPos + 1);
}
@@ -1877,7 +1879,7 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
UnparsedSettingsMap::iterator i;
- int indexOfSlash = key.indexOf(QLatin1Char('/'));
+ int indexOfSlash = key.indexOf(u'/');
if (indexOfSlash != -1) {
i = confFile->unparsedIniSections.upperBound(key);
if (i == confFile->unparsedIniSections.begin())
@@ -2982,7 +2984,7 @@ int QSettings::beginReadArray(QAnyStringView prefix)
{
Q_D(QSettings);
d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), false));
- return value(QLatin1String("size")).toInt();
+ return value("size"_L1).toInt();
}
/*!
@@ -3023,9 +3025,9 @@ void QSettings::beginWriteArray(QAnyStringView prefix, int size)
d->beginGroupOrArray(QSettingsGroup(d->normalizedKey(prefix), size < 0));
if (size < 0)
- remove(QLatin1String("size"));
+ remove("size"_L1);
else
- setValue(QLatin1String("size"), size);
+ setValue("size"_L1, size);
}
/*!
@@ -3049,7 +3051,7 @@ void QSettings::endArray()
d->groupPrefix.truncate(d->groupPrefix.size() - (len + 1));
if (group.arraySizeGuess() != -1)
- setValue(group.name() + QLatin1String("/size"), group.arraySizeGuess());
+ setValue(group.name() + "/size"_L1, group.arraySizeGuess());
if (!group.isArray())
qWarning("QSettings::endArray: Expected endGroup() instead");
@@ -3510,7 +3512,7 @@ QSettings::Format QSettings::registerFormat(const QString &extension, ReadFunc r
return QSettings::InvalidFormat;
QConfFileCustomFormat info;
- info.extension = QLatin1Char('.') + extension;
+ info.extension = u'.' + extension;
info.readFunc = readFunc;
info.writeFunc = writeFunc;
info.caseSensitivity = caseSensitivity;
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index 59f0015b63..fa4d95b1fe 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static const CFStringRef hostNames[2] = { kCFPreferencesCurrentHost, kCFPreferencesAnyHost };
static const int numHostNames = 2;
@@ -291,18 +293,16 @@ static QString comify(const QString &organization)
{
for (int i = organization.size() - 1; i >= 0; --i) {
QChar ch = organization.at(i);
- if (ch == QLatin1Char('.') || ch == QChar(0x3002) || ch == QChar(0xff0e)
+ if (ch == u'.' || ch == QChar(0x3002) || ch == QChar(0xff0e)
|| ch == QChar(0xff61)) {
QString suffix = organization.mid(i + 1).toLower();
- if (suffix.size() == 2 || suffix == QLatin1String("com")
- || suffix == QLatin1String("org") || suffix == QLatin1String("net")
- || suffix == QLatin1String("edu") || suffix == QLatin1String("gov")
- || suffix == QLatin1String("mil") || suffix == QLatin1String("biz")
- || suffix == QLatin1String("info") || suffix == QLatin1String("name")
- || suffix == QLatin1String("pro") || suffix == QLatin1String("aero")
- || suffix == QLatin1String("coop") || suffix == QLatin1String("museum")) {
+ if (suffix.size() == 2 || suffix == "com"_L1 || suffix == "org"_L1
+ || suffix == "net"_L1 || suffix == "edu"_L1 || suffix == "gov"_L1
+ || suffix == "mil"_L1 || suffix == "biz"_L1 || suffix == "info"_L1
+ || suffix == "name"_L1 || suffix == "pro"_L1 || suffix == "aero"_L1
+ || suffix == "coop"_L1 || suffix == "museum"_L1) {
QString result = organization;
- result.replace(QLatin1Char('/'), QLatin1Char(' '));
+ result.replace(u'/', u' ');
return result;
}
break;
@@ -321,13 +321,13 @@ static QString comify(const QString &organization)
} else if (uc >= 'A' && uc <= 'Z') {
domain += ch.toLower();
} else {
- domain += QLatin1Char(' ');
+ domain += u' ';
}
}
domain = domain.simplified();
- domain.replace(QLatin1Char(' '), QLatin1Char('-'));
+ domain.replace(u' ', u'-');
if (!domain.isEmpty())
- domain.append(QLatin1String(".com"));
+ domain.append(".com"_L1);
return domain;
}
@@ -380,35 +380,34 @@ QMacSettingsPrivate::QMacSettingsPrivate(QSettings::Scope scope, const QString &
if (main_bundle_identifier != NULL) {
QString bundle_identifier(qtKey(main_bundle_identifier));
// CFBundleGetIdentifier returns identifier separated by slashes rather than periods.
- QStringList bundle_identifier_components = bundle_identifier.split(QLatin1Char('/'));
+ QStringList bundle_identifier_components = bundle_identifier.split(u'/');
// pre-reverse them so that when they get reversed again below, they are in the com.company.product format.
QStringList bundle_identifier_components_reversed;
for (int i=0; i<bundle_identifier_components.size(); ++i) {
const QString &bundle_identifier_component = bundle_identifier_components.at(i);
bundle_identifier_components_reversed.push_front(bundle_identifier_component);
}
- domainName = bundle_identifier_components_reversed.join(QLatin1Char('.'));
+ domainName = bundle_identifier_components_reversed.join(u'.');
}
}
}
// if no bundle identifier yet. use a hard coded string.
- if (domainName.isEmpty()) {
- domainName = QLatin1String("unknown-organization.trolltech.com");
- }
+ if (domainName.isEmpty())
+ domainName = "unknown-organization.trolltech.com"_L1;
- while ((nextDot = domainName.indexOf(QLatin1Char('.'), curPos)) != -1) {
+ while ((nextDot = domainName.indexOf(u'.', curPos)) != -1) {
javaPackageName.prepend(QStringView{domainName}.mid(curPos, nextDot - curPos));
- javaPackageName.prepend(QLatin1Char('.'));
+ javaPackageName.prepend(u'.');
curPos = nextDot + 1;
}
javaPackageName.prepend(QStringView{domainName}.mid(curPos));
javaPackageName = std::move(javaPackageName).toLower();
if (curPos == 0)
- javaPackageName.prepend(QLatin1String("com."));
+ javaPackageName.prepend("com."_L1);
suiteId = javaPackageName;
if (!application.isEmpty()) {
- javaPackageName += QLatin1Char('.') + application;
+ javaPackageName += u'.' + application;
applicationId = javaPackageName;
}
@@ -436,13 +435,13 @@ QMacSettingsPrivate::~QMacSettingsPrivate()
void QMacSettingsPrivate::remove(const QString &key)
{
- QStringList keys = children(key + QLatin1Char('/'), AllKeys);
+ QStringList keys = children(key + u'/', AllKeys);
// If i == -1, then delete "key" itself.
for (int i = -1; i < keys.size(); ++i) {
QString subKey = key;
if (i >= 0) {
- subKey += QLatin1Char('/');
+ subKey += u'/';
subKey += keys.at(i);
}
CFPreferencesSetValue(macKey(subKey), 0, domains[0].applicationOrSuiteId,
@@ -534,7 +533,7 @@ void QMacSettingsPrivate::flush()
bool QMacSettingsPrivate::isWritable() const
{
QMacSettingsPrivate *that = const_cast<QMacSettingsPrivate *>(this);
- QString impossibleKey(QLatin1String("qt_internal/"));
+ QString impossibleKey("qt_internal/"_L1);
QSettings::Status oldStatus = that->status;
that->status = QSettings::NoError;
@@ -554,9 +553,9 @@ QString QMacSettingsPrivate::fileName() const
QString result;
if (scope == QSettings::UserScope)
result = QDir::homePath();
- result += QLatin1String("/Library/Preferences/");
+ result += "/Library/Preferences/"_L1;
result += QString::fromCFString(domains[0].applicationOrSuiteId);
- result += QLatin1String(".plist");
+ result += ".plist"_L1;
return result;
}
@@ -566,7 +565,7 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format,
const QString &application)
{
#ifndef QT_BOOTSTRAPPED
- if (organization == QLatin1String("Qt"))
+ if (organization == "Qt"_L1)
{
QString organizationDomain = QCoreApplication::organizationDomain();
QString applicationName = QCoreApplication::applicationName();
diff --git a/src/corelib/io/qsettings_wasm.cpp b/src/corelib/io/qsettings_wasm.cpp
index 9e016aa4f4..d264515a7c 100644
--- a/src/corelib/io/qsettings_wasm.cpp
+++ b/src/corelib/io/qsettings_wasm.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static bool isReadReady = false;
class QWasmSettingsPrivate : public QConfFileSettingsPrivate
@@ -127,7 +129,7 @@ QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format,
const QString &application)
{
Q_UNUSED(format);
- if (organization == QLatin1String("Qt"))
+ if (organization == "Qt"_L1)
{
QString organizationDomain = QCoreApplication::organizationDomain();
QString applicationName = QCoreApplication::applicationName();
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 5146009c71..9059f2af01 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/* Keys are stored in QStrings. If the variable name starts with 'u', this is a "user"
key, ie. "foo/bar/alpha/beta". If the variable name starts with 'r', this is a "registry"
key, ie. "\foo\bar\alpha\beta". */
@@ -76,7 +78,7 @@ static const REGSAM registryPermissions = KEY_READ | KEY_WRITE;
static QString keyPath(const QString &rKey)
{
- int idx = rKey.lastIndexOf(QLatin1Char('\\'));
+ int idx = rKey.lastIndexOf(u'\\');
if (idx == -1)
return QString();
return rKey.left(idx + 1);
@@ -84,7 +86,7 @@ static QString keyPath(const QString &rKey)
static QString keyName(const QString &rKey)
{
- int idx = rKey.lastIndexOf(QLatin1Char('\\'));
+ int idx = rKey.lastIndexOf(u'\\');
QString res;
if (idx == -1)
@@ -92,8 +94,8 @@ static QString keyName(const QString &rKey)
else
res = rKey.mid(idx + 1);
- if (res == QLatin1String("Default") || res == QLatin1String("."))
- res = QLatin1String("");
+ if (res == "Default"_L1 || res == "."_L1)
+ res = ""_L1;
return res;
}
@@ -248,7 +250,7 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS
continue;
}
if (item.isEmpty())
- item = QLatin1String(".");
+ item = "."_L1;
result.append(item);
}
return result;
@@ -267,7 +269,7 @@ static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result,
for (int i = 0; i < childKeys.size(); ++i) {
QString s = rSubKey;
if (!s.isEmpty())
- s += QLatin1Char('\\');
+ s += u'\\';
s += childKeys.at(i);
result->insert(s, QString());
}
@@ -275,7 +277,7 @@ static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result,
for (int i = 0; i < childGroups.size(); ++i) {
QString s = rSubKey;
if (!s.isEmpty())
- s += QLatin1Char('\\');
+ s += u'\\';
s += childGroups.at(i);
allKeys(parentHandle, s, result, access);
}
@@ -411,9 +413,9 @@ QWinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString &
deleteWriteHandleOnExit = false;
if (!organization.isEmpty()) {
- QString prefix = QLatin1String("Software\\") + organization;
- QString orgPrefix = prefix + QLatin1String("\\OrganizationDefaults");
- QString appPrefix = prefix + QLatin1Char('\\') + application;
+ QString prefix = "Software\\"_L1 + organization;
+ QString orgPrefix = prefix + "\\OrganizationDefaults"_L1;
+ QString appPrefix = prefix + u'\\' + application;
if (scope == QSettings::UserScope) {
if (!application.isEmpty())
@@ -438,34 +440,34 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath, REGSAM access)
{
deleteWriteHandleOnExit = false;
- if (rPath.startsWith(QLatin1Char('\\')))
+ if (rPath.startsWith(u'\\'))
rPath.remove(0, 1);
int keyLength;
HKEY keyName;
- if (rPath.startsWith(QLatin1String("HKEY_CURRENT_USER"))) {
+ if (rPath.startsWith("HKEY_CURRENT_USER"_L1)) {
keyLength = 17;
keyName = HKEY_CURRENT_USER;
- } else if (rPath.startsWith(QLatin1String("HKCU"))) {
+ } else if (rPath.startsWith("HKCU"_L1)) {
keyLength = 4;
keyName = HKEY_CURRENT_USER;
- } else if (rPath.startsWith(QLatin1String("HKEY_LOCAL_MACHINE"))) {
+ } else if (rPath.startsWith("HKEY_LOCAL_MACHINE"_L1)) {
keyLength = 18;
keyName = HKEY_LOCAL_MACHINE;
- } else if (rPath.startsWith(QLatin1String("HKLM"))) {
+ } else if (rPath.startsWith("HKLM"_L1)) {
keyLength = 4;
keyName = HKEY_LOCAL_MACHINE;
- } else if (rPath.startsWith(QLatin1String("HKEY_CLASSES_ROOT"))) {
+ } else if (rPath.startsWith("HKEY_CLASSES_ROOT"_L1)) {
keyLength = 17;
keyName = HKEY_CLASSES_ROOT;
- } else if (rPath.startsWith(QLatin1String("HKCR"))) {
+ } else if (rPath.startsWith("HKCR"_L1)) {
keyLength = 4;
keyName = HKEY_CLASSES_ROOT;
- } else if (rPath.startsWith(QLatin1String("HKEY_USERS"))) {
+ } else if (rPath.startsWith("HKEY_USERS"_L1)) {
keyLength = 10;
keyName = HKEY_USERS;
- } else if (rPath.startsWith(QLatin1String("HKU"))) {
+ } else if (rPath.startsWith("HKU"_L1)) {
keyLength = 3;
keyName = HKEY_USERS;
} else {
@@ -474,7 +476,7 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath, REGSAM access)
if (rPath.length() == keyLength)
regList.append(RegistryKey(keyName, QString(), false, access));
- else if (rPath[keyLength] == QLatin1Char('\\'))
+ else if (rPath[keyLength] == u'\\')
regList.append(RegistryKey(keyName, rPath.mid(keyLength+1), false, access));
}
@@ -773,7 +775,7 @@ QStringList QWinSettingsPrivate::children(const QString &uKey, ChildSpec spec) c
if (spec == AllKeys) {
NameSet keys;
- allKeys(handle, QLatin1String(""), &keys, access);
+ allKeys(handle, ""_L1, &keys, access);
mergeKeySets(&result, keys);
} else { // ChildGroups or ChildKeys
QStringList names = childKeysOrGroups(handle, spec);
@@ -813,9 +815,9 @@ QString QWinSettingsPrivate::fileName() const
const RegistryKey &key = regList.at(0);
QString result;
if (key.parentHandle() == HKEY_CURRENT_USER)
- result = QLatin1String("\\HKEY_CURRENT_USER\\");
+ result = "\\HKEY_CURRENT_USER\\"_L1;
else
- result = QLatin1String("\\HKEY_LOCAL_MACHINE\\");
+ result = "\\HKEY_LOCAL_MACHINE\\"_L1;
return result + regList.at(0).key();
}
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 65cbfe70e7..2f73cf27bb 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -60,6 +60,7 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
/*!
\class QStandardPaths
\inmodule QtCore
@@ -412,7 +413,7 @@ QString QStandardPaths::locate(StandardLocation type, const QString &fileName, L
{
const QStringList &dirs = standardLocations(type);
for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) {
- const QString path = *dir + QLatin1Char('/') + fileName;
+ const QString path = *dir + u'/' + fileName;
if (existsAsSpecified(path, options))
return path;
}
@@ -427,7 +428,7 @@ QStringList QStandardPaths::locateAll(StandardLocation type, const QString &file
const QStringList &dirs = standardLocations(type);
QStringList result;
for (QStringList::const_iterator dir = dirs.constBegin(); dir != dirs.constEnd(); ++dir) {
- const QString path = *dir + QLatin1Char('/') + fileName;
+ const QString path = *dir + u'/' + fileName;
if (existsAsSpecified(path, options))
result.append(path);
}
@@ -438,11 +439,9 @@ QStringList QStandardPaths::locateAll(StandardLocation type, const QString &file
static QStringList executableExtensions()
{
// If %PATHEXT% does not contain .exe, it is either empty, malformed, or distorted in ways that we cannot support, anyway.
- const QStringList pathExt = QString::fromLocal8Bit(qgetenv("PATHEXT")).toLower().split(QLatin1Char(';'));
- return pathExt.contains(QLatin1String(".exe"), Qt::CaseInsensitive) ?
- pathExt :
- QStringList() << QLatin1String(".exe") << QLatin1String(".com")
- << QLatin1String(".bat") << QLatin1String(".cmd");
+ const QStringList pathExt = QString::fromLocal8Bit(qgetenv("PATHEXT")).toLower().split(u';');
+ return pathExt.contains(".exe"_L1, Qt::CaseInsensitive) ?
+ pathExt : QStringList{".exe"_L1, ".com"_L1, ".bat"_L1, ".cmd"_L1};
}
#endif
@@ -461,7 +460,7 @@ static inline QString searchExecutable(const QStringList &searchPaths,
{
const QDir currentDir = QDir::current();
for (const QString &searchPath : searchPaths) {
- const QString candidate = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName);
+ const QString candidate = currentDir.absoluteFilePath(searchPath + u'/' + executableName);
const QString absPath = checkExecutable(candidate);
if (!absPath.isEmpty())
return absPath;
@@ -480,7 +479,7 @@ static inline QString
{
const QDir currentDir = QDir::current();
for (const QString &searchPath : searchPaths) {
- const QString candidateRoot = currentDir.absoluteFilePath(searchPath + QLatin1Char('/') + executableName);
+ const QString candidateRoot = currentDir.absoluteFilePath(searchPath + u'/' + executableName);
for (const QString &suffix : suffixes) {
const QString absPath = checkExecutable(candidateRoot + suffix);
if (!absPath.isEmpty())
@@ -530,7 +529,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
searchPaths.reserve(rawPaths.size());
for (const QString &rawPath : rawPaths) {
QString cleanPath = QDir::cleanPath(rawPath);
- if (cleanPath.size() > 1 && cleanPath.endsWith(QLatin1Char('/')))
+ if (cleanPath.size() > 1 && cleanPath.endsWith(u'/'))
cleanPath.truncate(cleanPath.size() - 1);
searchPaths.push_back(cleanPath);
}
@@ -540,9 +539,9 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
// On Windows, if the name does not have a suffix or a suffix not
// in PATHEXT ("xx.foo"), append suffixes from PATHEXT.
static const QStringList executable_extensions = executableExtensions();
- if (executableName.contains(QLatin1Char('.'))) {
+ if (executableName.contains(u'.')) {
const QString suffix = QFileInfo(executableName).suffix();
- if (suffix.isEmpty() || !executable_extensions.contains(QLatin1Char('.') + suffix, Qt::CaseInsensitive))
+ if (suffix.isEmpty() || !executable_extensions.contains(u'.' + suffix, Qt::CaseInsensitive))
return searchExecutableAppendSuffix(searchPaths, executableName, executable_extensions);
} else {
return searchExecutableAppendSuffix(searchPaths, executableName, executable_extensions);
diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp
index 28993a16dc..9deab7754b 100644
--- a/src/corelib/io/qstandardpaths_android.cpp
+++ b/src/corelib/io/qstandardpaths_android.cpp
@@ -49,14 +49,14 @@
QT_BEGIN_NAMESPACE
using namespace QNativeInterface;
+using namespace Qt::StringLiterals;
typedef QMap<QString, QString> AndroidDirCache;
Q_GLOBAL_STATIC(AndroidDirCache, androidDirCache)
static QString testDir()
{
- return QStandardPaths::isTestModeEnabled() ? QLatin1String("/qttest")
- : QLatin1String("");
+ return QStandardPaths::isTestModeEnabled() ? "/qttest"_L1 : ""_L1;
}
static inline QString getAbsolutePath(const QJniObject &file)
@@ -75,7 +75,7 @@ static inline QString getAbsolutePath(const QJniObject &file)
*/
static QString getExternalFilesDir(const char *directoryField = nullptr)
{
- QString &path = (*androidDirCache)[QLatin1String("APPNAME_%1").arg(QLatin1String(directoryField))];
+ QString &path = (*androidDirCache)["APPNAME_%1"_L1.arg(QLatin1String(directoryField))];
if (!path.isEmpty())
return path;
@@ -83,7 +83,7 @@ static QString getExternalFilesDir(const char *directoryField = nullptr)
if (!appCtx.isValid())
return QString();
- QJniObject dirField = QJniObject::fromString(QLatin1String(""));
+ QJniObject dirField = QJniObject::fromString(""_L1);
if (directoryField && strlen(directoryField) > 0) {
dirField = QJniObject::getStaticObjectField("android/os/Environment",
directoryField,
@@ -184,7 +184,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
case QStandardPaths::GenericConfigLocation:
case QStandardPaths::ConfigLocation:
case QStandardPaths::AppConfigLocation:
- return getFilesDir() + testDir() + QLatin1String("/settings");
+ return getFilesDir() + testDir() + "/settings"_L1;
case QStandardPaths::GenericDataLocation:
return getExternalFilesDir() + testDir();
case QStandardPaths::AppDataLocation:
@@ -260,7 +260,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
// Don't cache the fallback, as we might just have been called before
// QT_ANDROID_FONT_LOCATION has been set.
- return QStringList(QLatin1String("/system/fonts"));
+ return QStringList("/system/fonts"_L1);
}
return QStringList(writableLocation(type));
diff --git a/src/corelib/io/qstandardpaths_haiku.cpp b/src/corelib/io/qstandardpaths_haiku.cpp
index cac7767e6b..0709e2a57f 100644
--- a/src/corelib/io/qstandardpaths_haiku.cpp
+++ b/src/corelib/io/qstandardpaths_haiku.cpp
@@ -61,10 +61,10 @@ void appendOrganizationAndApp(QString &path)
#ifndef QT_BOOTSTRAPPED
const QString org = QCoreApplication::organizationName();
if (!org.isEmpty())
- path += QLatin1Char('/') + org;
+ path += u'/' + org;
const QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty())
- path += QLatin1Char('/') + appName;
+ path += u'/' + appName;
#else
Q_UNUSED(path);
#endif
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index 8c102d6928..f0963daf04 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static QString pathForDirectory(NSSearchPathDirectory directory,
NSSearchPathDomainMask mask)
{
@@ -98,10 +100,10 @@ static void appendOrganizationAndApp(QString &path)
#ifndef QT_BOOTSTRAPPED
const QString org = QCoreApplication::organizationName();
if (!org.isEmpty())
- path += QLatin1Char('/') + org;
+ path += u'/' + org;
const QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty())
- path += QLatin1Char('/') + appName;
+ path += u'/' + appName;
#else
Q_UNUSED(path);
#endif
@@ -123,36 +125,36 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type,
#if defined(QT_PLATFORM_UIKIT)
// These locations point to non-existing write-protected paths. Use sensible fallbacks.
case QStandardPaths::MusicLocation:
- path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Music");
+ path = pathForDirectory(NSDocumentDirectory, mask) + "/Music"_L1;
break;
case QStandardPaths::MoviesLocation:
- path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Movies");
+ path = pathForDirectory(NSDocumentDirectory, mask) + "/Movies"_L1;
break;
case QStandardPaths::PicturesLocation:
- path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Pictures");
+ path = pathForDirectory(NSDocumentDirectory, mask) + "/Pictures"_L1;
break;
case QStandardPaths::DownloadLocation:
- path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Downloads");
+ path = pathForDirectory(NSDocumentDirectory, mask) + "/Downloads"_L1;
break;
case QStandardPaths::DesktopLocation:
- path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Desktop");
+ path = pathForDirectory(NSDocumentDirectory, mask) + "/Desktop"_L1;
break;
case QStandardPaths::ApplicationsLocation:
break;
case QStandardPaths::PublicShareLocation:
- path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Public");
+ path = pathForDirectory(NSDocumentDirectory, mask) + "/Public"_L1;
break;
case QStandardPaths::TemplatesLocation:
- path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Templates");
+ path = pathForDirectory(NSDocumentDirectory, mask) + "/Templates"_L1;
break;
#endif
case QStandardPaths::FontsLocation:
- path = pathForDirectory(NSLibraryDirectory, mask) + QLatin1String("/Fonts");
+ path = pathForDirectory(NSLibraryDirectory, mask) + "/Fonts"_L1;
break;
case QStandardPaths::ConfigLocation:
case QStandardPaths::GenericConfigLocation:
case QStandardPaths::AppConfigLocation:
- path = pathForDirectory(NSLibraryDirectory, mask) + QLatin1String("/Preferences");
+ path = pathForDirectory(NSLibraryDirectory, mask) + "/Preferences"_L1;
break;
default:
path = pathForDirectory(dir, mask);
@@ -179,7 +181,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
{
QString location = baseWritableLocation(type, NSUserDomainMask, true);
if (isTestModeEnabled())
- location = location.replace(QDir::homePath(), QDir::homePath() + QLatin1String("/.qttest"));
+ location = location.replace(QDir::homePath(), QDir::homePath() + "/.qttest"_L1);
return location;
}
@@ -190,7 +192,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
#if defined(QT_PLATFORM_UIKIT)
if (type == PicturesLocation)
- dirs << writableLocation(PicturesLocation) << QLatin1String("assets-library://");
+ dirs << writableLocation(PicturesLocation) << "assets-library://"_L1;
#endif
if (type == GenericDataLocation || type == FontsLocation || type == ApplicationsLocation
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index 6acec9c034..2750feda5d 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -58,15 +58,17 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static void appendOrganizationAndApp(QString &path)
{
#ifndef QT_BOOTSTRAPPED
const QString org = QCoreApplication::organizationName();
if (!org.isEmpty())
- path += QLatin1Char('/') + org;
+ path += u'/' + org;
const QString appName = QCoreApplication::applicationName();
if (!appName.isEmpty())
- path += QLatin1Char('/') + appName;
+ path += u'/' + appName;
#else
Q_UNUSED(path);
#endif
@@ -77,23 +79,23 @@ static QLatin1String xdg_key_name(QStandardPaths::StandardLocation type)
{
switch (type) {
case QStandardPaths::DesktopLocation:
- return QLatin1String("DESKTOP");
+ return "DESKTOP"_L1;
case QStandardPaths::DocumentsLocation:
- return QLatin1String("DOCUMENTS");
+ return "DOCUMENTS"_L1;
case QStandardPaths::PicturesLocation:
- return QLatin1String("PICTURES");
+ return "PICTURES"_L1;
case QStandardPaths::MusicLocation:
- return QLatin1String("MUSIC");
+ return "MUSIC"_L1;
case QStandardPaths::MoviesLocation:
- return QLatin1String("VIDEOS");
+ return "VIDEOS"_L1;
case QStandardPaths::DownloadLocation:
- return QLatin1String("DOWNLOAD");
+ return "DOWNLOAD"_L1;
case QStandardPaths::PublicShareLocation:
- return QLatin1String("PUBLICSHARE");
+ return "PUBLICSHARE"_L1;
case QStandardPaths::TemplatesLocation:
- return QLatin1String("TEMPLATES");
+ return "TEMPLATES"_L1;
default:
- return QLatin1String();
+ return {};
}
}
#endif
@@ -217,9 +219,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
// http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
QString xdgCacheHome = QFile::decodeName(qgetenv("XDG_CACHE_HOME"));
if (isTestModeEnabled())
- xdgCacheHome = QDir::homePath() + QLatin1String("/.qttest/cache");
+ xdgCacheHome = QDir::homePath() + "/.qttest/cache"_L1;
if (xdgCacheHome.isEmpty())
- xdgCacheHome = QDir::homePath() + QLatin1String("/.cache");
+ xdgCacheHome = QDir::homePath() + "/.cache"_L1;
if (type == QStandardPaths::CacheLocation)
appendOrganizationAndApp(xdgCacheHome);
return xdgCacheHome;
@@ -230,9 +232,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
{
QString xdgDataHome = QFile::decodeName(qgetenv("XDG_DATA_HOME"));
if (isTestModeEnabled())
- xdgDataHome = QDir::homePath() + QLatin1String("/.qttest/share");
+ xdgDataHome = QDir::homePath() + "/.qttest/share"_L1;
if (xdgDataHome.isEmpty())
- xdgDataHome = QDir::homePath() + QLatin1String("/.local/share");
+ xdgDataHome = QDir::homePath() + "/.local/share"_L1;
if (type == AppDataLocation || type == AppLocalDataLocation)
appendOrganizationAndApp(xdgDataHome);
return xdgDataHome;
@@ -244,9 +246,9 @@ QString QStandardPaths::writableLocation(StandardLocation type)
// http://standards.freedesktop.org/basedir-spec/latest/
QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
if (isTestModeEnabled())
- xdgConfigHome = QDir::homePath() + QLatin1String("/.qttest/config");
+ xdgConfigHome = QDir::homePath() + "/.qttest/config"_L1;
if (xdgConfigHome.isEmpty())
- xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
+ xdgConfigHome = QDir::homePath() + "/.config"_L1;
if (type == AppConfigLocation)
appendOrganizationAndApp(xdgConfigHome);
return xdgConfigHome;
@@ -259,7 +261,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
// environment variable not set or is set to something unsuitable
const uint myUid = uint(geteuid());
const QString userName = QFileSystemEngine::resolveUserName(myUid);
- xdgRuntimeDir = QDir::tempPath() + QLatin1String("/runtime-") + userName;
+ xdgRuntimeDir = QDir::tempPath() + "/runtime-"_L1 + userName;
if (!fromEnv) {
#ifndef Q_OS_WASM
@@ -281,13 +283,13 @@ QString QStandardPaths::writableLocation(StandardLocation type)
// http://www.freedesktop.org/wiki/Software/xdg-user-dirs
QString xdgConfigHome = QFile::decodeName(qgetenv("XDG_CONFIG_HOME"));
if (xdgConfigHome.isEmpty())
- xdgConfigHome = QDir::homePath() + QLatin1String("/.config");
- QFile file(xdgConfigHome + QLatin1String("/user-dirs.dirs"));
+ xdgConfigHome = QDir::homePath() + "/.config"_L1;
+ QFile file(xdgConfigHome + "/user-dirs.dirs"_L1);
const QLatin1String key = xdg_key_name(type);
if (!key.isEmpty() && !isTestModeEnabled() && file.open(QIODevice::ReadOnly)) {
QTextStream stream(&file);
// Only look for lines like: XDG_DESKTOP_DIR="$HOME/Desktop"
- QRegularExpression exp(QLatin1String("^XDG_(.*)_DIR=(.*)$"));
+ QRegularExpression exp("^XDG_(.*)_DIR=(.*)$"_L1);
QString result;
while (!stream.atEnd()) {
const QString &line = stream.readLine();
@@ -295,15 +297,15 @@ QString QStandardPaths::writableLocation(StandardLocation type)
if (match.hasMatch() && match.capturedView(1) == key) {
QStringView value = match.capturedView(2);
if (value.length() > 2
- && value.startsWith(QLatin1Char('\"'))
- && value.endsWith(QLatin1Char('\"')))
+ && value.startsWith(u'\"')
+ && value.endsWith(u'\"'))
value = value.mid(1, value.length() - 2);
// value can start with $HOME
- if (value.startsWith(QLatin1String("$HOME")))
+ if (value.startsWith("$HOME"_L1))
result = QDir::homePath() + value.mid(5);
else
result = value.toString();
- if (result.length() > 1 && result.endsWith(QLatin1Char('/')))
+ if (result.length() > 1 && result.endsWith(u'/'))
result.chop(1);
}
}
@@ -315,39 +317,39 @@ QString QStandardPaths::writableLocation(StandardLocation type)
QString path;
switch (type) {
case DesktopLocation:
- path = QDir::homePath() + QLatin1String("/Desktop");
+ path = QDir::homePath() + "/Desktop"_L1;
break;
case DocumentsLocation:
- path = QDir::homePath() + QLatin1String("/Documents");
+ path = QDir::homePath() + "/Documents"_L1;
break;
case PicturesLocation:
- path = QDir::homePath() + QLatin1String("/Pictures");
+ path = QDir::homePath() + "/Pictures"_L1;
break;
case FontsLocation:
- path = writableLocation(GenericDataLocation) + QLatin1String("/fonts");
+ path = writableLocation(GenericDataLocation) + "/fonts"_L1;
break;
case MusicLocation:
- path = QDir::homePath() + QLatin1String("/Music");
+ path = QDir::homePath() + "/Music"_L1;
break;
case MoviesLocation:
- path = QDir::homePath() + QLatin1String("/Videos");
+ path = QDir::homePath() + "/Videos"_L1;
break;
case DownloadLocation:
- path = QDir::homePath() + QLatin1String("/Downloads");
+ path = QDir::homePath() + "/Downloads"_L1;
break;
case ApplicationsLocation:
- path = writableLocation(GenericDataLocation) + QLatin1String("/applications");
+ path = writableLocation(GenericDataLocation) + "/applications"_L1;
break;
case PublicShareLocation:
- path = QDir::homePath() + QLatin1String("/Public");
+ path = QDir::homePath() + "/Public"_L1;
break;
case TemplatesLocation:
- path = QDir::homePath() + QLatin1String("/Templates");
+ path = QDir::homePath() + "/Templates"_L1;
break;
default:
@@ -368,7 +370,7 @@ static QStringList xdgDataDirs()
} else {
// Normalize paths, skip relative paths
for (const auto dir : qTokenize(xdgDataDirsEnv, u':')) {
- if (dir.startsWith(QLatin1Char('/')))
+ if (dir.startsWith(u'/'))
dirs.push_back(QDir::cleanPath(dir.toString()));
}
@@ -391,7 +393,7 @@ static QStringList xdgConfigDirs()
if (xdgConfigDirs.isEmpty())
dirs.append(QString::fromLatin1("/etc/xdg"));
else
- dirs = xdgConfigDirs.split(QLatin1Char(':'));
+ dirs = xdgConfigDirs.split(u':');
return dirs;
}
@@ -414,7 +416,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
case ApplicationsLocation:
dirs = xdgDataDirs();
for (int i = 0; i < dirs.count(); ++i)
- dirs[i].append(QLatin1String("/applications"));
+ dirs[i].append("/applications"_L1);
break;
case AppDataLocation:
case AppLocalDataLocation:
@@ -423,10 +425,10 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
appendOrganizationAndApp(dirs[i]);
break;
case FontsLocation:
- dirs += QDir::homePath() + QLatin1String("/.fonts");
+ dirs += QDir::homePath() + "/.fonts"_L1;
dirs += xdgDataDirs();
for (int i = 1; i < dirs.count(); ++i)
- dirs[i].append(QLatin1String("/fonts"));
+ dirs[i].append("/fonts"_L1);
break;
default:
break;
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index d191ed33b4..1c404a06b3 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -55,6 +55,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static QString convertCharArray(const wchar_t *path)
{
return QDir::fromNativeSeparators(QString::fromWCharArray(path));
@@ -77,10 +79,10 @@ static void appendOrganizationAndApp(QString &path) // Courtesy qstandardpaths_u
#ifndef QT_BOOTSTRAPPED
const QString &org = QCoreApplication::organizationName();
if (!org.isEmpty())
- path += QLatin1Char('/') + org;
+ path += u'/' + org;
const QString &appName = QCoreApplication::applicationName();
if (!appName.isEmpty())
- path += QLatin1Char('/') + appName;
+ path += u'/' + appName;
#else // !QT_BOOTSTRAPPED
Q_UNUSED(path);
#endif
@@ -89,7 +91,7 @@ static void appendOrganizationAndApp(QString &path) // Courtesy qstandardpaths_u
static inline void appendTestMode(QString &path)
{
if (QStandardPaths::isTestModeEnabled())
- path += QLatin1String("/qttest");
+ path += "/qttest"_L1;
}
static bool isProcessLowIntegrity()
@@ -197,7 +199,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
if (!result.isEmpty()) {
appendTestMode(result);
appendOrganizationAndApp(result);
- result += QLatin1String("/cache");
+ result += "/cache"_L1;
}
break;
@@ -205,7 +207,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
result = sHGetKnownFolderPath(writableSpecialFolderId(GenericDataLocation));
if (!result.isEmpty()) {
appendTestMode(result);
- result += QLatin1String("/cache");
+ result += "/cache"_L1;
}
break;
@@ -256,7 +258,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
QString applicationDirPath = qApp ? QCoreApplication::applicationDirPath()
: QFileInfo(qAppFileName()).path();
dirs.append(applicationDirPath);
- const QString dataDir = applicationDirPath + QLatin1String("/data");
+ const QString dataDir = applicationDirPath + "/data"_L1;
dirs.append(dataDir);
if (!isGenericConfigLocation(type)) {
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 2b635f63bb..380f3e3f4c 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -119,6 +119,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
class QStorageIterator
{
public:
@@ -190,7 +192,7 @@ template <typename String>
static bool isParentOf(const String &parent, const QString &dirName)
{
return dirName.startsWith(parent) &&
- (dirName.size() == parent.size() || dirName.at(parent.size()) == QLatin1Char('/') ||
+ (dirName.size() == parent.size() || dirName.at(parent.size()) == u'/' ||
parent.size() == 1);
}
@@ -214,11 +216,11 @@ static bool shouldIncludeFs(const QStorageIterator &it)
*/
QString mountDir = it.rootPath();
- if (isParentOf(QLatin1String("/dev"), mountDir)
- || isParentOf(QLatin1String("/proc"), mountDir)
- || isParentOf(QLatin1String("/sys"), mountDir)
- || isParentOf(QLatin1String("/var/run"), mountDir)
- || isParentOf(QLatin1String("/var/lock"), mountDir)) {
+ if (isParentOf("/dev"_L1, mountDir)
+ || isParentOf("/proc"_L1, mountDir)
+ || isParentOf("/sys"_L1, mountDir)
+ || isParentOf("/var/run"_L1, mountDir)
+ || isParentOf("/var/lock"_L1, mountDir)) {
return false;
}
@@ -767,8 +769,7 @@ static QString decodeFsEncString(const QString &str)
int i = 0;
while (i < str.size()) {
if (i <= str.size() - 4) { // we need at least four characters \xAB
- if (str.at(i) == QLatin1Char('\\') &&
- str.at(i+1) == QLatin1Char('x')) {
+ if (QStringView{str}.sliced(i).startsWith("\\x"_L1)) {
bool bOk;
const int code = QStringView{str}.mid(i+2, 2).toInt(&bOk, 16);
// only decode characters between 0x20 and 0x7f but not
diff --git a/src/corelib/io/qstorageinfo_win.cpp b/src/corelib/io/qstorageinfo_win.cpp
index d594551425..e9929c9921 100644
--- a/src/corelib/io/qstorageinfo_win.cpp
+++ b/src/corelib/io/qstorageinfo_win.cpp
@@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static const int defaultBufferSize = MAX_PATH + 1;
static QString canonicalPath(const QString &rootPath)
@@ -59,16 +61,16 @@ static QString canonicalPath(const QString &rootPath)
if (path.isEmpty())
return path;
- if (path.startsWith(QLatin1String("\\\\?\\")))
+ if (path.startsWith("\\\\?\\"_L1))
path.remove(0, 4);
- if (path.length() < 2 || path.at(1) != QLatin1Char(':'))
+ if (path.length() < 2 || path.at(1) != u':')
return QString();
path[0] = path[0].toUpper();
if (!(path.at(0).unicode() >= 'A' && path.at(0).unicode() <= 'Z'))
return QString();
- if (!path.endsWith(QLatin1Char('\\')))
- path.append(QLatin1Char('\\'));
+ if (!path.endsWith(u'\\'))
+ path.append(u'\\');
return path;
}
diff --git a/src/corelib/io/qtemporarydir.cpp b/src/corelib/io/qtemporarydir.cpp
index c9573182c4..d19896563d 100644
--- a/src/corelib/io/qtemporarydir.cpp
+++ b/src/corelib/io/qtemporarydir.cpp
@@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static_assert(std::is_nothrow_move_constructible_v<QTemporaryDir>);
static_assert(std::is_nothrow_move_assignable_v<QTemporaryDir>);
@@ -95,9 +97,9 @@ static QString defaultTemplateName()
baseName = QCoreApplication::applicationName();
if (baseName.isEmpty())
#endif
- baseName = QLatin1String("qt_temp");
+ baseName = "qt_temp"_L1;
- return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX");
+ return QDir::tempPath() + u'/' + baseName + "-XXXXXX"_L1;
}
void QTemporaryDirPrivate::create(const QString &templateName)
@@ -302,7 +304,7 @@ QString QTemporaryDir::filePath(const QString &fileName) const
QString ret = d_ptr->pathOrError;
if (!fileName.isEmpty()) {
- ret += QLatin1Char('/');
+ ret += u'/';
ret += fileName;
}
return ret;
@@ -347,7 +349,7 @@ bool QTemporaryDir::remove()
if (!d_ptr->success)
return false;
Q_ASSERT(!path().isEmpty());
- Q_ASSERT(path() != QLatin1String("."));
+ Q_ASSERT(path() != "."_L1);
const bool result = QDir(path()).removeRecursively();
if (!result) {
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 4b587857a8..21dd468c5f 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -59,6 +59,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if defined(Q_OS_WIN)
typedef ushort Char;
@@ -85,13 +87,13 @@ QTemporaryFileName::QTemporaryFileName(const QString &templateName)
while (phPos != 0) {
--phPos;
- if (qfilename[phPos] == QLatin1Char('X')) {
+ if (qfilename[phPos] == u'X') {
++phLength;
continue;
}
if (phLength >= 6
- || qfilename[phPos] == QLatin1Char('/')) {
+ || qfilename[phPos] == u'/') {
++phPos;
break;
}
@@ -101,7 +103,7 @@ QTemporaryFileName::QTemporaryFileName(const QString &templateName)
}
if (phLength < 6)
- qfilename.append(QLatin1String(".XXXXXX"));
+ qfilename.append(".XXXXXX"_L1);
// "Nativify" :-)
QFileSystemEntry::NativePath filename = QFileSystemEngine::absoluteName(
@@ -576,9 +578,9 @@ QString QTemporaryFilePrivate::defaultTemplateName()
baseName = QCoreApplication::applicationName();
if (baseName.isEmpty())
#endif
- baseName = QLatin1String("qt_temp");
+ baseName = "qt_temp"_L1;
- return QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String(".XXXXXX");
+ return QDir::tempPath() + u'/' + baseName + ".XXXXXX"_L1;
}
//************* QTemporaryFile
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 08385c9629..9dc84094ce 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -439,6 +439,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// in qstring.cpp:
void qt_from_latin1(char16_t *dst, const char *str, size_t size) noexcept;
@@ -833,7 +835,7 @@ static const ushort * const fragmentInUrl = userNameInUrl + 6;
static inline void parseDecodedComponent(QString &data)
{
- data.replace(QLatin1Char('%'), QLatin1String("%25"));
+ data.replace(u'%', "%25"_L1);
}
static inline QString
@@ -870,11 +872,11 @@ inline void QUrlPrivate::appendAuthority(QString &appendTo, QUrl::FormattingOpti
// add '@' only if we added anything
if (hasUserName() || (hasPassword() && (options & QUrl::RemovePassword) == 0))
- appendTo += QLatin1Char('@');
+ appendTo += u'@';
}
appendHost(appendTo, options);
if (!(options & QUrl::RemovePort) && port != -1)
- appendTo += QLatin1Char(':') + QString::number(port);
+ appendTo += u':' + QString::number(port);
}
inline void QUrlPrivate::appendUserInfo(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const
@@ -916,7 +918,7 @@ inline void QUrlPrivate::appendUserInfo(QString &appendTo, QUrl::FormattingOptio
if (options & QUrl::RemovePassword || !hasPassword()) {
return;
} else {
- appendTo += QLatin1Char(':');
+ appendTo += u':';
if (!qt_urlRecode(appendTo, password, options, passwordActions))
appendTo += password;
}
@@ -945,14 +947,14 @@ inline void QUrlPrivate::appendPath(QString &appendTo, QUrl::FormattingOptions o
QStringView thePathView(thePath);
if (options & QUrl::RemoveFilename) {
- const qsizetype slash = path.lastIndexOf(QLatin1Char('/'));
+ const qsizetype slash = path.lastIndexOf(u'/');
if (slash == -1)
return;
thePathView = QStringView{path}.left(slash + 1);
}
// check if we need to remove trailing slashes
if (options & QUrl::StripTrailingSlash) {
- while (thePathView.length() > 1 && thePathView.endsWith(QLatin1Char('/')))
+ while (thePathView.length() > 1 && thePathView.endsWith(u'/'))
thePathView.chop(1);
}
@@ -1048,7 +1050,7 @@ inline void QUrlPrivate::setAuthority(const QString &auth, qsizetype from, qsize
// we never actually _loop_
while (from != end) {
- qsizetype userInfoIndex = auth.indexOf(QLatin1Char('@'), from);
+ qsizetype userInfoIndex = auth.indexOf(u'@', from);
if (size_t(userInfoIndex) < size_t(end)) {
setUserInfo(auth, from, userInfoIndex);
if (mode == QUrl::StrictMode && !validateComponent(UserInfo, auth, from, userInfoIndex))
@@ -1056,14 +1058,14 @@ inline void QUrlPrivate::setAuthority(const QString &auth, qsizetype from, qsize
from = userInfoIndex + 1;
}
- qsizetype colonIndex = auth.lastIndexOf(QLatin1Char(':'), end - 1);
+ qsizetype colonIndex = auth.lastIndexOf(u':', end - 1);
if (colonIndex < from)
colonIndex = -1;
if (size_t(colonIndex) < size_t(end)) {
if (auth.at(from).unicode() == '[') {
// check if colonIndex isn't inside the "[...]" part
- qsizetype closingBracket = auth.indexOf(QLatin1Char(']'), from);
+ qsizetype closingBracket = auth.indexOf(u']', from);
if (size_t(closingBracket) > size_t(colonIndex))
colonIndex = -1;
}
@@ -1111,7 +1113,7 @@ inline void QUrlPrivate::setAuthority(const QString &auth, qsizetype from, qsize
inline void QUrlPrivate::setUserInfo(const QString &userInfo, qsizetype from, qsizetype end)
{
- qsizetype delimIndex = userInfo.indexOf(QLatin1Char(':'), from);
+ qsizetype delimIndex = userInfo.indexOf(u':', from);
setUserName(userInfo, from, qMin<size_t>(delimIndex, end));
if (size_t(delimIndex) >= size_t(end)) {
@@ -1248,7 +1250,7 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar
else
return decoded.isEmpty() ? begin : &origBegin[2];
}
- host += QLatin1Char(']');
+ host += u']';
return nullptr;
}
return &origBegin[2];
@@ -1290,14 +1292,14 @@ static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end
return begin + (ret - decoded.constBegin());
host.reserve(host.size() + (end - begin) + 2); // +2 for the brackets
- host += QLatin1Char('[');
+ host += u'[';
QIPAddressUtils::toString(host, address);
if (!zoneId.isEmpty()) {
host += zoneIdIdentifier;
host += zoneId;
}
- host += QLatin1Char(']');
+ host += u']';
return nullptr;
}
@@ -1504,19 +1506,19 @@ QString QUrlPrivate::toLocalFile(QUrl::FormattingOptions options) const
// magic for shared drive on windows
if (!host.isEmpty()) {
- tmp = QLatin1String("//") + host;
+ tmp = "//"_L1 + host;
#ifdef Q_OS_WIN // QTBUG-42346, WebDAV is visible as local file on Windows only.
if (scheme == webDavScheme())
tmp += webDavSslTag();
#endif
- if (!ourPath.isEmpty() && !ourPath.startsWith(QLatin1Char('/')))
- tmp += QLatin1Char('/');
+ if (!ourPath.isEmpty() && !ourPath.startsWith(u'/'))
+ tmp += u'/';
tmp += ourPath;
} else {
tmp = ourPath;
#ifdef Q_OS_WIN
// magic for drives on windows
- if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':'))
+ if (ourPath.length() > 2 && ourPath.at(0) == u'/' && ourPath.at(2) == u':')
tmp.remove(0, 1);
#endif
}
@@ -1537,7 +1539,7 @@ inline QString QUrlPrivate::mergePaths(const QString &relativePath) const
// path, then return a string consisting of "/" concatenated with
// the reference's path; otherwise,
if (!host.isEmpty() && path.isEmpty())
- return QLatin1Char('/') + relativePath;
+ return u'/' + relativePath;
// Return a string consisting of the reference's path component
// appended to all but the last segment of the base URI's path
@@ -1545,10 +1547,10 @@ inline QString QUrlPrivate::mergePaths(const QString &relativePath) const
// base URI path, or excluding the entire base URI path if it does
// not contain any "/" characters).
QString newPath;
- if (!path.contains(QLatin1Char('/')))
+ if (!path.contains(u'/'))
newPath = relativePath;
else
- newPath = QStringView{path}.left(path.lastIndexOf(QLatin1Char('/')) + 1) + relativePath;
+ newPath = QStringView{path}.left(path.lastIndexOf(u'/') + 1) + relativePath;
return newPath;
}
@@ -1594,7 +1596,7 @@ static void removeDotsFromPath(QString *path)
in += 2;
continue;
} else if (in == end - 2 && in[0].unicode() == '/' && in[1].unicode() == '.') {
- *out++ = QLatin1Char('/');
+ *out++ = u'/';
in += 2;
break;
}
@@ -1661,8 +1663,8 @@ inline QUrlPrivate::ErrorCode QUrlPrivate::validityError(QString *source, qsizet
if (path.isEmpty())
return NoError;
- if (path.at(0) == QLatin1Char('/')) {
- if (hasAuthority() || path.length() == 1 || path.at(1) != QLatin1Char('/'))
+ if (path.at(0) == u'/') {
+ if (hasAuthority() || path.length() == 1 || path.at(1) != u'/')
return NoError;
if (source) {
*source = path;
@@ -1779,7 +1781,7 @@ inline void QUrlPrivate::validate() const
if (!isHostValid)
return;
- if (scheme == QLatin1String("mailto")) {
+ if (scheme == "mailto"_L1) {
if (!host.isEmpty() || port != -1 || !userName.isEmpty() || !password.isEmpty()) {
that->isValid = false;
that->errorInfo.setParams(0, QT_TRANSLATE_NOOP(QUrl, "expected empty host, username,"
@@ -2321,15 +2323,15 @@ void QUrl::setHost(const QString &host, ParsingMode mode)
if (d->setHost(data, 0, data.length(), mode)) {
if (host.isNull())
d->sectionIsPresent &= ~QUrlPrivate::Host;
- } else if (!data.startsWith(QLatin1Char('['))) {
+ } else if (!data.startsWith(u'[')) {
// setHost failed, it might be IPv6 or IPvFuture in need of bracketing
Q_ASSERT(d->error);
- data.prepend(QLatin1Char('['));
- data.append(QLatin1Char(']'));
+ data.prepend(u'[');
+ data.append(u']');
if (!d->setHost(data, 0, data.length(), mode)) {
// failed again
- if (data.contains(QLatin1Char(':'))) {
+ if (data.contains(u':')) {
// source data contains ':', so it's an IPv6 error
d->error->code = QUrlPrivate::InvalidIPv6AddressError;
}
@@ -2363,7 +2365,7 @@ QString QUrl::host(ComponentFormattingOptions options) const
QString result;
if (d) {
d->appendHost(result, options);
- if (result.startsWith(QLatin1Char('[')))
+ if (result.startsWith(u'['))
result = result.mid(1, result.length() - 2);
}
return result;
@@ -2518,7 +2520,7 @@ QString QUrl::path(ComponentFormattingOptions options) const
QString QUrl::fileName(ComponentFormattingOptions options) const
{
const QString ourPath = path(options);
- const qsizetype slash = ourPath.lastIndexOf(QLatin1Char('/'));
+ const qsizetype slash = ourPath.lastIndexOf(u'/');
if (slash == -1)
return ourPath;
return ourPath.mid(slash + 1);
@@ -2776,7 +2778,7 @@ QUrl QUrl::resolved(const QUrl &relative) const
t.d->sectionIsPresent |= QUrlPrivate::Query;
}
} else {
- t.d->path = relative.d->path.startsWith(QLatin1Char('/'))
+ t.d->path = relative.d->path.startsWith(u'/')
? relative.d->path
: d->mergePaths(relative.d->path);
if (relative.d->hasQuery()) {
@@ -2883,26 +2885,26 @@ QString QUrl::toString(FormattingOptions options) const
options |= EncodeReserved;
if (!(options & QUrl::RemoveScheme) && d->hasScheme())
- url += d->scheme + QLatin1Char(':');
+ url += d->scheme + u':';
- bool pathIsAbsolute = d->path.startsWith(QLatin1Char('/'));
+ bool pathIsAbsolute = d->path.startsWith(u'/');
if (!((options & QUrl::RemoveAuthority) == QUrl::RemoveAuthority) && d->hasAuthority()) {
- url += QLatin1String("//");
+ url += "//"_L1;
d->appendAuthority(url, options, QUrlPrivate::FullUrl);
} else if (isLocalFile() && pathIsAbsolute) {
// Comply with the XDG file URI spec, which requires triple slashes.
- url += QLatin1String("//");
+ url += "//"_L1;
}
if (!(options & QUrl::RemovePath))
d->appendPath(url, options, QUrlPrivate::FullUrl);
if (!(options & QUrl::RemoveQuery) && d->hasQuery()) {
- url += QLatin1Char('?');
+ url += u'?';
d->appendQuery(url, options, QUrlPrivate::FullUrl);
}
if (!(options & QUrl::RemoveFragment) && d->hasFragment()) {
- url += QLatin1Char('#');
+ url += u'#';
d->appendFragment(url, options, QUrlPrivate::FullUrl);
}
@@ -3380,11 +3382,11 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
QString deslashified = fromNativeSeparators(localFile);
// magic for drives on windows
- if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) {
- deslashified.prepend(QLatin1Char('/'));
- } else if (deslashified.startsWith(QLatin1String("//"))) {
+ if (deslashified.length() > 1 && deslashified.at(1) == u':' && deslashified.at(0) != u'/') {
+ deslashified.prepend(u'/');
+ } else if (deslashified.startsWith("//"_L1)) {
// magic for shared drive on windows
- qsizetype indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2);
+ qsizetype indexOfPath = deslashified.indexOf(u'/', 2);
QStringView hostSpec = QStringView{deslashified}.mid(2, indexOfPath - 2);
// Check for Windows-specific WebDAV specification: "//host@SSL/path".
if (hostSpec.endsWith(webDavSslTag(), Qt::CaseInsensitive)) {
@@ -3465,16 +3467,16 @@ bool QUrl::isParentOf(const QUrl &childUrl) const
if (!d)
return ((childUrl.scheme().isEmpty())
&& (childUrl.authority().isEmpty())
- && childPath.length() > 0 && childPath.at(0) == QLatin1Char('/'));
+ && childPath.length() > 0 && childPath.at(0) == u'/');
QString ourPath = path();
return ((childUrl.scheme().isEmpty() || d->scheme == childUrl.scheme())
&& (childUrl.authority().isEmpty() || authority() == childUrl.authority())
&& childPath.startsWith(ourPath)
- && ((ourPath.endsWith(QLatin1Char('/')) && childPath.length() > ourPath.length())
- || (!ourPath.endsWith(QLatin1Char('/'))
- && childPath.length() > ourPath.length() && childPath.at(ourPath.length()) == QLatin1Char('/'))));
+ && ((ourPath.endsWith(u'/') && childPath.length() > ourPath.length())
+ || (!ourPath.endsWith(u'/') && childPath.length() > ourPath.length()
+ && childPath.at(ourPath.length()) == u'/')));
}
@@ -3533,21 +3535,21 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err
return QString();
case QUrlPrivate::InvalidSchemeError: {
- auto msg = QLatin1String("Invalid scheme (character '%1' not permitted)");
+ auto msg = "Invalid scheme (character '%1' not permitted)"_L1;
return msg.arg(c);
}
case QUrlPrivate::InvalidUserNameError:
- return QLatin1String("Invalid user name (character '%1' not permitted)")
+ return "Invalid user name (character '%1' not permitted)"_L1
.arg(c);
case QUrlPrivate::InvalidPasswordError:
- return QLatin1String("Invalid password (character '%1' not permitted)")
+ return "Invalid password (character '%1' not permitted)"_L1
.arg(c);
case QUrlPrivate::InvalidRegNameError:
if (errorPosition >= 0)
- return QLatin1String("Invalid hostname (character '%1' not permitted)")
+ return "Invalid hostname (character '%1' not permitted)"_L1
.arg(c);
else
return QStringLiteral("Invalid hostname (contains invalid characters)");
@@ -3556,9 +3558,9 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err
case QUrlPrivate::InvalidIPv6AddressError:
return QStringLiteral("Invalid IPv6 address");
case QUrlPrivate::InvalidCharacterInIPv6Error:
- return QLatin1String("Invalid IPv6 address (character '%1' not permitted)").arg(c);
+ return "Invalid IPv6 address (character '%1' not permitted)"_L1.arg(c);
case QUrlPrivate::InvalidIPvFutureError:
- return QLatin1String("Invalid IPvFuture address (character '%1' not permitted)").arg(c);
+ return "Invalid IPvFuture address (character '%1' not permitted)"_L1.arg(c);
case QUrlPrivate::HostMissingEndBracket:
return QStringLiteral("Expected ']' to match '[' in hostname");
@@ -3568,15 +3570,15 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err
return QStringLiteral("Port field was empty");
case QUrlPrivate::InvalidPathError:
- return QLatin1String("Invalid path (character '%1' not permitted)")
+ return "Invalid path (character '%1' not permitted)"_L1
.arg(c);
case QUrlPrivate::InvalidQueryError:
- return QLatin1String("Invalid query (character '%1' not permitted)")
+ return "Invalid query (character '%1' not permitted)"_L1
.arg(c);
case QUrlPrivate::InvalidFragmentError:
- return QLatin1String("Invalid fragment (character '%1' not permitted)")
+ return "Invalid fragment (character '%1' not permitted)"_L1
.arg(c);
case QUrlPrivate::AuthorityPresentAndPathIsRelative:
@@ -3597,9 +3599,9 @@ static inline void appendComponentIfPresent(QString &msg, bool present, const ch
{
if (present) {
msg += QLatin1String(componentName);
- msg += QLatin1Char('"');
+ msg += u'"';
msg += component;
- msg += QLatin1String("\",");
+ msg += "\","_L1;
}
}
@@ -3629,9 +3631,9 @@ QString QUrl::errorString() const
return msg;
msg += errorMessage(errorCode, errorSource, errorPosition);
- msg += QLatin1String("; source was \"");
+ msg += "; source was \""_L1;
msg += errorSource;
- msg += QLatin1String("\";");
+ msg += "\";"_L1;
appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Scheme,
" scheme = ", d->scheme);
appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::UserInfo,
@@ -3646,7 +3648,7 @@ QString QUrl::errorString() const
" query = ", d->query);
appendComponentIfPresent(msg, d->sectionIsPresent & QUrlPrivate::Fragment,
" fragment = ", d->fragment);
- if (msg.endsWith(QLatin1Char(',')))
+ if (msg.endsWith(u','))
msg.chop(1);
return msg;
}
@@ -3717,8 +3719,8 @@ static QUrl adjustFtpPath(QUrl url)
{
if (url.scheme() == ftpScheme()) {
QString path = url.path(QUrl::PrettyDecoded);
- if (path.startsWith(QLatin1String("//")))
- url.setPath(QLatin1String("/%2F") + QStringView{path}.mid(2), QUrl::TolerantMode);
+ if (path.startsWith("//"_L1))
+ url.setPath("/%2F"_L1 + QStringView{path}.mid(2), QUrl::TolerantMode);
}
return url;
}
@@ -3803,7 +3805,7 @@ QUrl QUrl::fromUserInput(const QString &userInput, const QString &workingDirecto
if (QDir::isAbsolutePath(trimmedString))
return QUrl::fromLocalFile(trimmedString);
- QUrl urlPrepended = QUrl(QLatin1String("http://") + trimmedString, QUrl::TolerantMode);
+ QUrl urlPrepended = QUrl("http://"_L1 + trimmedString, QUrl::TolerantMode);
// Check the most common case of a valid url with a scheme
// We check if the port would be valid by adding the scheme to handle the case host:port
@@ -3815,7 +3817,7 @@ QUrl QUrl::fromUserInput(const QString &userInput, const QString &workingDirecto
// Else, try the prepended one and adjust the scheme from the host name
if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty())) {
- qsizetype dotIndex = trimmedString.indexOf(QLatin1Char('.'));
+ qsizetype dotIndex = trimmedString.indexOf(u'.');
const QStringView hostscheme = QStringView{trimmedString}.left(dotIndex);
if (hostscheme.compare(ftpScheme(), Qt::CaseInsensitive) == 0)
urlPrepended.setScheme(ftpScheme());
diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp
index 14208f98ee..170475ce61 100644
--- a/src/corelib/io/qurlidna.cpp
+++ b/src/corelib/io/qurlidna.cpp
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// needed by the punycode encoder/decoder
static const uint base = 36;
static const uint tmin = 1;
@@ -137,7 +139,7 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(QStringView in, QString *output)
// if basic code points were copied, add the delimiter character.
if (h > 0)
- *output += QLatin1Char{'-'};
+ *output += u'-';
// compute the input length in Unicode code points.
uint inputLength = 0;
@@ -198,7 +200,7 @@ Q_AUTOTEST_EXPORT void qt_punycodeEncoder(QStringView in, QString *output)
}
// prepend ACE prefix
- output->insert(outLen, QLatin1String("xn--"));
+ output->insert(outLen, "xn--"_L1);
return;
}
@@ -215,13 +217,13 @@ Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc)
return QString();
// strip any ACE prefix
- int start = pc.startsWith(QLatin1String("xn--")) ? 4 : 0;
+ int start = pc.startsWith("xn--"_L1) ? 4 : 0;
if (!start)
return pc;
// find the last delimiter character '-' in the input array. copy
// all data before this delimiter directly to the output array.
- int delimiterPos = pc.lastIndexOf(QLatin1Char{'-'});
+ int delimiterPos = pc.lastIndexOf(u'-');
auto output = delimiterPos < 4 ? std::u32string()
: pc.mid(start, delimiterPos - start).toStdU32String();
@@ -383,7 +385,7 @@ static bool equal(const QChar *a, int l, const char *b)
static bool qt_is_idn_enabled(QStringView aceDomain)
{
- auto idx = aceDomain.lastIndexOf(QLatin1Char('.'));
+ auto idx = aceDomain.lastIndexOf(u'.');
if (idx == -1)
return false;
@@ -747,14 +749,14 @@ bool DomainValidityChecker::checkLabel(const QString &label, QUrl::AceProcessing
// This assumes that the first two characters are in BMP, but that's ok
// because non-BMP characters are unlikely to be used for specifying
// future extensions.
- if (label[2] == QLatin1Char('-') && label[3] == QLatin1Char('-'))
+ if (label[2] == u'-' && label[3] == u'-')
return false;
}
- if (label.startsWith(QLatin1Char('-')) || label.endsWith(QLatin1Char('-')))
+ if (label.startsWith(u'-') || label.endsWith(u'-'))
return false;
- if (label.contains(QLatin1Char('.')))
+ if (label.contains(u'.'))
return false;
QStringIterator iter(label);
@@ -871,7 +873,7 @@ static bool checkAsciiDomainName(const QString &normalizedDomain, AceLeadingDot
if (!validateAsciiLabel(label))
return false;
- hasPunycode = hasPunycode || label.startsWith(QLatin1String("xn--"));
+ hasPunycode = hasPunycode || label.startsWith("xn--"_L1);
}
lastIdx = idx + 1;
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 4435a47cab..8411697a87 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -45,6 +45,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static const DWORD minReadBufferSize = 4096;
QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
@@ -493,7 +495,7 @@ bool QWindowsPipeReader::consumePendingAndEmit(bool allowWinActPosting)
if (emitReadyRead)
emit readyRead();
if (alive && dwError != ERROR_BROKEN_PIPE && dwError != ERROR_PIPE_NOT_CONNECTED)
- emit winError(dwError, QLatin1String("QWindowsPipeReader::consumePendingAndEmit"));
+ emit winError(dwError, "QWindowsPipeReader::consumePendingAndEmit"_L1);
if (alive)
emit pipeClosed();
}
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index fa0c2486cc..e41c1b6df7 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -138,6 +138,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
extern QString qAppFileName();
#endif
@@ -573,7 +575,7 @@ void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths()
if (!app_libpaths)
coreappdata()->app_libpaths.reset(app_libpaths = new QStringList);
QString app_location = QCoreApplication::applicationFilePath();
- app_location.truncate(app_location.lastIndexOf(QLatin1Char('/')));
+ app_location.truncate(app_location.lastIndexOf(u'/'));
app_location = QDir(app_location).canonicalPath();
if (QFile::exists(app_location) && !app_libpaths->contains(app_location))
app_libpaths->append(app_location);
@@ -2181,20 +2183,20 @@ static void replacePercentN(QString *result, int n)
if (n >= 0) {
int percentPos = 0;
int len = 0;
- while ((percentPos = result->indexOf(QLatin1Char('%'), percentPos + len)) != -1) {
+ while ((percentPos = result->indexOf(u'%', percentPos + len)) != -1) {
len = 1;
if (percentPos + len == result->length())
break;
QString fmt;
- if (result->at(percentPos + len) == QLatin1Char('L')) {
+ if (result->at(percentPos + len) == u'L') {
++len;
if (percentPos + len == result->length())
break;
- fmt = QLatin1String("%L1");
+ fmt = "%L1"_L1;
} else {
- fmt = QLatin1String("%1");
+ fmt = "%1"_L1;
}
- if (result->at(percentPos + len) == QLatin1Char('n')) {
+ if (result->at(percentPos + len) == u'n') {
fmt = fmt.arg(n);
++len;
result->replace(percentPos, len, fmt);
@@ -2290,7 +2292,7 @@ QString QCoreApplication::translate(const char *context, const char *sourceText,
Q_UNUSED(disambiguation);
QString ret = QString::fromUtf8(sourceText);
if (n >= 0)
- ret.replace(QLatin1String("%n"), QString::number(n));
+ ret.replace("%n"_L1, QString::number(n));
return ret;
}
@@ -2406,13 +2408,13 @@ QString QCoreApplication::applicationFilePath()
if (absPath.isEmpty() && !arguments().isEmpty()) {
QString argv0 = QFile::decodeName(arguments().at(0).toLocal8Bit());
- if (!argv0.isEmpty() && argv0.at(0) == QLatin1Char('/')) {
+ if (!argv0.isEmpty() && argv0.at(0) == u'/') {
/*
If argv0 starts with a slash, it is already an absolute
file path.
*/
absPath = argv0;
- } else if (argv0.contains(QLatin1Char('/'))) {
+ } else if (argv0.contains(u'/')) {
/*
If argv0 contains one or more slashes, it is a file path
relative to the current directory.
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 87d8af90bb..03559d90ae 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -55,6 +55,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_CORE_EXPORT QString qAppFileName() // get application file name
{
/*
@@ -172,7 +174,7 @@ static QString flagsValue(const QWinMessageMapping<IntType> *haystack,
for (auto p = haystack, end = haystack + haystackSize; p < end; ++p) {
if ((p->value & value) == p->value) {
if (!result.isEmpty())
- result += QLatin1String(" | ");
+ result += " | "_L1;
result += QLatin1String(p->name);
}
}
@@ -664,8 +666,8 @@ QString decodeMSG(const MSG& msg)
// decoded message, since some of the common messages are quite long, and
// we don't want the decoded information to vary in output position
if (message.size() < 20)
- message.prepend(QString(20 - message.size(), QLatin1Char(' ')));
- message += QLatin1String(": ");
+ message.prepend(QString(20 - message.size(), u' '));
+ message += ": "_L1;
const QString hwndS = QString::asprintf("(%p)", reinterpret_cast<void *>(msg.hwnd));
const QString wParamS = QString::asprintf("(%p)", reinterpret_cast<void *>(wParam));
@@ -676,10 +678,10 @@ QString decodeMSG(const MSG& msg)
case WM_ACTIVATE:
if (const char *a = activateParameter(uint(wParam)))
parameters += QLatin1String(a);
- parameters += QLatin1String(" Hwnd ") + hwndS;
+ parameters += " Hwnd "_L1 + hwndS;
break;
case WM_CAPTURECHANGED:
- parameters = QLatin1String("Hwnd gaining capture ") + hwndS;
+ parameters = "Hwnd gaining capture "_L1 + hwndS;
break;
case WM_CREATE:
{
@@ -704,7 +706,7 @@ QString decodeMSG(const MSG& msg)
}
break;
case WM_DESTROY:
- parameters = QLatin1String("Destroy hwnd ") + hwndS;
+ parameters = "Destroy hwnd "_L1 + hwndS;
break;
case 0x02E0u: { // WM_DPICHANGED
auto rect = reinterpret_cast<const RECT *>(lParam);
@@ -715,20 +717,20 @@ QString decodeMSG(const MSG& msg)
break;
case WM_IME_NOTIFY:
{
- parameters = QLatin1String("Command(");
+ parameters = "Command("_L1;
if (const char *c = imeCommand(uint(wParam)))
parameters += QLatin1String(c);
- parameters += QLatin1String(" : ") + lParamS;
+ parameters += " : "_L1 + lParamS;
}
break;
case WM_IME_SETCONTEXT:
- parameters = QLatin1String("Input context(")
- + QLatin1String(wParam == TRUE ? "Active" : "Inactive")
- + QLatin1String(") Show flags(")
- + imeShowFlags(DWORD(lParam)) + QLatin1Char(')');
+ parameters = "Input context("_L1
+ + (wParam ? "Active"_L1 : "Inactive"_L1)
+ + ") Show flags("_L1
+ + imeShowFlags(DWORD(lParam)) + u')';
break;
case WM_KILLFOCUS:
- parameters = QLatin1String("Hwnd gaining keyboard focus ") + wParamS;
+ parameters = "Hwnd gaining keyboard focus "_L1 + wParamS;
break;
case WM_CHAR:
case WM_IME_CHAR:
@@ -751,7 +753,7 @@ QString decodeMSG(const MSG& msg)
parameters = QStringLiteral("Keyboard layout changed");
break;
case WM_NCACTIVATE:
- parameters = (msg.wParam? QLatin1String("Active Titlebar") : QLatin1String("Inactive Titlebar"));
+ parameters = (msg.wParam? "Active Titlebar"_L1 : "Inactive Titlebar"_L1);
break;
case WM_MOUSEACTIVATE:
{
@@ -778,14 +780,14 @@ QString decodeMSG(const MSG& msg)
case WM_MOUSEMOVE:
parameters = QString::asprintf("x,y(%4d,%4d) Virtual Keys(",
GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))
- + virtualKeys(uint(wParam)) + QLatin1Char(')');
+ + virtualKeys(uint(wParam)) + u')';
break;
case WM_MOVE:
parameters = QString::asprintf("x,y(%4d,%4d)", LOWORD(lParam), HIWORD(lParam));
break;
case WM_ERASEBKGND:
case WM_PAINT:
- parameters = QLatin1String("hdc") + wParamS;
+ parameters = "hdc"_L1 + wParamS;
break;
case WM_QUERYNEWPALETTE:
break; // lParam & wParam are unused
@@ -793,22 +795,22 @@ QString decodeMSG(const MSG& msg)
parameters = QString::asprintf("HitTestCode(0x%x) MouseMsg(", LOWORD(lParam));
if (const char *mouseMsg = findWMstr(HIWORD(lParam)))
parameters += QLatin1String(mouseMsg);
- parameters += QLatin1Char(')');
+ parameters += u')';
break;
case WM_SETFOCUS:
- parameters = QLatin1String("Lost Focus ") + wParamS;
+ parameters = "Lost Focus "_L1 + wParamS;
break;
case WM_SETTEXT:
- parameters = QLatin1String("Set Text (")
+ parameters = "Set Text ("_L1
+ QString::fromWCharArray(reinterpret_cast<const wchar_t *>(lParam))
- + QLatin1Char(')');
+ + u')';
break;
case WM_SIZE:
parameters = QString::asprintf("w,h(%4d,%4d) showmode(",
LOWORD(lParam), HIWORD(lParam));
if (const char *showMode = wmSizeParam(uint(wParam)))
parameters += QLatin1String(showMode);
- parameters += QLatin1Char(')');
+ parameters += u')';
break;
case WM_WINDOWPOSCHANGED:
{
@@ -823,20 +825,20 @@ QString decodeMSG(const MSG& msg)
parameters += QLatin1String(h);
else
parameters += QString::number(insertAfter, 16);
- parameters += QLatin1Char(')');
+ parameters += u')';
}
break;
case WM_QUERYENDSESSION:
- parameters = QLatin1String("End session: ");
+ parameters = "End session: "_L1;
if (const char *logoffOption = sessionMgrLogOffOption(uint(wParam)))
parameters += QLatin1String(logoffOption);
break;
default:
- parameters = QLatin1String("wParam") + wParamS + QLatin1String(" lParam") + lParamS;
+ parameters = "wParam"_L1 + wParamS + " lParam"_L1 + lParamS;
break;
}
- return message + QLatin1String("hwnd") + hwndS + QLatin1Char(' ') + parameters;
+ return message + "hwnd"_L1 + hwndS + u' ' + parameters;
}
QDebug operator<<(QDebug dbg, const MSG &msg)
diff --git a/src/corelib/kernel/qjniobject.cpp b/src/corelib/kernel/qjniobject.cpp
index dfb0dbd36d..1057f5fb59 100644
--- a/src/corelib/kernel/qjniobject.cpp
+++ b/src/corelib/kernel/qjniobject.cpp
@@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QJniObject
\inmodule QtCore
@@ -317,7 +319,7 @@ public:
static inline QLatin1String keyBase()
{
- return QLatin1String("%1%2:%3");
+ return "%1%2:%3"_L1;
}
static QString qt_convertJString(jstring string)
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 274f8d104b..b55b630b04 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -66,6 +66,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QMetaObject
\inmodule QtCore
@@ -2837,7 +2839,7 @@ static auto parse_scope(QLatin1String qualifiedKey) noexcept
std::optional<QLatin1String> scope;
QLatin1String key;
};
- const auto scopePos = qualifiedKey.lastIndexOf(QLatin1String("::"));
+ const auto scopePos = qualifiedKey.lastIndexOf("::"_L1);
if (scopePos < 0)
return R{std::nullopt, qualifiedKey};
else
@@ -2871,7 +2873,7 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const
auto className = [&] { return stringDataView(mobj, priv(mobj->d.data)->className); };
int value = 0;
- for (const QLatin1String &untrimmed : qTokenize(QLatin1String{keys}, QLatin1Char{'|'})) {
+ for (const QLatin1String &untrimmed : qTokenize(QLatin1String{keys}, u'|')) {
const auto parsed = parse_scope(untrimmed.trimmed());
if (parsed.scope && *parsed.scope != className())
return -1; // wrong type name in qualified name
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index 6a0a4d6ed1..7d00ea1061 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static inline QString textUriListLiteral() { return QStringLiteral("text/uri-list"); }
static inline QString textHtmlLiteral() { return QStringLiteral("text/html"); }
static inline QString textPlainLiteral() { return QStringLiteral("text/plain"); }
@@ -118,7 +120,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType ty
QVariant data = q->retrieveData(format, type);
// Text data requested: fallback to URL data if available
- if (format == QLatin1String("text/plain") && !data.isValid()) {
+ if (format == "text/plain"_L1 && !data.isValid()) {
data = retrieveTypedData(textUriListLiteral(), QMetaType(QMetaType::QVariantList));
if (data.metaType().id() == QMetaType::QUrl) {
data = QVariant(data.toUrl().toDisplayString());
@@ -128,7 +130,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType ty
const QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
if (list.at(i).metaType().id() == QMetaType::QUrl) {
- text += list.at(i).toUrl().toDisplayString() + QLatin1Char('\n');
+ text += list.at(i).toUrl().toDisplayString() + u'\n';
++numUrls;
}
}
@@ -158,7 +160,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType ty
switch (typeId) {
case QMetaType::QString: {
const QByteArray ba = data.toByteArray();
- if (format == QLatin1String("text/html")) {
+ if (format == "text/html"_L1) {
auto encoding = QStringConverter::encodingForHtml(ba);
if (encoding) {
QStringDecoder toUtf16(*encoding);
@@ -176,7 +178,7 @@ QT_WARNING_POP
return newData;
}
case QMetaType::QVariantList: {
- if (format != QLatin1String("text/uri-list"))
+ if (format != "text/uri-list"_L1)
break;
Q_FALLTHROUGH();
}
@@ -594,7 +596,7 @@ void QMimeData::setData(const QString &mimeType, const QByteArray &data)
{
Q_D(QMimeData);
- if (mimeType == QLatin1String("text/uri-list")) {
+ if (mimeType == "text/uri-list"_L1) {
QByteArray ba = data;
if (ba.endsWith('\0'))
ba.chop(1);
diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp
index 3dbbe75fc4..ba8bf5eca3 100644
--- a/src/corelib/kernel/qsharedmemory.cpp
+++ b/src/corelib/kernel/qsharedmemory.cpp
@@ -60,6 +60,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if !(defined(QT_NO_SHAREDMEMORY) && defined(QT_NO_SYSTEMSEMAPHORE))
/*!
\internal
@@ -90,14 +92,14 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
// so we can't use the logic below of combining the prefix, key, and a hash,
// to ensure a unique and valid name. Instead we use the first part of the
// hash, which should still long enough to avoid collisions in practice.
- return QLatin1Char('/') + hex.left(SHM_NAME_MAX - 1);
+ return u'/' + hex.left(SHM_NAME_MAX - 1);
}
#endif
QString result = prefix;
for (QChar ch : key) {
- if ((ch >= QLatin1Char('a') && ch <= QLatin1Char('z')) ||
- (ch >= QLatin1Char('A') && ch <= QLatin1Char('Z')))
+ if ((ch >= u'a' && ch <= u'z') ||
+ (ch >= u'A' && ch <= u'Z'))
result += ch;
}
result.append(QLatin1String(hex));
@@ -105,9 +107,9 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key,
#ifdef Q_OS_WIN
return result;
#elif defined(QT_POSIX_IPC)
- return QLatin1Char('/') + result;
+ return u'/' + result;
#else
- return QDir::tempPath() + QLatin1Char('/') + result;
+ return QDir::tempPath() + u'/' + result;
#endif
}
#endif // QT_NO_SHAREDMEMORY && QT_NO_SHAREDMEMORY
@@ -321,7 +323,7 @@ bool QSharedMemoryPrivate::initKey()
systemSemaphore.setKey(QString(), 1);
systemSemaphore.setKey(key, 1);
if (systemSemaphore.error() != QSystemSemaphore::NoError) {
- QString function = QLatin1String("QSharedMemoryPrivate::initKey");
+ QString function = "QSharedMemoryPrivate::initKey"_L1;
errorString = QSharedMemory::tr("%1: unable to set key on lock").arg(function);
switch(systemSemaphore.error()) {
case QSystemSemaphore::PermissionDenied:
@@ -412,7 +414,7 @@ bool QSharedMemory::create(qsizetype size, AccessMode mode)
#endif
#endif
- QString function = QLatin1String("QSharedMemory::create");
+ QString function = "QSharedMemory::create"_L1;
#ifndef QT_NO_SYSTEMSEMAPHORE
QSharedMemoryLocker lock(this);
if (!d->key.isNull() && !d->tryLocker(&lock, function))
@@ -479,7 +481,7 @@ bool QSharedMemory::attach(AccessMode mode)
return false;
#ifndef QT_NO_SYSTEMSEMAPHORE
QSharedMemoryLocker lock(this);
- if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::attach")))
+ if (!d->key.isNull() && !d->tryLocker(&lock, "QSharedMemory::attach"_L1))
return false;
#endif
@@ -519,7 +521,7 @@ bool QSharedMemory::detach()
#ifndef QT_NO_SYSTEMSEMAPHORE
QSharedMemoryLocker lock(this);
- if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::detach")))
+ if (!d->key.isNull() && !d->tryLocker(&lock, "QSharedMemory::detach"_L1))
return false;
#endif
@@ -588,7 +590,7 @@ bool QSharedMemory::lock()
d->lockedByMe = true;
return true;
}
- QString function = QLatin1String("QSharedMemory::lock");
+ const auto function = "QSharedMemory::lock"_L1;
d->errorString = QSharedMemory::tr("%1: unable to lock").arg(function);
d->error = QSharedMemory::LockError;
return false;
@@ -610,7 +612,7 @@ bool QSharedMemory::unlock()
d->lockedByMe = false;
if (d->systemSemaphore.release())
return true;
- QString function = QLatin1String("QSharedMemory::unlock");
+ const auto function = "QSharedMemory::unlock"_L1;
d->errorString = QSharedMemory::tr("%1: unable to unlock").arg(function);
d->error = QSharedMemory::LockError;
return false;
diff --git a/src/corelib/kernel/qsharedmemory_posix.cpp b/src/corelib/kernel/qsharedmemory_posix.cpp
index 9406e200be..713339d345 100644
--- a/src/corelib/kernel/qsharedmemory_posix.cpp
+++ b/src/corelib/kernel/qsharedmemory_posix.cpp
@@ -61,12 +61,14 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
int QSharedMemoryPrivate::handle()
{
// don't allow making handles on empty keys
const QString safeKey = makePlatformSafeKey(key);
if (safeKey.isEmpty()) {
- errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle"));
+ errorString = QSharedMemory::tr("%1: key is empty").arg("QSharedMemory::handle"_L1);
error = QSharedMemory::KeyError;
return 0;
}
@@ -100,7 +102,7 @@ bool QSharedMemoryPrivate::create(qsizetype size)
#endif
if (fd == -1) {
const int errorNumber = errno;
- const QLatin1String function("QSharedMemory::attach (shm_open)");
+ const auto function = "QSharedMemory::attach (shm_open)"_L1;
switch (errorNumber) {
case EINVAL:
errorString = QSharedMemory::tr("%1: bad name").arg(function);
@@ -116,7 +118,7 @@ bool QSharedMemoryPrivate::create(qsizetype size)
int ret;
EINTR_LOOP(ret, QT_FTRUNCATE(fd, size));
if (ret == -1) {
- setErrorString(QLatin1String("QSharedMemory::create (ftruncate)"));
+ setErrorString("QSharedMemory::create (ftruncate)"_L1);
qt_safe_close(fd);
return false;
}
@@ -143,7 +145,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
#endif
if (hand == -1) {
const int errorNumber = errno;
- const QLatin1String function("QSharedMemory::attach (shm_open)");
+ const auto function = "QSharedMemory::attach (shm_open)"_L1;
switch (errorNumber) {
case EINVAL:
errorString = QSharedMemory::tr("%1: bad name").arg(function);
@@ -159,7 +161,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
// grab the size
QT_STATBUF st;
if (QT_FSTAT(hand, &st) == -1) {
- setErrorString(QLatin1String("QSharedMemory::attach (fstat)"));
+ setErrorString("QSharedMemory::attach (fstat)"_L1);
cleanHandle();
return false;
}
@@ -169,7 +171,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
const int mprot = (mode == QSharedMemory::ReadOnly ? PROT_READ : PROT_READ | PROT_WRITE);
memory = QT_MMAP(0, size_t(size), mprot, MAP_SHARED, hand, 0);
if (memory == MAP_FAILED || !memory) {
- setErrorString(QLatin1String("QSharedMemory::attach (mmap)"));
+ setErrorString("QSharedMemory::attach (mmap)"_L1);
cleanHandle();
memory = 0;
size = 0;
@@ -190,7 +192,7 @@ bool QSharedMemoryPrivate::detach()
{
// detach from the memory segment
if (::munmap(memory, size_t(size)) == -1) {
- setErrorString(QLatin1String("QSharedMemory::detach (munmap)"));
+ setErrorString("QSharedMemory::detach (munmap)"_L1);
return false;
}
memory = 0;
@@ -216,7 +218,7 @@ bool QSharedMemoryPrivate::detach()
if (shm_nattch == 0) {
const QByteArray shmName = QFile::encodeName(makePlatformSafeKey(key));
if (::shm_unlink(shmName.constData()) == -1 && errno != ENOENT)
- setErrorString(QLatin1String("QSharedMemory::detach (shm_unlink)"));
+ setErrorString("QSharedMemory::detach (shm_unlink)"_L1);
}
#else
// On non-QNX systems (tested Linux and Haiku), the st_nlink field is always 1,
diff --git a/src/corelib/kernel/qsharedmemory_systemv.cpp b/src/corelib/kernel/qsharedmemory_systemv.cpp
index 65ad23b9f6..04bc700fdf 100644
--- a/src/corelib/kernel/qsharedmemory_systemv.cpp
+++ b/src/corelib/kernel/qsharedmemory_systemv.cpp
@@ -63,6 +63,8 @@
#ifndef QT_NO_SHAREDMEMORY
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\internal
@@ -76,21 +78,21 @@ key_t QSharedMemoryPrivate::handle()
// don't allow making handles on empty keys
if (nativeKey.isEmpty()) {
- errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle:"));
+ errorString = QSharedMemory::tr("%1: key is empty").arg("QSharedMemory::handle:"_L1);
error = QSharedMemory::KeyError;
return 0;
}
// ftok requires that an actual file exists somewhere
if (!QFile::exists(nativeKey)) {
- errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg(QLatin1String("QSharedMemory::handle:"));
+ errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg("QSharedMemory::handle:"_L1);
error = QSharedMemory::NotFound;
return 0;
}
unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q');
if (-1 == unix_key) {
- errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:"));
+ errorString = QSharedMemory::tr("%1: ftok failed").arg("QSharedMemory::handle:"_L1);
error = QSharedMemory::KeyError;
unix_key = 0;
}
@@ -138,7 +140,7 @@ bool QSharedMemoryPrivate::create(qsizetype size)
bool createdFile = false;
int built = createUnixKeyFile(nativeKey);
if (built == -1) {
- errorString = QSharedMemory::tr("%1: unable to make key").arg(QLatin1String("QSharedMemory::handle:"));
+ errorString = QSharedMemory::tr("%1: unable to make key").arg("QSharedMemory::handle:"_L1);
error = QSharedMemory::KeyError;
return false;
}
@@ -155,10 +157,10 @@ bool QSharedMemoryPrivate::create(qsizetype size)
// create
if (-1 == shmget(unix_key, size_t(size), 0600 | IPC_CREAT | IPC_EXCL)) {
- const QLatin1String function("QSharedMemory::create");
+ const auto function = "QSharedMemory::create"_L1;
switch (errno) {
case EINVAL:
- errorString = QSharedMemory::tr("%1: system-imposed size restrictions").arg(QLatin1String("QSharedMemory::handle"));
+ errorString = QSharedMemory::tr("%1: system-imposed size restrictions").arg("QSharedMemory::handle"_L1);
error = QSharedMemory::InvalidSize;
break;
default:
@@ -177,7 +179,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
// grab the shared memory segment id
int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0400 : 0600));
if (-1 == id) {
- setErrorString(QLatin1String("QSharedMemory::attach (shmget)"));
+ setErrorString("QSharedMemory::attach (shmget)"_L1);
return false;
}
@@ -185,7 +187,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
memory = shmat(id, nullptr, (mode == QSharedMemory::ReadOnly ? SHM_RDONLY : 0));
if ((void *)-1 == memory) {
memory = nullptr;
- setErrorString(QLatin1String("QSharedMemory::attach (shmat)"));
+ setErrorString("QSharedMemory::attach (shmat)"_L1);
return false;
}
@@ -194,7 +196,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
if (!shmctl(id, IPC_STAT, &shmid_ds)) {
size = (qsizetype)shmid_ds.shm_segsz;
} else {
- setErrorString(QLatin1String("QSharedMemory::attach (shmctl)"));
+ setErrorString("QSharedMemory::attach (shmctl)"_L1);
return false;
}
@@ -205,7 +207,7 @@ bool QSharedMemoryPrivate::detach()
{
// detach from the memory segment
if (-1 == shmdt(memory)) {
- const QLatin1String function("QSharedMemory::detach");
+ const auto function = "QSharedMemory::detach"_L1;
switch (errno) {
case EINVAL:
errorString = QSharedMemory::tr("%1: not attached").arg(function);
@@ -236,7 +238,7 @@ bool QSharedMemoryPrivate::detach()
if (shmid_ds.shm_nattch == 0) {
// mark for removal
if (-1 == shmctl(id, IPC_RMID, &shmid_ds)) {
- setErrorString(QLatin1String("QSharedMemory::remove"));
+ setErrorString("QSharedMemory::remove"_L1);
switch (errno) {
case EINVAL:
return true;
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index 30ae5fb275..920f60b286 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -45,6 +45,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifndef QT_NO_SHAREDMEMORY
QSharedMemoryPrivate::QSharedMemoryPrivate() :
@@ -95,7 +97,7 @@ void QSharedMemoryPrivate::setErrorString(QLatin1String function)
HANDLE QSharedMemoryPrivate::handle()
{
if (!hand) {
- const QLatin1String function("QSharedMemory::handle");
+ const auto function = "QSharedMemory::handle"_L1;
if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: unable to make key").arg(function);
@@ -115,7 +117,7 @@ bool QSharedMemoryPrivate::cleanHandle()
{
if (hand != 0 && !CloseHandle(hand)) {
hand = 0;
- setErrorString(QLatin1String("QSharedMemory::cleanHandle"));
+ setErrorString("QSharedMemory::cleanHandle"_L1);
return false;
}
hand = 0;
@@ -124,7 +126,7 @@ bool QSharedMemoryPrivate::cleanHandle()
bool QSharedMemoryPrivate::create(qsizetype size)
{
- const QLatin1String function("QSharedMemory::create");
+ const auto function = "QSharedMemory::create"_L1;
if (nativeKey.isEmpty()) {
error = QSharedMemory::KeyError;
errorString = QSharedMemory::tr("%1: key error").arg(function);
@@ -152,7 +154,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
int permissions = (mode == QSharedMemory::ReadOnly ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS);
memory = (void *)MapViewOfFile(handle(), permissions, 0, 0, 0);
if (0 == memory) {
- setErrorString(QLatin1String("QSharedMemory::attach"));
+ setErrorString("QSharedMemory::attach"_L1);
cleanHandle();
return false;
}
@@ -163,7 +165,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
// Windows doesn't set an error code on this one,
// it should only be a kernel memory error.
error = QSharedMemory::UnknownError;
- errorString = QSharedMemory::tr("%1: size query failed").arg(QLatin1String("QSharedMemory::attach: "));
+ errorString = QSharedMemory::tr("%1: size query failed").arg("QSharedMemory::attach: "_L1);
return false;
}
size = qsizetype(info.RegionSize);
@@ -175,7 +177,7 @@ bool QSharedMemoryPrivate::detach()
{
// umap memory
if (!UnmapViewOfFile(memory)) {
- setErrorString(QLatin1String("QSharedMemory::detach"));
+ setErrorString("QSharedMemory::detach"_L1);
return false;
}
memory = 0;
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 4be4874cf1..1aea501416 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if !defined(Q_OS_WIN) && QT_CONFIG(thread) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
namespace {
@@ -92,11 +94,11 @@ static QString windowsErrorString(int errorCode)
if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND)
ret = QString::fromLatin1("The specified module could not be found.");
- if (ret.endsWith(QLatin1String("\r\n")))
+ if (ret.endsWith("\r\n"_L1))
ret.chop(2);
if (ret.isEmpty())
ret = QString::fromLatin1("Unknown error 0x%1.")
- .arg(unsigned(errorCode), 8, 16, QLatin1Char('0'));
+ .arg(unsigned(errorCode), 8, 16, '0'_L1);
return ret;
}
#endif
@@ -152,7 +154,7 @@ QString QSystemError::string(ErrorScope errorScope, int errorCode)
qWarning("invalid error scope");
Q_FALLTHROUGH();
case NoError:
- return QLatin1String("No error");
+ return u"No error"_qs;
}
}
diff --git a/src/corelib/kernel/qsystemsemaphore_posix.cpp b/src/corelib/kernel/qsystemsemaphore_posix.cpp
index 567e154e0d..330801a36e 100644
--- a/src/corelib/kernel/qsystemsemaphore_posix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_posix.cpp
@@ -64,13 +64,15 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
bool QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
{
if (semaphore != SEM_FAILED)
return true; // we already have a semaphore
if (fileName.isEmpty()) {
- errorString = QSystemSemaphore::tr("%1: key is empty").arg(QLatin1String("QSystemSemaphore::handle"));
+ errorString = QSystemSemaphore::tr("%1: key is empty").arg("QSystemSemaphore::handle"_L1);
error = QSystemSemaphore::KeyError;
return false;
}
@@ -86,7 +88,7 @@ bool QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
if (semaphore == SEM_FAILED && errno == EEXIST) {
if (mode == QSystemSemaphore::Create) {
if (::sem_unlink(semName.constData()) == -1 && errno != ENOENT) {
- setErrorString(QLatin1String("QSystemSemaphore::handle (sem_unlink)"));
+ setErrorString("QSystemSemaphore::handle (sem_unlink)"_L1);
return false;
}
// Race condition: the semaphore might be recreated before
@@ -104,7 +106,7 @@ bool QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
}
if (semaphore == SEM_FAILED) {
- setErrorString(QLatin1String("QSystemSemaphore::handle"));
+ setErrorString("QSystemSemaphore::handle"_L1);
return false;
}
@@ -117,7 +119,7 @@ void QSystemSemaphorePrivate::cleanHandle()
{
if (semaphore != SEM_FAILED) {
if (::sem_close(semaphore) == -1) {
- setErrorString(QLatin1String("QSystemSemaphore::cleanHandle (sem_close)"));
+ setErrorString("QSystemSemaphore::cleanHandle (sem_close)"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::cleanHandle sem_close failed.");
#endif
@@ -127,7 +129,7 @@ void QSystemSemaphorePrivate::cleanHandle()
if (createdSemaphore) {
if (::sem_unlink(QFile::encodeName(fileName).constData()) == -1 && errno != ENOENT) {
- setErrorString(QLatin1String("QSystemSemaphore::cleanHandle (sem_unlink)"));
+ setErrorString("QSystemSemaphore::cleanHandle (sem_unlink)"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::cleanHandle sem_unlink failed.");
#endif
@@ -145,7 +147,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
int cnt = count;
do {
if (::sem_post(semaphore) == -1) {
- setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_post)"));
+ setErrorString("QSystemSemaphore::modifySemaphore (sem_post)"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modify sem_post failed %d %d", count, errno);
#endif
@@ -167,7 +169,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
semaphore = SEM_FAILED;
return modifySemaphore(count);
}
- setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_wait)"));
+ setErrorString("QSystemSemaphore::modifySemaphore (sem_wait)"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modify sem_wait failed %d %d", count, errno);
#endif
diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
index 1c9fc1f2f7..4d577d11df 100644
--- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
@@ -68,6 +68,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\internal
@@ -79,7 +81,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
if (qt_apple_isSandboxed()) {
errorString = QSystemSemaphore::tr("%1: System V semaphores are not available " \
"for sandboxed applications. Please build Qt with -feature-ipc_posix")
- .arg(QLatin1String("QSystemSemaphore::handle:"));
+ .arg("QSystemSemaphore::handle:"_L1);
error = QSystemSemaphore::PermissionDenied;
return -1;
}
@@ -87,7 +89,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
if (key.isEmpty()){
errorString = QSystemSemaphore::tr("%1: key is empty")
- .arg(QLatin1String("QSystemSemaphore::handle:"));
+ .arg("QSystemSemaphore::handle:"_L1);
error = QSystemSemaphore::KeyError;
return -1;
}
@@ -100,7 +102,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
int built = QSharedMemoryPrivate::createUnixKeyFile(fileName);
if (-1 == built) {
errorString = QSystemSemaphore::tr("%1: unable to make key")
- .arg(QLatin1String("QSystemSemaphore::handle:"));
+ .arg("QSystemSemaphore::handle:"_L1);
error = QSystemSemaphore::KeyError;
return -1;
}
@@ -112,7 +114,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
#endif
if (-1 == unix_key) {
errorString = QSystemSemaphore::tr("%1: ftok failed")
- .arg(QLatin1String("QSystemSemaphore::handle:"));
+ .arg("QSystemSemaphore::handle:"_L1);
error = QSystemSemaphore::KeyError;
return -1;
}
@@ -123,7 +125,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
if (errno == EEXIST)
semaphore = semget(unix_key, 1, 0600 | IPC_CREAT);
if (-1 == semaphore) {
- setErrorString(QLatin1String("QSystemSemaphore::handle"));
+ setErrorString("QSystemSemaphore::handle"_L1);
cleanHandle();
return -1;
}
@@ -143,7 +145,7 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
qt_semun init_op;
init_op.val = initialValue;
if (-1 == semctl(semaphore, 0, SETVAL, init_op)) {
- setErrorString(QLatin1String("QSystemSemaphore::handle"));
+ setErrorString("QSystemSemaphore::handle"_L1);
cleanHandle();
return -1;
}
@@ -170,7 +172,7 @@ void QSystemSemaphorePrivate::cleanHandle()
if (createdSemaphore) {
if (-1 != semaphore) {
if (-1 == semctl(semaphore, 0, IPC_RMID, 0)) {
- setErrorString(QLatin1String("QSystemSemaphore::cleanHandle"));
+ setErrorString("QSystemSemaphore::cleanHandle"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::cleanHandle semctl failed.");
#endif
@@ -204,7 +206,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
handle();
return modifySemaphore(count);
}
- setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
+ setErrorString("QSystemSemaphore::modifySemaphore"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modify failed %d %d %d %d %d",
count, int(semctl(semaphore, 0, GETVAL)), int(errno), int(EIDRM), int(EINVAL);
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index d19476db4a..96d3ba0679 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -45,6 +45,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifndef QT_NO_SYSTEMSEMAPHORE
QSystemSemaphorePrivate::QSystemSemaphorePrivate() :
@@ -88,7 +90,7 @@ HANDLE QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode)
semaphore = CreateSemaphore(0, initialValue, MAXLONG,
reinterpret_cast<const wchar_t*>(fileName.utf16()));
if (semaphore == NULL)
- setErrorString(QLatin1String("QSystemSemaphore::handle"));
+ setErrorString("QSystemSemaphore::handle"_L1);
}
return semaphore;
@@ -111,7 +113,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
if (count > 0) {
if (0 == ReleaseSemaphore(semaphore, count, 0)) {
- setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
+ setErrorString("QSystemSemaphore::modifySemaphore"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modifySemaphore ReleaseSemaphore failed");
#endif
@@ -119,7 +121,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
} else {
if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) {
- setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
+ setErrorString("QSystemSemaphore::modifySemaphore"_L1);
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modifySemaphore WaitForSingleObject failed");
#endif
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 1d0c613c17..9f0ce2a825 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -485,8 +485,8 @@ bool QTranslator::load(const QString & filename, const QString & directory,
QString prefix;
if (QFileInfo(filename).isRelative()) {
prefix = directory;
- if (prefix.length() && !prefix.endsWith(QLatin1Char('/')))
- prefix += QLatin1Char('/');
+ if (prefix.length() && !prefix.endsWith(u'/'))
+ prefix += u'/';
}
const QString suffixOrDotQM = suffix.isNull() ? dotQmLiteral() : suffix;
@@ -530,7 +530,7 @@ bool QTranslatorPrivate::do_load(const QString &realname, const QString &directo
QTranslatorPrivate *d = this;
bool ok = false;
- if (realname.startsWith(QLatin1Char(':'))) {
+ if (realname.startsWith(u':')) {
// If the translation is in a non-compressed resource file, the data is already in
// memory, so no need to use QFile to copy it again.
Q_ASSERT(!d->resource);
@@ -645,8 +645,8 @@ static QString find_translation(const QLocale & locale,
QString path;
if (QFileInfo(filename).isRelative()) {
path = directory;
- if (!path.isEmpty() && !path.endsWith(QLatin1Char('/')))
- path += QLatin1Char('/');
+ if (!path.isEmpty() && !path.endsWith(u'/'))
+ path += u'/';
}
const QString suffixOrDotQM = suffix.isNull() ? dotQmLiteral() : suffix;
@@ -667,7 +667,7 @@ static QString find_translation(const QLocale & locale,
#endif
for (QString localeName : qAsConst(languages)) {
- localeName.replace(QLatin1Char('-'), QLatin1Char('_'));
+ localeName.replace(u'-', u'_');
// try the complete locale name first and progressively truncate from
// the end until a matching language tag is found (with or without suffix)
@@ -682,7 +682,7 @@ static QString find_translation(const QLocale & locale,
realname.truncate(realNameBaseSize);
- int rightmost = localeName.lastIndexOf(QLatin1Char('_'));
+ int rightmost = localeName.lastIndexOf(u'_');
if (rightmost <= 0)
break; // no truncations anymore, break
localeName.truncate(rightmost);
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 13c90f2578..72dce5e32f 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -90,6 +90,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace { // anonymous used to hide QVariant handlers
/*!
@@ -154,11 +156,11 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok, bool all
if (*ok)
return l;
if (allowStringToBool) {
- if (s == QLatin1String("false") || s == QLatin1String("0")) {
+ if (s == "false"_L1 || s == "0"_L1) {
*ok = true;
return 0;
}
- if (s == QLatin1String("true") || s == QLatin1String("1")) {
+ if (s == "true"_L1 || s == "1"_L1) {
*ok = true;
return 1;
}
diff --git a/src/corelib/mimetypes/qmimedatabase.cpp b/src/corelib/mimetypes/qmimedatabase.cpp
index 518da4316c..8510bdca93 100644
--- a/src/corelib/mimetypes/qmimedatabase.cpp
+++ b/src/corelib/mimetypes/qmimedatabase.cpp
@@ -62,6 +62,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static QString directoryMimeType()
{
return QStringLiteral("inode/directory");
@@ -116,7 +118,7 @@ void QMimeDatabasePrivate::loadProviders()
// We use QStandardPaths every time to check if new files appeared
const QStringList mimeDirs = locateMimeDirectories();
const auto fdoIterator = std::find_if(mimeDirs.constBegin(), mimeDirs.constEnd(), [](const QString &mimeDir) -> bool {
- return QFileInfo::exists(mimeDir + QLatin1String("/packages/freedesktop.org.xml")); }
+ return QFileInfo::exists(mimeDir + "/packages/freedesktop.org.xml"_L1); }
);
const bool needInternalDB = QMimeXMLProvider::InternalDatabaseAvailable && fdoIterator == mimeDirs.constEnd();
//qDebug() << "mime dirs:" << mimeDirs;
@@ -127,7 +129,7 @@ void QMimeDatabasePrivate::loadProviders()
m_providers.reserve(mimeDirs.size() + (needInternalDB ? 1 : 0));
for (const QString &mimeDir : mimeDirs) {
- const QString cacheFile = mimeDir + QLatin1String("/mime.cache");
+ const QString cacheFile = mimeDir + "/mime.cache"_L1;
// Check if we already have a provider for this dir
const auto predicate = [mimeDir](const std::unique_ptr<QMimeProviderBase> &prov)
{
@@ -219,7 +221,7 @@ QMimeType QMimeDatabasePrivate::mimeTypeForName(const QString &nameOrAlias)
QStringList QMimeDatabasePrivate::mimeTypeForFileName(const QString &fileName)
{
- if (fileName.endsWith(QLatin1Char('/')))
+ if (fileName.endsWith(u'/'))
return { directoryMimeType() };
const QMimeGlobMatchResult result = findByFileName(fileName);
@@ -252,7 +254,7 @@ void QMimeDatabasePrivate::loadMimeTypePrivate(QMimeTypePrivate &mimePrivate)
}
}
if (!found) {
- const QString file = mimePrivate.name + QLatin1String(".xml");
+ const QString file = mimePrivate.name + ".xml"_L1;
qWarning() << "No file found for" << file << ", even though update-mime-info said it would exist.\n"
"Either it was just removed, or the directory doesn't have executable permission..."
<< locateMimeDirectories();
@@ -289,14 +291,14 @@ void QMimeDatabasePrivate::loadIcon(QMimeTypePrivate &mimePrivate)
QString QMimeDatabasePrivate::fallbackParent(const QString &mimeTypeName) const
{
- const QStringView myGroup = QStringView{mimeTypeName}.left(mimeTypeName.indexOf(QLatin1Char('/')));
+ const QStringView myGroup = QStringView{mimeTypeName}.left(mimeTypeName.indexOf(u'/'));
// All text/* types are subclasses of text/plain.
- if (myGroup == QLatin1String("text") && mimeTypeName != plainTextMimeType())
+ if (myGroup == "text"_L1 && mimeTypeName != plainTextMimeType())
return plainTextMimeType();
// All real-file mimetypes implicitly derive from application/octet-stream
- if (myGroup != QLatin1String("inode") &&
+ if (myGroup != "inode"_L1 &&
// ignore non-file extensions
- myGroup != QLatin1String("all") && myGroup != QLatin1String("fonts") && myGroup != QLatin1String("print") && myGroup != QLatin1String("uri")
+ myGroup != "all"_L1 && myGroup != "fonts"_L1 && myGroup != "print"_L1 && myGroup != "uri"_L1
&& mimeTypeName != defaultMimeType()) {
return defaultMimeType();
}
@@ -752,7 +754,7 @@ QMimeType QMimeDatabase::mimeTypeForUrl(const QUrl &url) const
return mimeTypeForFile(url.toLocalFile());
const QString scheme = url.scheme();
- if (scheme.startsWith(QLatin1String("http")) || scheme == QLatin1String("mailto"))
+ if (scheme.startsWith("http"_L1) || scheme == "mailto"_L1)
return mimeTypeForName(d->defaultMimeType());
return mimeTypeForFile(url.path(), MatchExtension);
@@ -781,7 +783,7 @@ QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, QIO
{
QMutexLocker locker(&d->mutex);
- if (fileName.endsWith(QLatin1Char('/')))
+ if (fileName.endsWith(u'/'))
return d->mimeTypeForName(directoryMimeType());
const QMimeType result = d->mimeTypeForFileNameAndData(fileName, device);
@@ -808,7 +810,7 @@ QMimeType QMimeDatabase::mimeTypeForFileNameAndData(const QString &fileName, con
{
QMutexLocker locker(&d->mutex);
- if (fileName.endsWith(QLatin1Char('/')))
+ if (fileName.endsWith(u'/'))
return d->mimeTypeForName(directoryMimeType());
QBuffer buffer(const_cast<QByteArray *>(&data));
diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp
index d36c29a82d..be38f071df 100644
--- a/src/corelib/mimetypes/qmimeglobpattern.cpp
+++ b/src/corelib/mimetypes/qmimeglobpattern.cpp
@@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\internal
\class QMimeGlobMatchResult
@@ -97,17 +99,17 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
if (!patternLength)
return OtherPattern;
- const int starCount = pattern.count(QLatin1Char('*'));
- const bool hasSquareBracket = pattern.indexOf(QLatin1Char('[')) != -1;
- const bool hasQuestionMark = pattern.indexOf(QLatin1Char('?')) != -1;
+ const int starCount = pattern.count(u'*');
+ const bool hasSquareBracket = pattern.indexOf(u'[') != -1;
+ const bool hasQuestionMark = pattern.indexOf(u'?') != -1;
if (!hasSquareBracket && !hasQuestionMark) {
if (starCount == 1) {
// Patterns like "*~", "*.extension"
- if (pattern.at(0) == QLatin1Char('*'))
+ if (pattern.at(0) == u'*')
return SuffixPattern;
// Patterns like "README*" (well this is currently the only one like that...)
- if (pattern.at(patternLength - 1) == QLatin1Char('*'))
+ if (pattern.at(patternLength - 1) == u'*')
return PrefixPattern;
} else if (starCount == 0) {
// Names without any wildcards like "README"
@@ -115,10 +117,10 @@ QMimeGlobPattern::PatternType QMimeGlobPattern::detectPatternType(const QString
}
}
- if (pattern == QLatin1String("[0-9][0-9][0-9].vdr"))
+ if (pattern == "[0-9][0-9][0-9].vdr"_L1)
return VdrPattern;
- if (pattern == QLatin1String("*.anim[1-9j]"))
+ if (pattern == "*.anim[1-9j]"_L1)
return AnimPattern;
return OtherPattern;
@@ -175,14 +177,14 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFileName) const
case VdrPattern: // "[0-9][0-9][0-9].vdr" case
return fileNameLength == 7
&& fileName.at(0).isDigit() && fileName.at(1).isDigit() && fileName.at(2).isDigit()
- && QStringView{fileName}.mid(3, 4) == QLatin1String(".vdr");
+ && QStringView{fileName}.mid(3, 4) == ".vdr"_L1;
case AnimPattern: { // "*.anim[1-9j]" case
if (fileNameLength < 6)
return false;
const QChar lastChar = fileName.at(fileNameLength - 1);
- const bool lastCharOK = (lastChar.isDigit() && lastChar != QLatin1Char('0'))
- || lastChar == QLatin1Char('j');
- return lastCharOK && QStringView{fileName}.mid(fileNameLength - 6, 5) == QLatin1String(".anim");
+ const bool lastCharOK = (lastChar.isDigit() && lastChar != u'0')
+ || lastChar == u'j';
+ return lastCharOK && QStringView{fileName}.mid(fileNameLength - 6, 5) == ".anim"_L1;
}
case OtherPattern:
// Other fallback patterns: slow but correct method
@@ -199,23 +201,23 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFileName) const
static bool isSimplePattern(const QString &pattern)
{
// starts with "*.", has no other '*'
- return pattern.lastIndexOf(QLatin1Char('*')) == 0
+ return pattern.lastIndexOf(u'*') == 0
&& pattern.length() > 1
- && pattern.at(1) == QLatin1Char('.') // (other dots are OK, like *.tar.bz2)
+ && pattern.at(1) == u'.' // (other dots are OK, like *.tar.bz2)
// and contains no other special character
- && !pattern.contains(QLatin1Char('?'))
- && !pattern.contains(QLatin1Char('['))
+ && !pattern.contains(u'?')
+ && !pattern.contains(u'[')
;
}
static bool isFastPattern(const QString &pattern)
{
// starts with "*.", has no other '*' and no other '.'
- return pattern.lastIndexOf(QLatin1Char('*')) == 0
- && pattern.lastIndexOf(QLatin1Char('.')) == 1
+ return pattern.lastIndexOf(u'*') == 0
+ && pattern.lastIndexOf(u'.') == 1
// and contains no other special character
- && !pattern.contains(QLatin1Char('?'))
- && !pattern.contains(QLatin1Char('['))
+ && !pattern.contains(u'?')
+ && !pattern.contains(u'[')
;
}
@@ -276,14 +278,14 @@ void QMimeAllGlobPatterns::matchingGlobs(const QString &fileName, QMimeGlobMatch
// Now use the "fast patterns" dict, for simple *.foo patterns with weight 50
// (which is most of them, so this optimization is definitely worth it)
- const int lastDot = fileName.lastIndexOf(QLatin1Char('.'));
+ const int lastDot = fileName.lastIndexOf(u'.');
if (lastDot != -1) { // if no '.', skip the extension lookup
const int ext_len = fileName.length() - lastDot - 1;
const QString simpleExtension = fileName.right(ext_len).toLower();
// (toLower because fast patterns are always case-insensitive and saved as lowercase)
const QStringList matchingMimeTypes = m_fastPatterns.value(simpleExtension);
- const QString simplePattern = QLatin1String("*.") + simpleExtension;
+ const QString simplePattern = "*."_L1 + simpleExtension;
for (const QString &mime : matchingMimeTypes)
result.addMatch(mime, 50, simplePattern, simpleExtension.size());
// Can't return yet; *.tar.bz2 has to win over *.bz2, so we need the low-weight mimetypes anyway,
diff --git a/src/corelib/mimetypes/qmimemagicrule.cpp b/src/corelib/mimetypes/qmimemagicrule.cpp
index 3cf5ba2d7f..13e60739e0 100644
--- a/src/corelib/mimetypes/qmimemagicrule.cpp
+++ b/src/corelib/mimetypes/qmimemagicrule.cpp
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// in the same order as Type!
static const char magicRuleTypes_string[] =
"invalid\0"
@@ -234,12 +236,12 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
{
if (Q_UNLIKELY(m_type == Invalid)) {
if (errorString)
- *errorString = QLatin1String("Type ") + type + QLatin1String(" is not supported");
+ *errorString = "Type "_L1 + type + " is not supported"_L1;
return;
}
// Parse for offset as "1" or "1:10"
- const int colonIndex = offsets.indexOf(QLatin1Char(':'));
+ const int colonIndex = offsets.indexOf(u':');
const QStringView startPosStr = QStringView{offsets}.mid(0, colonIndex); // \ These decay to returning 'offsets'
const QStringView endPosStr = QStringView{offsets}.mid(colonIndex + 1);// / unchanged when colonIndex == -1
if (Q_UNLIKELY(!QMimeTypeParserBase::parseNumber(startPosStr, &m_startPos, errorString)) ||
@@ -261,7 +263,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (Q_UNLIKELY(!ok)) {
m_type = Invalid;
if (errorString)
- *errorString = QLatin1String("Invalid magic rule value \"") + QLatin1String(m_value) + QLatin1Char('"');
+ *errorString = "Invalid magic rule value \""_L1 + QLatin1String(m_value) + u'"';
return;
}
m_numberMask = !m_mask.isEmpty() ? m_mask.toUInt(&ok, 0) : 0; // autodetect base
@@ -275,7 +277,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (Q_UNLIKELY(m_mask.size() < 4 || !m_mask.startsWith("0x"))) {
m_type = Invalid;
if (errorString)
- *errorString = QLatin1String("Invalid magic rule mask \"") + QLatin1String(m_mask) + QLatin1Char('"');
+ *errorString = "Invalid magic rule mask \""_L1 + QLatin1String(m_mask) + u'"';
return;
}
const QByteArray &tempMask = QByteArray::fromHex(QByteArray::fromRawData(
@@ -283,7 +285,7 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
if (Q_UNLIKELY(tempMask.size() != m_pattern.size())) {
m_type = Invalid;
if (errorString)
- *errorString = QLatin1String("Invalid magic rule mask size \"") + QLatin1String(m_mask) + QLatin1Char('"');
+ *errorString = "Invalid magic rule mask size \""_L1 + QLatin1String(m_mask) + u'"';
return;
}
m_mask = tempMask;
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index 6aa59e56f4..951ad2ca49 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -85,6 +85,8 @@ __attribute__((section(".qtmimedatabase"), aligned(4096)))
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
QMimeProviderBase::QMimeProviderBase(QMimeDatabasePrivate *db, const QString &directory)
: m_db(db), m_directory(directory)
{
@@ -201,7 +203,7 @@ bool QMimeBinaryProvider::checkCacheChanged()
void QMimeBinaryProvider::ensureLoaded()
{
if (!m_cacheFile) {
- const QString cacheFileName = m_directory + QLatin1String("/mime.cache");
+ const QString cacheFileName = m_directory + "/mime.cache"_L1;
m_cacheFile = new CacheFile(cacheFileName);
m_mimetypeListLoaded = false;
m_mimetypeExtra.clear();
@@ -317,7 +319,8 @@ bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBin
const bool caseSensitive = flagsAndWeight & 0x100;
if (caseSensitiveCheck || !caseSensitive) {
result.addMatch(QLatin1String(mimeType), weight,
- QLatin1Char('*') + QStringView{fileName}.mid(charPos + 1), fileName.size() - charPos - 2);
+ u'*' + QStringView{fileName}.mid(charPos + 1),
+ fileName.size() - charPos - 2);
success = true;
}
}
@@ -507,9 +510,9 @@ bool QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
// load comment and globPatterns
// shared-mime-info since 1.3 lowercases the xml files
- QString mimeFile = m_directory + QLatin1Char('/') + data.name.toLower() + QLatin1String(".xml");
+ QString mimeFile = m_directory + u'/' + data.name.toLower() + ".xml"_L1;
if (!QFile::exists(mimeFile))
- mimeFile = m_directory + QLatin1Char('/') + data.name + QLatin1String(".xml"); // pre-1.3
+ mimeFile = m_directory + u'/' + data.name + ".xml"_L1; // pre-1.3
QFile qfile(mimeFile);
if (!qfile.open(QFile::ReadOnly))
@@ -522,10 +525,10 @@ bool QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
QXmlStreamReader xml(&qfile);
if (xml.readNextStartElement()) {
- if (xml.name() != QLatin1String("mime-type")) {
+ if (xml.name() != "mime-type"_L1) {
return false;
}
- const auto name = xml.attributes().value(QLatin1String("type"));
+ const auto name = xml.attributes().value("type"_L1);
if (name.isEmpty())
return false;
if (name.compare(data.name, Qt::CaseInsensitive))
@@ -533,20 +536,20 @@ bool QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
while (xml.readNextStartElement()) {
const auto tag = xml.name();
- if (tag == QLatin1String("comment")) {
- QString lang = xml.attributes().value(QLatin1String("xml:lang")).toString();
+ if (tag == "comment"_L1) {
+ QString lang = xml.attributes().value("xml:lang"_L1).toString();
const QString text = xml.readElementText();
if (lang.isEmpty()) {
- lang = QLatin1String("default"); // no locale attribute provided, treat it as default.
+ lang = "default"_L1; // no locale attribute provided, treat it as default.
}
extra.localeComments.insert(lang, text);
continue; // we called readElementText, so we're at the EndElement already.
- } else if (tag == QLatin1String("glob-deleteall")) { // as written out by shared-mime-info >= 0.70
+ } else if (tag == "glob-deleteall"_L1) { // as written out by shared-mime-info >= 0.70
extra.globPatterns.clear();
mainPattern.clear();
- } else if (tag == QLatin1String("glob")) { // as written out by shared-mime-info >= 0.70
- const QString pattern = xml.attributes().value(QLatin1String("pattern")).toString();
- if (mainPattern.isEmpty() && pattern.startsWith(QLatin1Char('*'))) {
+ } else if (tag == "glob"_L1) { // as written out by shared-mime-info >= 0.70
+ const QString pattern = xml.attributes().value("pattern"_L1).toString();
+ if (mainPattern.isEmpty() && pattern.startsWith(u'*')) {
mainPattern = pattern;
}
if (!extra.globPatterns.contains(pattern))
@@ -554,7 +557,7 @@ bool QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
}
xml.skipCurrentElement();
}
- Q_ASSERT(xml.name() == QLatin1String("mime-type"));
+ Q_ASSERT(xml.name() == "mime-type"_L1);
}
// Let's assume that shared-mime-info is at least version 0.70
@@ -734,7 +737,7 @@ void QMimeXMLProvider::ensureLoaded()
const QStringList files = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
allFiles.reserve(files.count());
for (const QString &xmlFile : files)
- allFiles.append(packageDir + QLatin1Char('/') + xmlFile);
+ allFiles.append(packageDir + u'/' + xmlFile);
if (m_allFiles == allFiles)
return;
@@ -764,7 +767,7 @@ bool QMimeXMLProvider::load(const QString &fileName, QString *errorMessage)
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
if (errorMessage)
- *errorMessage = QLatin1String("Cannot open ") + fileName + QLatin1String(": ") + file.errorString();
+ *errorMessage = "Cannot open "_L1 + fileName + ": "_L1 + file.errorString();
return false;
}
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index 4308665730..746776fdf2 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -54,6 +54,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
QMimeTypePrivate::QMimeTypePrivate()
: loaded(false), fromCache(false)
{}
@@ -258,13 +260,13 @@ QString QMimeType::comment() const
QStringList languageList;
languageList << QLocale().name();
languageList << QLocale().uiLanguages();
- languageList << QLatin1String("default"); // use the default locale if possible.
+ languageList << u"default"_qs; // use the default locale if possible.
for (const QString &language : qAsConst(languageList)) {
- const QString lang = language == QLatin1String("C") ? QLatin1String("en_US") : language;
+ const QString lang = language == "C"_L1 ? u"en_US"_qs : language;
const QString comm = d->localeComments.value(lang);
if (!comm.isEmpty())
return comm;
- const int pos = lang.indexOf(QLatin1Char('_'));
+ const int pos = lang.indexOf(u'_');
if (pos != -1) {
// "pt_BR" not found? try just "pt"
const QString shortLang = lang.left(pos);
@@ -303,19 +305,19 @@ QString QMimeType::genericIconName() const
// (i.e. "video-x-generic" in the previous example).
const QString group = name();
QStringView groupRef(group);
- const int slashindex = groupRef.indexOf(QLatin1Char('/'));
+ const int slashindex = groupRef.indexOf(u'/');
if (slashindex != -1)
groupRef = groupRef.left(slashindex);
- return groupRef + QLatin1String("-x-generic");
+ return groupRef + "-x-generic"_L1;
}
return d->genericIconName;
}
static QString make_default_icon_name_from_mimetype_name(QString iconName)
{
- const int slashindex = iconName.indexOf(QLatin1Char('/'));
+ const int slashindex = iconName.indexOf(u'/');
if (slashindex != -1)
- iconName[slashindex] = QLatin1Char('-');
+ iconName[slashindex] = u'-';
return iconName;
}
@@ -446,9 +448,9 @@ QStringList QMimeType::suffixes() const
QStringList result;
for (const QString &pattern : qAsConst(d->globPatterns)) {
// Not a simple suffix if it looks like: README or *. or *.* or *.JP*G or *.JP?
- if (pattern.startsWith(QLatin1String("*.")) &&
+ if (pattern.startsWith("*."_L1) &&
pattern.length() > 2 &&
- pattern.indexOf(QLatin1Char('*'), 2) < 0 && pattern.indexOf(QLatin1Char('?'), 2) < 0) {
+ pattern.indexOf(u'*', 2) < 0 && pattern.indexOf(u'?', 2) < 0) {
const QString suffix = pattern.mid(2);
result.append(suffix);
}
@@ -488,13 +490,13 @@ QString QMimeType::filterString() const
QString filter;
if (!d->globPatterns.empty()) {
- filter += comment() + QLatin1String(" (");
+ filter += comment() + " ("_L1;
for (int i = 0; i < d->globPatterns.size(); ++i) {
if (i != 0)
- filter += QLatin1Char(' ');
+ filter += u' ';
filter += d->globPatterns.at(i);
}
- filter += QLatin1Char(')');
+ filter += u')';
}
return filter;
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index ff9936d335..af96d9b2d7 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// XML tags in MIME files
static const char mimeInfoTagC[] = "mime-info";
static const char mimeTypeTagC[] = "mime-type";
@@ -167,7 +169,7 @@ bool QMimeTypeParserBase::parseNumber(QStringView n, int *target, QString *error
*target = n.toInt(&ok);
if (Q_UNLIKELY(!ok)) {
if (errorMessage)
- *errorMessage = QLatin1String("Not a number '") + n + QLatin1String("'.");
+ *errorMessage = "Not a number '"_L1 + n + "'."_L1;
return false;
}
return true;
@@ -235,7 +237,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
case ParseGlobPattern: {
const QString pattern = atts.value(QLatin1String(patternAttributeC)).toString();
unsigned weight = atts.value(QLatin1String(weightAttributeC)).toInt();
- const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)) == QLatin1String("true");
+ const bool caseSensitive = atts.value(QLatin1String(caseSensitiveAttributeC)) == "true"_L1;
if (weight == 0)
weight = QMimeGlobPattern::DefaultWeight;
@@ -299,7 +301,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
break;
}
case ParseError:
- reader.raiseError(QLatin1String("Unexpected element <") + reader.name() + QLatin1Char('>'));
+ reader.raiseError("Unexpected element <"_L1 + reader.name() + u'>');
break;
default:
break;
diff --git a/src/corelib/plugin/qcoffpeparser.cpp b/src/corelib/plugin/qcoffpeparser.cpp
index 15d1f64426..1ebca08c32 100644
--- a/src/corelib/plugin/qcoffpeparser.cpp
+++ b/src/corelib/plugin/qcoffpeparser.cpp
@@ -49,14 +49,15 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// Whether we include some extra validity checks
// (checks to ensure we don't read out-of-bounds are always included)
static constexpr bool IncludeValidityChecks = true;
-static constexpr char rawSectionName[] = ".qtmetadata";
-static constexpr QLatin1String metadataSectionName(rawSectionName, sizeof(rawSectionName) - 1);
+static constexpr inline auto metadataSectionName() noexcept { return ".qtmetadata"_L1; }
static constexpr QLatin1String truncatedSectionName =
- metadataSectionName.left(sizeof(IMAGE_SECTION_HEADER::Name));
+ metadataSectionName().left(sizeof(IMAGE_SECTION_HEADER::Name));
#ifdef QT_BUILD_INTERNAL
# define QCOFFPEPARSER_DEBUG
@@ -389,7 +390,7 @@ QLibraryScanResult QCoffPeParser::parse(QByteArrayView data, QString *errMsg)
continue;
// if we do have a string table, the name may be complete
- if (sectionName != truncatedSectionName && sectionName != metadataSectionName)
+ if (sectionName != truncatedSectionName && sectionName != metadataSectionName())
continue;
peDebug << "found .qtmetadata section";
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index c6ccda92fb..f51b6915bc 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -58,6 +58,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// ### Qt7: propagate the constant and eliminate dead code
static constexpr bool ElfNotesAreMandatory = QT_VERSION >= QT_VERSION_CHECK(7,0,0);
@@ -717,7 +719,7 @@ static QLibraryScanResult scanSections(QByteArrayView data, const ErrorMaker &er
return error(QLibrary::tr("section contents extend past the end of the file"));
}
- if (name != QLatin1String(".qtmetadata"))
+ if (name != ".qtmetadata"_L1)
continue;
qEDebug << "found .qtmetadata section";
if (shdr->sh_size < sizeof(QPluginMetaData::MagicHeader))
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 8fa510aaea..97cc04e645 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -70,6 +70,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
bool QPluginParsedMetaData::parse(QByteArrayView raw)
{
QPluginMetaData::Header header;
@@ -187,14 +189,14 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
#if defined(Q_OS_WIN)
QStringList(QStringLiteral("*.dll")),
#elif defined(Q_OS_ANDROID)
- QStringList(QLatin1String("libplugins_%1_*.so").arg(suffix)),
+ QStringList("libplugins_%1_*.so"_L1.arg(suffix)),
#endif
QDir::Files);
while (plugins.hasNext()) {
QString fileName = plugins.next();
#ifdef Q_OS_MAC
- const bool isDebugPlugin = fileName.endsWith(QLatin1String("_debug.dylib"));
+ const bool isDebugPlugin = fileName.endsWith("_debug.dylib"_L1);
const bool isDebugLibrary =
#ifdef QT_DEBUG
true;
@@ -207,7 +209,7 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
if (isDebugPlugin != isDebugLibrary)
continue;
#elif defined(Q_PROCESSOR_X86)
- if (fileName.endsWith(QLatin1String(".avx2")) || fileName.endsWith(QLatin1String(".avx512"))) {
+ if (fileName.endsWith(".avx2"_L1) || fileName.endsWith(".avx512"_L1)) {
// ignore AVX2-optimized file, we'll do a bait-and-switch to it later
continue;
}
@@ -232,7 +234,7 @@ inline void QFactoryLoaderPrivate::updateSinglePath(const QString &path)
QCborMap object = library->metaData.value(QtPluginMetaDataKeys::MetaData).toMap();
metaDataOk = true;
- const QCborArray k = object.value(QLatin1String("Keys")).toArray();
+ const QCborArray k = object.value("Keys"_L1).toArray();
for (QCborValueConstRef v : k)
keys += cs ? v.toString() : v.toString().toLower();
}
@@ -332,7 +334,7 @@ QFactoryLoader::QFactoryLoader(const char *iid,
d->cs = cs;
d->suffix = suffix;
# ifdef Q_OS_ANDROID
- if (!d->suffix.isEmpty() && d->suffix.at(0) == QLatin1Char('/'))
+ if (!d->suffix.isEmpty() && d->suffix.at(0) == u'/')
d->suffix.remove(0, 1);
# endif
@@ -434,7 +436,7 @@ QMultiMap<int, QString> QFactoryLoader::keyMap() const
const QList<QPluginParsedMetaData> metaDataList = metaData();
for (int i = 0; i < metaDataList.size(); ++i) {
const QCborMap metaData = metaDataList.at(i).value(QtPluginMetaDataKeys::MetaData).toMap();
- const QCborArray keys = metaData.value(QLatin1String("Keys")).toArray();
+ const QCborArray keys = metaData.value("Keys"_L1).toArray();
for (QCborValueConstRef key : keys)
result.insert(i, key.toString());
}
@@ -446,7 +448,7 @@ int QFactoryLoader::indexOf(const QString &needle) const
const QList<QPluginParsedMetaData> metaDataList = metaData();
for (int i = 0; i < metaDataList.size(); ++i) {
const QCborMap metaData = metaDataList.at(i).value(QtPluginMetaDataKeys::MetaData).toMap();
- const QCborArray keys = metaData.value(QLatin1String("Keys")).toArray();
+ const QCborArray keys = metaData.value("Keys"_L1).toArray();
for (QCborValueConstRef key : keys) {
if (key.toString().compare(needle, Qt::CaseInsensitive) == 0)
return i;
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index fbeddf0bb0..1fdc05afeb 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -68,6 +68,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// On Unix systema and on Windows with MinGW, we can mix and match debug and
// release plugins without problems. (unless compiled in debug-and-release mode
// - why?)
@@ -628,11 +630,11 @@ QtPluginInstanceFunction QLibraryPrivate::loadPlugin()
bool QLibrary::isLibrary(const QString &fileName)
{
#if defined(Q_OS_WIN)
- return fileName.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive);
+ return fileName.endsWith(".dll"_L1, Qt::CaseInsensitive);
#else // Generic Unix
# if defined(Q_OS_DARWIN)
// On Apple platforms, dylib look like libmylib.1.0.0.dylib
- if (fileName.endsWith(QLatin1String(".dylib")))
+ if (fileName.endsWith(".dylib"_L1))
return true;
# endif
QString completeSuffix = QFileInfo(fileName).completeSuffix();
@@ -647,18 +649,18 @@ bool QLibrary::isLibrary(const QString &fileName)
"In PA-RISC (PA-32 and PA-64) shared libraries are suffixed with .sl. In IPF (32-bit and 64-bit),
the shared libraries are suffixed with .so. For compatibility, the IPF linker also supports the .sl suffix."
*/
- QLatin1String("sl"),
+ "sl"_L1,
# if defined __ia64
- QLatin1String("so"),
+ "so"_L1,
# endif
# elif defined(Q_OS_AIX)
- QLatin1String("a"),
- QLatin1String("so"),
+ "a"_L1,
+ "so"_L1,
# elif defined(Q_OS_DARWIN)
- QLatin1String("so"),
- QLatin1String("bundle"),
+ "so"_L1,
+ "bundle"_L1,
# elif defined(Q_OS_UNIX)
- QLatin1String("so"),
+ "so"_L1,
# endif
}; // candidates
@@ -741,7 +743,7 @@ void QLibraryPrivate::updatePluginState()
bool success = false;
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
- if (fileName.endsWith(QLatin1String(".debug"))) {
+ if (fileName.endsWith(".debug"_L1)) {
// refuse to load a file that ends in .debug
// these are the debug symbols from the libraries
// the problem is that they are valid shared library files
@@ -789,7 +791,7 @@ void QLibraryPrivate::updatePluginState()
QString::number((qt_version & 0xff0000) >> 16),
QString::number((qt_version & 0xff00) >> 8),
QString::number(qt_version & 0xff),
- debug ? QLatin1String("debug") : QLatin1String("release"));
+ debug ? "debug"_L1 : "release"_L1);
} else if (PluginMustMatchQtDebug && debug != QtBuildIsDebug) {
//don't issue a qWarning since we will hopefully find a non-debug? --Sam
errorString = QLibrary::tr("The plugin '%1' uses incompatible Qt library."
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index 17248c8b3f..1fcc22c8cc 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -59,10 +59,12 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static QString qdlerror()
{
const char *err = dlerror();
- return err ? QLatin1Char('(') + QString::fromLocal8Bit(err) + QLatin1Char(')') : QString();
+ return err ? u'(' + QString::fromLocal8Bit(err) + u')' : QString();
}
QStringList QLibraryPrivate::suffixes_sys(const QString &fullVersion)
@@ -82,25 +84,25 @@ QStringList QLibraryPrivate::suffixes_sys(const QString &fullVersion)
// .so is preferred.
# if defined(__ia64)
if (!fullVersion.isEmpty()) {
- suffixes << QLatin1String(".so.%1").arg(fullVersion);
+ suffixes << ".so.%1"_L1.arg(fullVersion);
} else {
- suffixes << QLatin1String(".so");
+ suffixes << ".so"_L1;
}
# endif
if (!fullVersion.isEmpty()) {
- suffixes << QLatin1String(".sl.%1").arg(fullVersion);
- suffixes << QLatin1String(".%1").arg(fullVersion);
+ suffixes << ".sl.%1"_L1.arg(fullVersion);
+ suffixes << ".%1"_L1.arg(fullVersion);
} else {
- suffixes << QLatin1String(".sl");
+ suffixes << ".sl"_L1;
}
#elif defined(Q_OS_AIX)
suffixes << ".a";
#else
if (!fullVersion.isEmpty()) {
- suffixes << QLatin1String(".so.%1").arg(fullVersion);
+ suffixes << ".so.%1"_L1.arg(fullVersion);
} else {
- suffixes << QLatin1String(".so");
+ suffixes << ".so"_L1;
# ifdef Q_OS_ANDROID
suffixes << QStringLiteral(LIBS_SUFFIX);
# endif
@@ -108,10 +110,10 @@ QStringList QLibraryPrivate::suffixes_sys(const QString &fullVersion)
#endif
# ifdef Q_OS_MAC
if (!fullVersion.isEmpty()) {
- suffixes << QLatin1String(".%1.bundle").arg(fullVersion);
- suffixes << QLatin1String(".%1.dylib").arg(fullVersion);
+ suffixes << ".%1.bundle"_L1.arg(fullVersion);
+ suffixes << ".%1.dylib"_L1.arg(fullVersion);
} else {
- suffixes << QLatin1String(".bundle") << QLatin1String(".dylib");
+ suffixes << ".bundle"_L1 << ".dylib"_L1;
}
#endif
return suffixes;
@@ -119,7 +121,7 @@ QStringList QLibraryPrivate::suffixes_sys(const QString &fullVersion)
QStringList QLibraryPrivate::prefixes_sys()
{
- return QStringList() << QLatin1String("lib");
+ return QStringList() << "lib"_L1;
}
bool QLibraryPrivate::load_sys()
@@ -130,10 +132,10 @@ bool QLibraryPrivate::load_sys()
QString path = fsEntry.path();
QString name = fsEntry.fileName();
- if (path == QLatin1String(".") && !fileName.startsWith(path))
+ if (path == "."_L1 && !fileName.startsWith(path))
path.clear();
else
- path += QLatin1Char('/');
+ path += u'/';
QStringList suffixes;
QStringList prefixes;
@@ -207,10 +209,10 @@ bool QLibraryPrivate::load_sys()
};
if (pluginState == IsAPlugin) {
// add ".avx2" to each suffix in the list
- transform(suffixes, [](QString *s) { s->append(QLatin1String(".avx2")); });
+ transform(suffixes, [](QString *s) { s->append(".avx2"_L1); });
} else {
// prepend "haswell/" to each prefix in the list
- transform(prefixes, [](QString *s) { s->prepend(QLatin1String("haswell/")); });
+ transform(prefixes, [](QString *s) { s->prepend("haswell/"_L1); });
}
}
#endif
@@ -222,13 +224,13 @@ bool QLibraryPrivate::load_sys()
for (int suffix = 0; retry && !hnd && suffix < suffixes.size(); suffix++) {
if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix)))
continue;
- if (path.isEmpty() && prefixes.at(prefix).contains(QLatin1Char('/')))
+ if (path.isEmpty() && prefixes.at(prefix).contains(u'/'))
continue;
if (!suffixes.at(suffix).isEmpty() && name.endsWith(suffixes.at(suffix)))
continue;
if (loadHints & QLibrary::LoadArchiveMemberHint) {
attempt = name;
- int lparen = attempt.indexOf(QLatin1Char('('));
+ int lparen = attempt.indexOf(u'(');
if (lparen == -1)
lparen = attempt.size();
attempt = path + prefixes.at(prefix) + attempt.insert(lparen, suffixes.at(suffix));
@@ -240,7 +242,7 @@ bool QLibraryPrivate::load_sys()
#ifdef Q_OS_ANDROID
if (!hnd) {
auto attemptFromBundle = attempt;
- hnd = dlopen(QFile::encodeName(attemptFromBundle.replace(QLatin1Char('/'), QLatin1Char('_'))), dlFlags);
+ hnd = dlopen(QFile::encodeName(attemptFromBundle.replace(u'/', u'_')), dlFlags);
}
if (hnd) {
using JniOnLoadPtr = jint (*)(JavaVM *vm, void *reserved);
@@ -252,7 +254,7 @@ bool QLibraryPrivate::load_sys()
}
#endif
- if (!hnd && fileName.startsWith(QLatin1Char('/')) && QFile::exists(attempt)) {
+ if (!hnd && fileName.startsWith(u'/') && QFile::exists(attempt)) {
// We only want to continue if dlopen failed due to that the shared library did not exist.
// However, we are only able to apply this check for absolute filenames (since they are
// not influenced by the content of LD_LIBRARY_PATH, /etc/ld.so.cache, DT_RPATH etc...)
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index eab7255a7a..9e3a90002d 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -49,6 +49,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
extern QString qt_error_string(int code);
QStringList QLibraryPrivate::suffixes_sys(const QString& fullVersion)
@@ -81,7 +83,7 @@ bool QLibraryPrivate::load_sys()
QStringList attempts;
if (pluginState != IsAPlugin)
- attempts.append(fileName + QLatin1String(".dll"));
+ attempts.append(fileName + ".dll"_L1);
// If the fileName is an absolute path we try that first, otherwise we
// use the system-specific suffix first
@@ -115,9 +117,9 @@ bool QLibraryPrivate::load_sys()
::GetModuleFileName(hnd, buffer, MAX_PATH);
QString moduleFileName = QString::fromWCharArray(buffer);
- moduleFileName.remove(0, 1 + moduleFileName.lastIndexOf(QLatin1Char('\\')));
+ moduleFileName.remove(0, 1 + moduleFileName.lastIndexOf(u'\\'));
const QDir dir(fsEntry.path());
- if (dir.path() == QLatin1String("."))
+ if (dir.path() == "."_L1)
qualifiedFileName = moduleFileName;
else
qualifiedFileName = dir.filePath(moduleFileName);
diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp
index 310d8e06c3..f8545316fc 100644
--- a/src/corelib/plugin/qmachparser.cpp
+++ b/src/corelib/plugin/qmachparser.cpp
@@ -46,6 +46,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// Whether we include some extra validity checks
// (checks to ensure we don't read out-of-bounds are always included)
static constexpr bool IncludeValidityChecks = true;
@@ -143,7 +145,8 @@ QLibraryScanResult QMachOParser::parse(const char *m_s, ulong fdlen, QString *e
// check magic
if (header->magic != my_magic)
- return notfound(QLibrary::tr("invalid magic %1").arg(qFromBigEndian(header->magic), 8, 16, QLatin1Char('0')),
+ return notfound(QLibrary::tr("invalid magic %1").arg(qFromBigEndian(header->magic),
+ 8, 16, '0'_L1),
errorString);
}
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index eaca077c90..6dd5150539 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -53,6 +53,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if QT_CONFIG(library)
/*!
@@ -269,7 +271,7 @@ static QString locatePlugin(const QString& fileName)
suffixes.prepend(QString());
// Split up "subdir/filename"
- const int slash = fileName.lastIndexOf(QLatin1Char('/'));
+ const int slash = fileName.lastIndexOf(u'/');
const auto baseName = QStringView{fileName}.mid(slash + 1);
const auto basePath = isAbsolute ? QStringView() : QStringView{fileName}.left(slash + 1); // keep the '/'
@@ -286,13 +288,13 @@ static QString locatePlugin(const QString& fileName)
#ifdef Q_OS_ANDROID
{
QString pluginPath = basePath + prefix + baseName + suffix;
- const QString fn = path + QLatin1String("/lib") + pluginPath.replace(QLatin1Char('/'), QLatin1Char('_'));
+ const QString fn = path + "/lib"_L1 + pluginPath.replace(u'/', u'_');
qCDebug(qt_lcDebugPlugins) << "Trying..." << fn;
if (QFileInfo(fn).isFile())
return fn;
}
#endif
- const QString fn = path + QLatin1Char('/') + basePath + prefix + baseName + suffix;
+ const QString fn = path + u'/' + basePath + prefix + baseName + suffix;
qCDebug(qt_lcDebugPlugins) << "Trying..." << fn;
if (QFileInfo(fn).isFile())
return fn;
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index 593b0c3be7..956af50f5c 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -72,6 +72,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if !defined(QT_BOOTSTRAPPED)
extern QString qAppFileName();
#endif
@@ -101,16 +103,16 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
if (!onlySystemDirectory) {
const QString PATH(QLatin1String(qgetenv("PATH").constData()));
- searchOrder << PATH.split(QLatin1Char(';'), Qt::SkipEmptyParts);
+ searchOrder << PATH.split(u';', Qt::SkipEmptyParts);
}
QString fileName = QString::fromWCharArray(libraryName);
- fileName.append(QLatin1String(".dll"));
+ fileName.append(".dll"_L1);
// Start looking in the order specified
for (int i = 0; i < searchOrder.count(); ++i) {
QString fullPathAttempt = searchOrder.at(i);
- if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) {
- fullPathAttempt.append(QLatin1Char('\\'));
+ if (!fullPathAttempt.endsWith(u'\\')) {
+ fullPathAttempt.append(u'\\');
}
fullPathAttempt.append(fileName);
HINSTANCE inst = ::LoadLibrary(reinterpret_cast<const wchar_t *>(fullPathAttempt.utf16()));
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 7f7d537fe4..7d9bd65f8b 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -419,7 +419,7 @@ static QUuid uuidFromString(QStringView text) noexcept
static QUuid uuidFromString(QLatin1String text) noexcept
{
if (Q_UNLIKELY(text.size() < MaxStringUuidLength - 2
- || (text.front() == QLatin1Char('{') && text.size() < MaxStringUuidLength - 1))) {
+ || (text.front() == '{' && text.size() < MaxStringUuidLength - 1))) {
// 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.
text = QLatin1String();
diff --git a/src/corelib/serialization/qcbordiagnostic.cpp b/src/corelib/serialization/qcbordiagnostic.cpp
index b7d8f1ed6b..7950b2e524 100644
--- a/src/corelib/serialization/qcbordiagnostic.cpp
+++ b/src/corelib/serialization/qcbordiagnostic.cpp
@@ -49,6 +49,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace {
class DiagnosticNotation
{
@@ -86,7 +88,7 @@ private:
};
DiagnosticNotation(QCborValue::DiagnosticNotationOptions opts_)
- : separator(QLatin1String(opts_ & QCborValue::LineWrapped ? "\n" : "")), opts(opts_)
+ : separator(opts_ & QCborValue::LineWrapped ? "\n"_L1 : ""_L1), opts(opts_)
{
byteArrayFormatStack.push(int(QCborKnownTags::ExpectedBase16));
}
@@ -109,11 +111,11 @@ static QString makeFpString(double d)
} else if (convertDoubleTo(d, &v)) {
s = QString::fromLatin1("%1.0").arg(v);
if (d < 0)
- s.prepend(QLatin1Char('-'));
+ s.prepend(u'-');
} else {
s = QString::number(d, 'g', QLocale::FloatingPointShortest);
if (!s.contains(u'.') && !s.contains(u'e'))
- s += QLatin1Char('.');
+ s += u'.';
}
return s;
}
@@ -131,7 +133,7 @@ static bool isByteArrayEncodingTag(QCborTag tag)
void DiagnosticNotation::appendString(const QString &s)
{
- result += QLatin1Char('"');
+ result += u'"';
const QChar *begin = s.begin();
const QChar *end = s.end();
@@ -161,7 +163,7 @@ void DiagnosticNotation::appendString(const QString &s)
};
int buflen = 2;
QChar buf[10];
- buf[0] = QLatin1Char('\\');
+ buf[0] = u'\\';
buf[1] = QChar::Null;
char16_t uc = ptr->unicode();
@@ -203,12 +205,12 @@ void DiagnosticNotation::appendString(const QString &s)
begin = ptr + 1;
}
- result += QLatin1Char('"');
+ result += u'"';
}
void DiagnosticNotation::appendArray(const QCborArray &a)
{
- result += QLatin1Char('[');
+ result += u'[';
// length 2 (including the space) when not line wrapping
QLatin1String commaValue(", ", opts & QCborValue::LineWrapped ? 1 : 2);
@@ -222,12 +224,12 @@ void DiagnosticNotation::appendArray(const QCborArray &a)
}
}
- result += separator + QLatin1Char(']');
+ result += separator + u']';
}
void DiagnosticNotation::appendMap(const QCborMap &m)
{
- result += QLatin1Char('{');
+ result += u'{';
// length 2 (including the space) when not line wrapping
QLatin1String commaValue(", ", opts & QCborValue::LineWrapped ? 1 : 2);
@@ -238,12 +240,12 @@ void DiagnosticNotation::appendMap(const QCborMap &m)
result += comma + separator;
comma = commaValue;
appendValue(v.first);
- result += QLatin1String(": ");
+ result += ": "_L1;
appendValue(v.second);
}
}
- result += separator + QLatin1Char('}');
+ result += separator + u'}';
};
void DiagnosticNotation::appendValue(const QCborValue &v)
@@ -276,16 +278,16 @@ void DiagnosticNotation::appendValue(const QCborValue &v)
case QCborValue::Map:
return appendMap(v.toMap());
case QCborValue::False:
- result += QLatin1String("false");
+ result += "false"_L1;
return;
case QCborValue::True:
- result += QLatin1String("true");
+ result += "true"_L1;
return;
case QCborValue::Null:
- result += QLatin1String("null");
+ result += "null"_L1;
return;
case QCborValue::Undefined:
- result += QLatin1String("undefined");
+ result += "undefined"_L1;
return;
case QCborValue::Double:
result += makeFpString(v.toDouble());
@@ -305,9 +307,9 @@ void DiagnosticNotation::appendValue(const QCborValue &v)
bool byteArrayFormat = opts & QCborValue::ExtendedFormat && isByteArrayEncodingTag(v.tag());
if (byteArrayFormat)
byteArrayFormatStack.push(int(v.tag()));
- result += QString::number(quint64(v.tag())) + QLatin1Char('(');
+ result += QString::number(quint64(v.tag())) + u'(';
appendValue(v.taggedValue());
- result += QLatin1Char(')');
+ result += u')';
if (byteArrayFormat)
byteArrayFormatStack.pop();
} else {
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp
index 5e09d2ef28..e6ff337182 100644
--- a/src/corelib/serialization/qtextstream.cpp
+++ b/src/corelib/serialization/qtextstream.cpp
@@ -279,6 +279,8 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
//-------------------------------------------------------------------
/*!
@@ -310,7 +312,7 @@ void QTextStreamPrivate::Params::reset()
realNumberPrecision = 6;
integerBase = 0;
fieldWidth = 0;
- padChar = QLatin1Char(' ');
+ padChar = u' ';
fieldAlignment = QTextStream::AlignRight;
realNumberNotation = QTextStream::SmartNotation;
numberFlags = { };
@@ -415,7 +417,7 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
// remove all '\r\n' in the string.
if (readBuffer.size() > oldReadBufferSize && textModeEnabled) {
- QChar CR = QLatin1Char('\r');
+ QChar CR = u'\r';
QChar *writePtr = readBuffer.data() + oldReadBufferSize;
QChar *readPtr = readBuffer.data() + oldReadBufferSize;
QChar *endPtr = readBuffer.data() + readBuffer.size();
@@ -483,7 +485,7 @@ void QTextStreamPrivate::flushWriteBuffer()
bool textModeEnabled = device->isTextModeEnabled();
if (textModeEnabled) {
device->setTextModeEnabled(false);
- writeBuffer.replace(QLatin1Char('\n'), QLatin1String("\r\n"));
+ writeBuffer.replace(u'\n', "\r\n"_L1);
}
#endif
@@ -590,9 +592,9 @@ bool QTextStreamPrivate::scan(const QChar **ptr, int *length, int maxlen, TokenD
}
break;
case EndOfLine:
- if (ch == QLatin1Char('\n')) {
+ if (ch == u'\n') {
foundToken = true;
- delimSize = (lastChar == QLatin1Char('\r')) ? 2 : 1;
+ delimSize = (lastChar == u'\r') ? 2 : 1;
consumeDelimiter = true;
}
lastChar = ch;
@@ -614,7 +616,7 @@ bool QTextStreamPrivate::scan(const QChar **ptr, int *length, int maxlen, TokenD
// don't make it part of the line.
if (delimiter == EndOfLine && totalSize > 0 && !foundToken) {
if (((string && stringOffset + totalSize == string->size()) || (device && device->atEnd()))
- && lastChar == QLatin1Char('\r')) {
+ && lastChar == u'\r') {
consumeDelimiter = true;
++delimSize;
}
@@ -1646,7 +1648,7 @@ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong
QChar ch;
if (!getChar(&ch))
return npsInvalidPrefix;
- if (ch == QLatin1Char('0')) {
+ if (ch == u'0') {
QChar ch2;
if (!getChar(&ch2)) {
// Result is the number 0
@@ -1655,9 +1657,9 @@ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong
}
ch2 = ch2.toLower();
- if (ch2 == QLatin1Char('x')) {
+ if (ch2 == u'x') {
base = 16;
- } else if (ch2 == QLatin1Char('b')) {
+ } else if (ch2 == u'b') {
base = 2;
} else if (ch2.isDigit() && ch2.digitValue() >= 0 && ch2.digitValue() <= 7) {
base = 8;
@@ -1682,9 +1684,9 @@ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong
case 2: {
QChar pf1, pf2, dig;
// Parse prefix '0b'
- if (!getChar(&pf1) || pf1 != QLatin1Char('0'))
+ if (!getChar(&pf1) || pf1 != u'0')
return npsInvalidPrefix;
- if (!getChar(&pf2) || pf2.toLower() != QLatin1Char('b'))
+ if (!getChar(&pf2) || pf2.toLower() != u'b')
return npsInvalidPrefix;
// Parse digits
int ndigits = 0;
@@ -1710,7 +1712,7 @@ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong
case 8: {
QChar pf, dig;
// Parse prefix '0'
- if (!getChar(&pf) || pf != QLatin1Char('0'))
+ if (!getChar(&pf) || pf != u'0')
return npsInvalidPrefix;
// Parse digits
int ndigits = 0;
@@ -1773,9 +1775,9 @@ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong
case 16: {
QChar pf1, pf2, dig;
// Parse prefix ' 0x'
- if (!getChar(&pf1) || pf1 != QLatin1Char('0'))
+ if (!getChar(&pf1) || pf1 != u'0')
return npsInvalidPrefix;
- if (!getChar(&pf2) || pf2.toLower() != QLatin1Char('x'))
+ if (!getChar(&pf2) || pf2.toLower() != u'x')
return npsInvalidPrefix;
// Parse digits
int ndigits = 0;
@@ -2251,8 +2253,8 @@ void QTextStreamPrivate::putNumber(qulonglong number, bool negative)
// workaround for backward compatibility - in octal form with
// ShowBase flag set zero should be written as '00'
if (number == 0 && base == 8 && params.numberFlags & QTextStream::ShowBase
- && result == QLatin1String("0")) {
- result.prepend(QLatin1Char('0'));
+ && result == "0"_L1) {
+ result.prepend(u'0');
}
}
putString(result, true);
@@ -2844,7 +2846,7 @@ QTextStream &center(QTextStream &stream)
*/
QTextStream &endl(QTextStream &stream)
{
- return stream << QLatin1Char('\n') << Qt::flush;
+ return stream << '\n'_L1 << Qt::flush;
}
/*!
diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp
index ed9a3233d1..6361beb409 100644
--- a/src/corelib/serialization/qxmlstream.cpp
+++ b/src/corelib/serialization/qxmlstream.cpp
@@ -58,6 +58,7 @@
QT_BEGIN_NAMESPACE
using namespace QtPrivate;
+using namespace Qt::StringLiterals;
enum { StreamEOF = ~0U };
@@ -789,7 +790,7 @@ QXmlStreamReaderPrivate::QXmlStreamReaderPrivate(QXmlStreamReader *q)
init();
#define ADD_PREDEFINED(n, v) \
do { \
- Entity e = Entity::createLiteral(QLatin1String(n), QLatin1String(v)); \
+ Entity e = Entity::createLiteral(n##_L1, v##_L1); \
entityHash.insert(qToStringViewIgnoringNull(e.name), std::move(e)); \
} while (false)
ADD_PREDEFINED("lt", "<");
@@ -1156,7 +1157,7 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent()
case ' ':
case '\t':
if (normalizeLiterals)
- textBuffer += QLatin1Char(' ');
+ textBuffer += u' ';
else
textBuffer += QChar(c);
++n;
@@ -1238,7 +1239,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList()
if (c == 0) {
putString(textBuffer, pos);
textBuffer.resize(pos);
- } else if (c == '>' && textBuffer.at(textBuffer.size()-2) == QLatin1Char(']')) {
+ } else if (c == '>' && textBuffer.at(textBuffer.size() - 2) == u']') {
raiseWellFormedError(QXmlStream::tr("Sequence ']]>' not allowed in content."));
} else {
putChar(c);
@@ -1558,25 +1559,25 @@ void QXmlStreamReaderPrivate::resolveTag()
++i;
if (i != n)
continue;
- if (dtdAttribute.attributePrefix.isEmpty() && dtdAttribute.attributeName == QLatin1String("xmlns")) {
+ if (dtdAttribute.attributePrefix.isEmpty() && dtdAttribute.attributeName == "xmlns"_L1) {
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
namespaceDeclaration.prefix.clear();
const XmlStringRef ns(dtdAttribute.defaultValue);
- if (ns == QLatin1String("http://www.w3.org/2000/xmlns/") ||
- ns == QLatin1String("http://www.w3.org/XML/1998/namespace"))
+ if (ns == "http://www.w3.org/2000/xmlns/"_L1 ||
+ ns == "http://www.w3.org/XML/1998/namespace"_L1)
raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
else
namespaceDeclaration.namespaceUri = ns;
- } else if (dtdAttribute.attributePrefix == QLatin1String("xmlns")) {
+ } else if (dtdAttribute.attributePrefix == "xmlns"_L1) {
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
XmlStringRef namespacePrefix = dtdAttribute.attributeName;
XmlStringRef namespaceUri = dtdAttribute.defaultValue;
- if (((namespacePrefix == QLatin1String("xml"))
- ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
- || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
+ if (((namespacePrefix == "xml"_L1)
+ ^ (namespaceUri == "http://www.w3.org/XML/1998/namespace"_L1))
+ || namespaceUri == "http://www.w3.org/2000/xmlns/"_L1
|| namespaceUri.isEmpty()
- || namespacePrefix == QLatin1String("xmlns"))
+ || namespacePrefix == "xmlns"_L1)
raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
namespaceDeclaration.prefix = namespacePrefix;
@@ -1751,8 +1752,8 @@ bool QXmlStreamReaderPrivate::checkStartDocument()
void QXmlStreamReaderPrivate::startDocument()
{
QString err;
- if (documentVersion != QLatin1String("1.0")) {
- if (documentVersion.view().contains(QLatin1Char(' ')))
+ if (documentVersion != "1.0"_L1) {
+ if (documentVersion.view().contains(u' '))
err = QXmlStream::tr("Invalid XML version string.");
else
err = QXmlStream::tr("Unsupported XML version.");
@@ -1771,7 +1772,7 @@ void QXmlStreamReaderPrivate::startDocument()
XmlStringRef key(symString(attrib.key));
XmlStringRef value(symString(attrib.value));
- if (prefix.isEmpty() && key == QLatin1String("encoding")) {
+ if (prefix.isEmpty() && key == "encoding"_L1) {
documentEncoding = value;
if (hasStandalone)
@@ -1789,11 +1790,11 @@ void QXmlStreamReaderPrivate::startDocument()
}
}
}
- } else if (prefix.isEmpty() && key == QLatin1String("standalone")) {
+ } else if (prefix.isEmpty() && key == "standalone"_L1) {
hasStandalone = true;
- if (value == QLatin1String("yes"))
+ if (value == "yes"_L1)
standalone = true;
- else if (value == QLatin1String("no"))
+ else if (value == "no"_L1)
standalone = false;
else
err = QXmlStream::tr("Standalone accepts only yes or no.");
@@ -2294,7 +2295,7 @@ QXmlStreamAttribute::QXmlStreamAttribute(const QString &namespaceUri, const QStr
*/
QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QString &value)
{
- int colon = qualifiedName.indexOf(QLatin1Char(':'));
+ int colon = qualifiedName.indexOf(u':');
m_name = qualifiedName.mid(colon + 1);
m_qualifiedName = qualifiedName;
m_value = value;
@@ -2936,26 +2937,26 @@ void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespa
QChar c = s.at(i);
switch (c.unicode()) {
case '<':
- escaped.append(QLatin1String("&lt;"));
+ escaped.append("&lt;"_L1);
break;
case '>':
- escaped.append(QLatin1String("&gt;"));
+ escaped.append("&gt;"_L1);
break;
case '&':
- escaped.append(QLatin1String("&amp;"));
+ escaped.append("&amp;"_L1);
break;
case '\"':
- escaped.append(QLatin1String("&quot;"));
+ escaped.append("&quot;"_L1);
break;
case '\t':
if (escapeWhitespace)
- escaped.append(QLatin1String("&#9;"));
+ escaped.append("&#9;"_L1);
else
escaped += c;
break;
case '\n':
if (escapeWhitespace)
- escaped.append(QLatin1String("&#10;"));
+ escaped.append("&#10;"_L1);
else
escaped += c;
break;
@@ -2965,7 +2966,7 @@ void QXmlStreamWriterPrivate::writeEscaped(const QString &s, bool escapeWhitespa
break;
case '\r':
if (escapeWhitespace)
- escaped.append(QLatin1String("&#13;"));
+ escaped.append("&#13;"_L1);
else
escaped += c;
break;
@@ -3045,7 +3046,7 @@ QXmlStreamPrivateTagStack::NamespaceDeclaration &QXmlStreamWriterPrivate::findNa
QString s;
int n = ++namespacePrefixCount;
forever {
- s = QLatin1Char('n') + QString::number(n++);
+ s = u'n' + QString::number(n++);
qsizetype j = namespaceDeclarations.size() - 2;
while (j >= 0 && namespaceDeclarations.at(j).prefix != s)
--j;
@@ -3247,7 +3248,7 @@ void QXmlStreamWriter::writeAttribute(const QString &qualifiedName, const QStrin
{
Q_D(QXmlStreamWriter);
Q_ASSERT(d->inStartElement);
- Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
+ Q_ASSERT(qualifiedName.count(u':') <= 1);
d->write(" ");
d->write(qualifiedName);
d->write("=\"");
@@ -3267,7 +3268,7 @@ void QXmlStreamWriter::writeAttribute(const QString &namespaceUri, const QString
{
Q_D(QXmlStreamWriter);
Q_ASSERT(d->inStartElement);
- Q_ASSERT(!name.contains(QLatin1Char(':')));
+ Q_ASSERT(!name.contains(u':'));
QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->findNamespace(namespaceUri, true, true);
d->write(" ");
if (!namespaceDeclaration.prefix.isEmpty()) {
@@ -3332,7 +3333,7 @@ void QXmlStreamWriter::writeCDATA(const QString &text)
Q_D(QXmlStreamWriter);
d->finishStartElement();
QString copy(text);
- copy.replace(QLatin1String("]]>"), QLatin1String("]]]]><![CDATA[>"));
+ copy.replace("]]>"_L1, "]]]]><![CDATA[>"_L1);
d->write("<![CDATA[");
d->write(copy);
d->write("]]>");
@@ -3360,7 +3361,7 @@ void QXmlStreamWriter::writeCharacters(const QString &text)
void QXmlStreamWriter::writeComment(const QString &text)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(!text.contains(QLatin1String("--")) && !text.endsWith(QLatin1Char('-')));
+ Q_ASSERT(!text.contains("--"_L1) && !text.endsWith(u'-'));
if (!d->finishStartElement(false) && d->autoFormatting)
d->indent(d->tagStack.size());
d->write("<!--");
@@ -3393,7 +3394,7 @@ void QXmlStreamWriter::writeDTD(const QString &dtd)
void QXmlStreamWriter::writeEmptyElement(const QString &qualifiedName)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
+ Q_ASSERT(qualifiedName.count(u':') <= 1);
d->writeStartElement(QString(), qualifiedName);
d->inEmptyElement = true;
}
@@ -3409,7 +3410,7 @@ void QXmlStreamWriter::writeEmptyElement(const QString &qualifiedName)
void QXmlStreamWriter::writeEmptyElement(const QString &namespaceUri, const QString &name)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(!name.contains(QLatin1Char(':')));
+ Q_ASSERT(!name.contains(u':'));
d->writeStartElement(namespaceUri, name);
d->inEmptyElement = true;
}
@@ -3530,12 +3531,12 @@ void QXmlStreamWriter::writeEntityReference(const QString &name)
void QXmlStreamWriter::writeNamespace(const QString &namespaceUri, const QString &prefix)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(prefix != QLatin1String("xmlns"));
+ Q_ASSERT(prefix != "xmlns"_L1);
if (prefix.isEmpty()) {
d->findNamespace(namespaceUri, d->inStartElement);
} else {
- Q_ASSERT(!((prefix == QLatin1String("xml")) ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace"))));
- Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/"));
+ Q_ASSERT(!((prefix == "xml"_L1) ^ (namespaceUri == "http://www.w3.org/XML/1998/namespace"_L1)));
+ Q_ASSERT(namespaceUri != "http://www.w3.org/2000/xmlns/"_L1);
QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
namespaceDeclaration.prefix = d->addToStringStorage(prefix);
namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
@@ -3558,8 +3559,8 @@ void QXmlStreamWriter::writeNamespace(const QString &namespaceUri, const QString
void QXmlStreamWriter::writeDefaultNamespace(const QString &namespaceUri)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/XML/1998/namespace"));
- Q_ASSERT(namespaceUri != QLatin1String("http://www.w3.org/2000/xmlns/"));
+ Q_ASSERT(namespaceUri != "http://www.w3.org/XML/1998/namespace"_L1);
+ Q_ASSERT(namespaceUri != "http://www.w3.org/2000/xmlns/"_L1);
QXmlStreamWriterPrivate::NamespaceDeclaration &namespaceDeclaration = d->namespaceDeclarations.push();
namespaceDeclaration.prefix.clear();
namespaceDeclaration.namespaceUri = d->addToStringStorage(namespaceUri);
@@ -3575,7 +3576,7 @@ void QXmlStreamWriter::writeDefaultNamespace(const QString &namespaceUri)
void QXmlStreamWriter::writeProcessingInstruction(const QString &target, const QString &data)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(!data.contains(QLatin1String("?>")));
+ Q_ASSERT(!data.contains("?>"_L1));
if (!d->finishStartElement(false) && d->autoFormatting)
d->indent(d->tagStack.size());
d->write("<?");
@@ -3598,7 +3599,7 @@ void QXmlStreamWriter::writeProcessingInstruction(const QString &target, const Q
*/
void QXmlStreamWriter::writeStartDocument()
{
- writeStartDocument(QLatin1String("1.0"));
+ writeStartDocument("1.0"_L1);
}
@@ -3649,7 +3650,7 @@ void QXmlStreamWriter::writeStartDocument(const QString &version, bool standalon
void QXmlStreamWriter::writeStartElement(const QString &qualifiedName)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(qualifiedName.count(QLatin1Char(':')) <= 1);
+ Q_ASSERT(qualifiedName.count(u':') <= 1);
d->writeStartElement(QString(), qualifiedName);
}
@@ -3665,7 +3666,7 @@ void QXmlStreamWriter::writeStartElement(const QString &qualifiedName)
void QXmlStreamWriter::writeStartElement(const QString &namespaceUri, const QString &name)
{
Q_D(QXmlStreamWriter);
- Q_ASSERT(!name.contains(QLatin1Char(':')));
+ Q_ASSERT(!name.contains(u':'));
d->writeStartElement(namespaceUri, name);
}
diff --git a/src/corelib/serialization/qxmlstream.g b/src/corelib/serialization/qxmlstream.g
index 0051c6255b..9177818778 100644
--- a/src/corelib/serialization/qxmlstream.g
+++ b/src/corelib/serialization/qxmlstream.g
@@ -225,6 +225,8 @@ bool QXmlStreamReaderPrivate::parse()
{
// cleanup currently reported token
+ using namespace Qt::StringLiterals;
+
switch (type) {
case QXmlStreamReader::StartElement:
name.clear();
@@ -732,9 +734,9 @@ attdef ::= attdef_start att_type default_decl;
dtdAttribute.attributePrefix = addToStringStorage(symPrefix(1));
dtdAttribute.attributeName = addToStringStorage(symString(1));
dtdAttribute.attributeQualifiedName = addToStringStorage(symName(1));
- dtdAttribute.isNamespaceAttribute = (dtdAttribute.attributePrefix == QLatin1String("xmlns")
+ dtdAttribute.isNamespaceAttribute = (dtdAttribute.attributePrefix == "xmlns"_L1
|| (dtdAttribute.attributePrefix.isEmpty()
- && dtdAttribute.attributeName == QLatin1String("xmlns")));
+ && dtdAttribute.attributeName == "xmlns"_L1));
if (lastAttributeValue.isNull()) {
dtdAttribute.defaultValue.clear();
} else {
@@ -873,7 +875,7 @@ processing_instruction ::= LANGLE QUESTIONMARK name space;
processingInstructionTarget = symString(3);
if (scanUntil("?>")) {
processingInstructionData = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 2);
- if (!processingInstructionTarget.view().compare(QLatin1String("xml"), Qt::CaseInsensitive)) {
+ if (!processingInstructionTarget.view().compare("xml"_L1, Qt::CaseInsensitive)) {
raiseWellFormedError(QXmlStream::tr("XML declaration not at start of document."));
}
else if (!QXmlUtils::isNCName(processingInstructionTarget))
@@ -891,7 +893,7 @@ processing_instruction ::= LANGLE QUESTIONMARK name QUESTIONMARK RANGLE;
case $rule_number:
setType(QXmlStreamReader::ProcessingInstruction);
processingInstructionTarget = symString(3);
- if (!processingInstructionTarget.view().compare(QLatin1String("xml"), Qt::CaseInsensitive))
+ if (!processingInstructionTarget.view().compare("xml"_L1, Qt::CaseInsensitive))
raiseWellFormedError(QXmlStream::tr("Invalid processing instruction name."));
break;
./
@@ -1184,13 +1186,13 @@ attribute ::= qname space_opt EQ space_opt attribute_value;
/.
case $rule_number: {
XmlStringRef prefix = symPrefix(1);
- if (prefix.isEmpty() && symString(1) == QLatin1String("xmlns") && namespaceProcessing) {
+ if (prefix.isEmpty() && symString(1) == "xmlns"_L1 && namespaceProcessing) {
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
namespaceDeclaration.prefix.clear();
const XmlStringRef ns(symString(5));
- if (ns.view() == QLatin1String("http://www.w3.org/2000/xmlns/") ||
- ns.view() == QLatin1String("http://www.w3.org/XML/1998/namespace"))
+ if (ns.view() == "http://www.w3.org/2000/xmlns/"_L1 ||
+ ns.view() == "http://www.w3.org/XML/1998/namespace"_L1)
raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
else
namespaceDeclaration.namespaceUri = addToStringStorage(ns);
@@ -1234,16 +1236,16 @@ attribute ::= qname space_opt EQ space_opt attribute_value;
attribute.value.pos = pos;
attribute.value.len = n;
}
- if (prefix == QLatin1String("xmlns") && namespaceProcessing) {
+ if (prefix == "xmlns"_L1 && namespaceProcessing) {
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
XmlStringRef namespacePrefix = symString(attribute.key);
XmlStringRef namespaceUri = symString(attribute.value);
attributeStack.pop();
- if (((namespacePrefix == QLatin1String("xml"))
- ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
- || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
+ if (((namespacePrefix == "xml"_L1)
+ ^ (namespaceUri == "http://www.w3.org/XML/1998/namespace"_L1))
+ || namespaceUri == "http://www.w3.org/2000/xmlns/"_L1
|| namespaceUri.isEmpty()
- || namespacePrefix == QLatin1String("xmlns"))
+ || namespacePrefix == "xmlns"_L1)
raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
namespaceDeclaration.prefix = addToStringStorage(namespacePrefix);
diff --git a/src/corelib/serialization/qxmlstreamparser_p.h b/src/corelib/serialization/qxmlstreamparser_p.h
index d568f9d024..9a46bdedac 100644
--- a/src/corelib/serialization/qxmlstreamparser_p.h
+++ b/src/corelib/serialization/qxmlstreamparser_p.h
@@ -80,6 +80,8 @@ bool QXmlStreamReaderPrivate::parse()
{
// cleanup currently reported token
+ using namespace Qt::StringLiterals;
+
switch (type) {
case QXmlStreamReader::StartElement:
name.clear();
@@ -467,9 +469,9 @@ bool QXmlStreamReaderPrivate::parse()
dtdAttribute.attributePrefix = addToStringStorage(symPrefix(1));
dtdAttribute.attributeName = addToStringStorage(symString(1));
dtdAttribute.attributeQualifiedName = addToStringStorage(symName(1));
- dtdAttribute.isNamespaceAttribute = (dtdAttribute.attributePrefix == QLatin1String("xmlns")
+ dtdAttribute.isNamespaceAttribute = (dtdAttribute.attributePrefix == "xmlns"_L1
|| (dtdAttribute.attributePrefix.isEmpty()
- && dtdAttribute.attributeName == QLatin1String("xmlns")));
+ && dtdAttribute.attributeName == "xmlns"_L1));
if (lastAttributeValue.isNull()) {
dtdAttribute.defaultValue.clear();
} else {
@@ -576,7 +578,7 @@ bool QXmlStreamReaderPrivate::parse()
processingInstructionTarget = symString(3);
if (scanUntil("?>")) {
processingInstructionData = XmlStringRef(&textBuffer, pos, textBuffer.size() - pos - 2);
- if (!processingInstructionTarget.view().compare(QLatin1String("xml"), Qt::CaseInsensitive)) {
+ if (!processingInstructionTarget.view().compare("xml"_L1, Qt::CaseInsensitive)) {
raiseWellFormedError(QXmlStream::tr("XML declaration not at start of document."));
}
else if (!QXmlUtils::isNCName(processingInstructionTarget))
@@ -591,7 +593,7 @@ bool QXmlStreamReaderPrivate::parse()
case 97:
setType(QXmlStreamReader::ProcessingInstruction);
processingInstructionTarget = symString(3);
- if (!processingInstructionTarget.view().compare(QLatin1String("xml"), Qt::CaseInsensitive))
+ if (!processingInstructionTarget.view().compare("xml"_L1, Qt::CaseInsensitive))
raiseWellFormedError(QXmlStream::tr("Invalid processing instruction name."));
break;
@@ -749,13 +751,13 @@ bool QXmlStreamReaderPrivate::parse()
case 229: {
XmlStringRef prefix = symPrefix(1);
- if (prefix.isEmpty() && symString(1) == QLatin1String("xmlns") && namespaceProcessing) {
+ if (prefix.isEmpty() && symString(1) == "xmlns"_L1 && namespaceProcessing) {
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
namespaceDeclaration.prefix.clear();
const XmlStringRef ns(symString(5));
- if (ns.view() == QLatin1String("http://www.w3.org/2000/xmlns/") ||
- ns.view() == QLatin1String("http://www.w3.org/XML/1998/namespace"))
+ if (ns.view() == "http://www.w3.org/2000/xmlns/"_L1 ||
+ ns.view() == "http://www.w3.org/XML/1998/namespace"_L1)
raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
else
namespaceDeclaration.namespaceUri = addToStringStorage(ns);
@@ -799,16 +801,16 @@ bool QXmlStreamReaderPrivate::parse()
attribute.value.pos = pos;
attribute.value.len = n;
}
- if (prefix == QLatin1String("xmlns") && namespaceProcessing) {
+ if (prefix == "xmlns"_L1 && namespaceProcessing) {
NamespaceDeclaration &namespaceDeclaration = namespaceDeclarations.push();
XmlStringRef namespacePrefix = symString(attribute.key);
XmlStringRef namespaceUri = symString(attribute.value);
attributeStack.pop();
- if (((namespacePrefix == QLatin1String("xml"))
- ^ (namespaceUri == QLatin1String("http://www.w3.org/XML/1998/namespace")))
- || namespaceUri == QLatin1String("http://www.w3.org/2000/xmlns/")
+ if (((namespacePrefix == "xml"_L1)
+ ^ (namespaceUri == "http://www.w3.org/XML/1998/namespace"_L1))
+ || namespaceUri == "http://www.w3.org/2000/xmlns/"_L1
|| namespaceUri.isEmpty()
- || namespacePrefix == QLatin1String("xmlns"))
+ || namespacePrefix == "xmlns"_L1)
raiseWellFormedError(QXmlStream::tr("Illegal namespace declaration."));
namespaceDeclaration.prefix = addToStringStorage(namespacePrefix);
diff --git a/src/corelib/serialization/qxmlutils.cpp b/src/corelib/serialization/qxmlutils.cpp
index dccdf85182..ccdacc8de5 100644
--- a/src/corelib/serialization/qxmlutils.cpp
+++ b/src/corelib/serialization/qxmlutils.cpp
@@ -380,7 +380,7 @@ bool QXmlUtils::isNCName(QStringView ncName)
return false;
for (QChar at : ncName) {
- if (!QXmlUtils::isNameChar(at) || at == QLatin1Char(':'))
+ if (!QXmlUtils::isNameChar(at) || at == u':')
return false;
}
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 1811304f51..73a41112a3 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -84,6 +84,8 @@ QT_WARNING_DISABLE_GCC("-Wfree-nonheap-object") // false positive tracking
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifndef QT_NO_SYSTEMLOCALE
static QSystemLocale *_systemLocale = nullptr;
class QSystemLocaleSingleton: public QSystemLocale
@@ -221,7 +223,7 @@ QLatin1String QLocalePrivate::languageToCode(QLocale::Language language,
if (language == QLocale::AnyLanguage || language > QLocale::LastLanguage)
return QLatin1String();
if (language == QLocale::C)
- return QLatin1String("C");
+ return "C"_L1;
const LanguageCodeEntry &i = languageCodeList[language];
@@ -636,22 +638,22 @@ QString qt_readEscapedFormatString(QStringView format, int *idx)
{
int &i = *idx;
- Q_ASSERT(format.at(i) == QLatin1Char('\''));
+ Q_ASSERT(format.at(i) == u'\'');
++i;
if (i == format.size())
return QString();
if (format.at(i).unicode() == '\'') { // "''" outside of a quoted string
++i;
- return QLatin1String("'");
+ return "'"_L1;
}
QString result;
while (i < format.size()) {
if (format.at(i).unicode() == '\'') {
- if (format.mid(i + 1).startsWith(QLatin1Char('\''))) {
+ if (format.mid(i + 1).startsWith(u'\'')) {
// "''" inside a quoted string
- result.append(QLatin1Char('\''));
+ result.append(u'\'');
i += 2;
} else {
break;
@@ -1357,7 +1359,7 @@ QString QLocale::name() const
if (c == AnyTerritory)
return d->languageCode();
- return d->languageCode() + QLatin1Char('_') + d->territoryCode();
+ return d->languageCode() + u'_' + d->territoryCode();
}
static qlonglong toIntegral_helper(const QLocaleData *d, QStringView str, bool *ok,
@@ -1550,7 +1552,7 @@ QLocale::Script QLocale::codeToScript(QStringView scriptCode) noexcept
QString QLocale::languageToString(Language language)
{
if (language > QLocale::LastLanguage)
- return QLatin1String("Unknown");
+ return "Unknown"_L1;
return QLatin1String(language_name_list + language_name_index[language]);
}
@@ -1564,7 +1566,7 @@ QString QLocale::languageToString(Language language)
QString QLocale::territoryToString(QLocale::Territory territory)
{
if (territory > QLocale::LastTerritory)
- return QLatin1String("Unknown");
+ return "Unknown"_L1;
return QLatin1String(territory_name_list + territory_name_index[territory]);
}
@@ -1592,7 +1594,7 @@ QString QLocale::countryToString(Country country)
QString QLocale::scriptToString(QLocale::Script script)
{
if (script > QLocale::LastScript)
- return QLatin1String("Unknown");
+ return "Unknown"_L1;
return QLatin1String(script_name_list + script_name_index[script]);
}
@@ -2338,7 +2340,7 @@ QString QLocale::dateTimeFormat(FormatType format) const
}
}
#endif
- return dateFormat(format) + QLatin1Char(' ') + timeFormat(format);
+ return dateFormat(format) + u' ' + timeFormat(format);
}
#if QT_CONFIG(datestring)
@@ -3497,7 +3499,7 @@ QString QCalendarBackend::dateTimeToString(QStringView format, const QDateTime &
QString text = time.hour() < 12 ? locale.amText() : locale.pmText();
used = true;
repeat = 1;
- if (format.mid(i + 1).startsWith(QLatin1Char('p'), Qt::CaseInsensitive))
+ if (format.mid(i + 1).startsWith(u'p', Qt::CaseInsensitive))
++repeat;
if (c.unicode() == 'A' && (repeat == 1 || format.at(i + 1).unicode() == 'P'))
text = std::move(text).toUpper();
@@ -4403,7 +4405,7 @@ QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats
unit = d->m_data->byteCount().viewData(byte_unit_data);
}
- return number + QLatin1Char(' ') + unit;
+ return number + u' ' + unit;
}
/*!
diff --git a/src/corelib/text/qlocale_mac.mm b/src/corelib/text/qlocale_mac.mm
index 7d75db31d0..6ca4045dc2 100644
--- a/src/corelib/text/qlocale_mac.mm
+++ b/src/corelib/text/qlocale_mac.mm
@@ -52,6 +52,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/******************************************************************************
** Wrappers for Mac locale system functions
*/
@@ -293,10 +295,10 @@ static QVariant macToQtFormat(QStringView sys_fmt)
while (i < sys_fmt.size()) {
if (sys_fmt.at(i).unicode() == '\'') {
QString text = qt_readEscapedFormatString(sys_fmt, &i);
- if (text == QLatin1String("'"))
- result += QLatin1String("''");
+ if (text == "'"_L1)
+ result += "''"_L1;
else
- result += QLatin1Char('\'') + text + QLatin1Char('\'');
+ result += u'\'' + text + u'\'';
continue;
}
@@ -322,17 +324,17 @@ static QVariant macToQtFormat(QStringView sys_fmt)
case 'u': // Extended Year (1..n): 2 = short year, 1 & 3..n = padded number
// Qt only supports long (4) or short (2) year, use long for all others
if (repeat == 2)
- result += QLatin1String("yy");
+ result += "yy"_L1;
else
- result += QLatin1String("yyyy");
+ result += "yyyy"_L1;
break;
case 'M': // Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow
case 'L': // Standalone Month (1..5): 4 = long, 3 = short, 1..2 = number, 5 = narrow
// Qt only supports long, short and number, use short for narrow
if (repeat == 5)
- result += QLatin1String("MMM");
+ result += "MMM"_L1;
else
- result += QString(repeat, QLatin1Char('M'));
+ result += QString(repeat, u'M');
break;
case 'd': // Day of Month (1..2): 1..2 padded number
result += QString(repeat, c);
@@ -340,32 +342,32 @@ static QVariant macToQtFormat(QStringView sys_fmt)
case 'E': // Day of Week (1..6): 4 = long, 1..3 = short, 5..6 = narrow
// Qt only supports long, short and padded number, use short for narrow
if (repeat == 4)
- result += QLatin1String("dddd");
+ result += "dddd"_L1;
else
- result += QLatin1String("ddd");
+ result += "ddd"_L1;
break;
case 'e': // Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number
case 'c': // Standalone Local Day of Week (1..6): 4 = long, 3 = short, 5..6 = narrow, 1..2 padded number
// Qt only supports long, short and padded number, use short for narrow
if (repeat >= 5)
- result += QLatin1String("ddd");
+ result += "ddd"_L1;
else
- result += QString(repeat, QLatin1Char('d'));
+ result += QString(repeat, 'd'_L1);
break;
case 'a': // AM/PM (1): 1 = short
// Translate to Qt uppercase AM/PM
- result += QLatin1String("AP");
+ result += "AP"_L1;
break;
case 'h': // Hour [1..12] (1..2): 1..2 = padded number
case 'K': // Hour [0..11] (1..2): 1..2 = padded number
case 'j': // Local Hour [12 or 24] (1..2): 1..2 = padded number
// Qt h is local hour
- result += QString(repeat, QLatin1Char('h'));
+ result += QString(repeat, 'h'_L1);
break;
case 'H': // Hour [0..23] (1..2): 1..2 = padded number
case 'k': // Hour [1..24] (1..2): 1..2 = padded number
// Qt H is 0..23 hour
- result += QString(repeat, QLatin1Char('H'));
+ result += QString(repeat, 'H'_L1);
break;
case 'm': // Minutes (1..2): 1..2 = padded number
case 's': // Seconds (1..2): 1..2 = padded number
@@ -374,9 +376,9 @@ static QVariant macToQtFormat(QStringView sys_fmt)
case 'S': // Fractional second (1..n): 1..n = truncates to decimal places
// Qt uses msecs either unpadded or padded to 3 places
if (repeat < 3)
- result += QLatin1Char('z');
+ result += u'z';
else
- result += QLatin1String("zzz");
+ result += "zzz"_L1;
break;
case 'z': // Time Zone (1..4)
case 'Z': // Time Zone (1..5)
@@ -385,16 +387,14 @@ static QVariant macToQtFormat(QStringView sys_fmt)
case 'V': // Time Zone (1..4)
case 'X': // Time Zone (1..5)
case 'x': // Time Zone (1..5)
- result += QLatin1Char('t');
+ result += u't';
break;
default:
// a..z and A..Z are reserved for format codes, so any occurrence of these not
// already processed are not known and so unsupported formats to be ignored.
// All other chars are allowed as literals.
- if (c < QLatin1Char('A') || c > QLatin1Char('z') ||
- (c > QLatin1Char('Z') && c < QLatin1Char('a'))) {
+ if (c < u'A' || c > u'z' || (c > u'Z' && c < u'a'))
result += QString(repeat, c);
- }
break;
}
@@ -433,7 +433,7 @@ static QVariant macMeasurementSystem()
{
QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
CFStringRef system = static_cast<CFStringRef>(CFLocaleGetValue(locale, kCFLocaleMeasurementSystem));
- if (QString::fromCFString(system) == QLatin1String("Metric")) {
+ if (QString::fromCFString(system) == "Metric"_L1) {
return QLocale::MetricSystem;
} else {
return QLocale::ImperialSystem;
diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp
index 84afaa377c..13346c5506 100644
--- a/src/corelib/text/qlocale_unix.cpp
+++ b/src/corelib/text/qlocale_unix.cpp
@@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifndef QT_NO_SYSTEMLOCALE
struct QSystemLocaleData
{
@@ -144,12 +146,12 @@ QLocale QSystemLocale::fallbackLocale() const
if (lang.isEmpty())
lang = qEnvironmentVariable("LANG");
// if the locale is the "C" locale, then we can return the language we found here:
- if (lang.isEmpty() || lang == QLatin1String("C") || lang == QLatin1String("POSIX"))
+ if (lang.isEmpty() || lang == "C"_L1 || lang == "POSIX"_L1)
return QLocale(lang);
// ... otherwise, if the first part of LANGUAGE says more than or
// contradicts what we have, use that:
- for (const auto &language : qEnvironmentVariable("LANGUAGE").tokenize(QLatin1Char(':'))) {
+ for (const auto &language : qEnvironmentVariable("LANGUAGE").tokenize(u':')) {
if (contradicts(language, lang))
return QLocale(language);
break; // We only look at the first entry.
@@ -260,9 +262,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
}
case MeasurementSystem: {
const QString meas_locale = QString::fromLatin1(d->lc_measurement_var);
- if (meas_locale.compare(QLatin1String("Metric"), Qt::CaseInsensitive) == 0)
+ if (meas_locale.compare("Metric"_L1, Qt::CaseInsensitive) == 0)
return QLocale::MetricSystem;
- if (meas_locale.compare(QLatin1String("Other"), Qt::CaseInsensitive) == 0)
+ if (meas_locale.compare("Other"_L1, Qt::CaseInsensitive) == 0)
return QLocale::MetricSystem;
return QVariant((int)QLocale(meas_locale).measurementSystem());
}
@@ -276,7 +278,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
if (languages.isEmpty())
lst.append(QString::fromLatin1(d->lc_messages_var));
else
- lst = languages.split(QLatin1Char(':'));
+ lst = languages.split(u':');
// Inadequate for various cases of a language that's written in more
// than one script in the same country, e.g. Sindhi in India.
@@ -285,7 +287,7 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
QStringView lang, cntry;
if (qt_splitLocaleName(lst.at(i), &lang, nullptr, &cntry)) {
d->uiLanguages.append(
- cntry.size() ? lang % QLatin1Char('-') % cntry : lang.toString());
+ cntry.size() ? lang % u'-' % cntry : lang.toString());
}
}
return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages);
diff --git a/src/corelib/text/qlocale_win.cpp b/src/corelib/text/qlocale_win.cpp
index 695b363e5f..c5f82b9500 100644
--- a/src/corelib/text/qlocale_win.cpp
+++ b/src/corelib/text/qlocale_win.cpp
@@ -69,6 +69,8 @@ namespace winrt::impl
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT);
static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT);
@@ -351,7 +353,7 @@ QVariant QSystemLocalePrivate::timeFormat(QLocale::FormatType type)
QVariant QSystemLocalePrivate::dateTimeFormat(QLocale::FormatType type)
{
- return QString(dateFormat(type).toString() + QLatin1Char(' ') + timeFormat(type).toString());
+ return QString(dateFormat(type).toString() + u' ' + timeFormat(type).toString());
}
QVariant QSystemLocalePrivate::dayName(int day, QLocale::FormatType type)
@@ -444,7 +446,7 @@ QString QSystemLocalePrivate::yearFix(int year, int fakeYear, QString &&formatte
Q_ASSERT(fakeYear >= 1970 && fakeYear <= 2400);
const bool matchTwo = year >= 0 && year % 100 == fakeYear % 100;
auto yearUsed = fourDigitYear(fakeYear);
- QString sign(year < 0 ? 1 : 0, QLatin1Char('-'));
+ QString sign(year < 0 ? 1 : 0, u'-');
auto trueYear = fourDigitYear(year < 0 ? -year : year);
if (formatted.contains(yearUsed))
return std::move(formatted).replace(yearUsed, sign + trueYear);
@@ -534,7 +536,8 @@ QVariant QSystemLocalePrivate::toString(QTime time, QLocale::FormatType type)
QVariant QSystemLocalePrivate::toString(const QDateTime &dt, QLocale::FormatType type)
{
- return QString(toString(dt.date(), type).toString() + QLatin1Char(' ') + toString(dt.time(), type).toString());
+ return QString(toString(dt.date(), type).toString() + u' '
+ + toString(dt.time(), type).toString());
}
QVariant QSystemLocalePrivate::measurementSystem()
@@ -665,7 +668,7 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
// int(32) == "12,34,56,789.00" == string("3;2;0")
// int(320)== "1234,56,789.00" == string("3;2")
QString groupingStr = getLocaleInfo(LOCALE_SMONGROUPING).toString();
- format.Grouping = groupingStr.remove(QLatin1Char(';')).toInt();
+ format.Grouping = groupingStr.remove(u';').toInt();
if (format.Grouping % 10 == 0) // magic
format.Grouping /= 10;
else
@@ -752,12 +755,12 @@ QString QSystemLocalePrivate::winToQtFormat(QStringView sys_fmt)
int i = 0;
while (i < sys_fmt.size()) {
- if (sys_fmt.at(i).unicode() == QLatin1Char('\'')) {
+ if (sys_fmt.at(i).unicode() == u'\'') {
QString text = qt_readEscapedFormatString(sys_fmt, &i);
- if (text == QLatin1String("'"))
- result += QLatin1String("''");
+ if (text == "'"_L1)
+ result += "''"_L1;
else
- result += QLatin1Char('\'') + text + QLatin1Char('\'');
+ result += u'\'' + text + u'\'';
continue;
}
@@ -773,13 +776,13 @@ QString QSystemLocalePrivate::winToQtFormat(QStringView sys_fmt)
repeat = 2;
switch (repeat) {
case 1:
- result += QLatin1String("yy"); // "y" unsupported by Qt, use "yy"
+ result += "yy"_L1; // "y" unsupported by Qt, use "yy"
break;
case 5:
- result += QLatin1String("yyyy"); // "yyyyy" same as "yyyy" on Windows
+ result += "yyyy"_L1; // "yyyyy" same as "yyyy" on Windows
break;
default:
- result += QString(repeat, QLatin1Char('y'));
+ result += QString(repeat, u'y');
break;
}
break;
@@ -790,14 +793,14 @@ QString QSystemLocalePrivate::winToQtFormat(QStringView sys_fmt)
case 2:
break; // no equivalent of "gg" in Qt
default:
- result += QLatin1Char('g');
+ result += u'g';
break;
}
break;
case 't':
if (repeat > 2)
repeat = 2;
- result += QLatin1String("AP"); // "t" unsupported, use "AP"
+ result += "AP"_L1; // "t" unsupported, use "AP"
break;
default:
result += QString(repeat, c);
@@ -1110,7 +1113,7 @@ static QString winIso639LangName(LCID id)
if (ok && *endptr == '\0') {
switch (i) {
case 0x814:
- result = QLatin1String("nn"); // Nynorsk
+ result = u"nn"_qs; // Nynorsk
break;
default:
break;
@@ -1160,7 +1163,7 @@ static QByteArray getWinLocaleName(LCID id)
QString resultusage = winIso639LangName(id);
QString country = winIso3116CtryName(id);
if (!country.isEmpty())
- resultusage += QLatin1Char('_') + country;
+ resultusage += u'_' + country;
return std::move(resultusage).toLatin1();
}
diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp
index c6aa26b619..e90ec6b1e6 100644
--- a/src/corelib/text/qregularexpression.cpp
+++ b/src/corelib/text/qregularexpression.cpp
@@ -61,6 +61,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QRegularExpression
\inmodule QtCore
@@ -1211,8 +1213,8 @@ void QRegularExpressionPrivate::doMatch(QRegularExpressionMatchPrivate *priv,
if (usingCrLfNewlines
&& offset < subjectLength
- && subjectUtf16[offset - 1] == QLatin1Char('\r')
- && subjectUtf16[offset] == QLatin1Char('\n')) {
+ && subjectUtf16[offset - 1] == u'\r'
+ && subjectUtf16[offset] == u'\n') {
++offset;
} else if (offset < subjectLength
&& QChar::isLowSurrogate(subjectUtf16[offset])) {
@@ -1595,7 +1597,7 @@ QString QRegularExpression::errorString() const
#endif
}
#ifdef QT_NO_TRANSLATION
- return QLatin1String("no error");
+ return u"no error"_qs;
#else
return QCoreApplication::translate("QRegularExpression", "no error");
#endif
@@ -1837,14 +1839,13 @@ QString QRegularExpression::escape(QStringView str)
// unlike Perl, a literal NUL must be escaped with
// "\\0" (backslash + 0) and not "\\\0" (backslash + NUL),
// because pcre16_compile uses a NUL-terminated string
- result.append(QLatin1Char('\\'));
- result.append(QLatin1Char('0'));
- } else if ( (current < QLatin1Char('a') || current > QLatin1Char('z')) &&
- (current < QLatin1Char('A') || current > QLatin1Char('Z')) &&
- (current < QLatin1Char('0') || current > QLatin1Char('9')) &&
- current != QLatin1Char('_') )
- {
- result.append(QLatin1Char('\\'));
+ result.append(u'\\');
+ result.append(u'0');
+ } else if ((current < u'a' || current > u'z') &&
+ (current < u'A' || current > u'Z') &&
+ (current < u'0' || current > u'9') &&
+ current != u'_') {
+ result.append(u'\\');
result.append(current);
if (current.isHighSurrogate() && i < (count - 1))
result.append(str.at(++i));
@@ -1940,13 +1941,13 @@ QString QRegularExpression::wildcardToRegularExpression(QStringView pattern, Wil
const QChar *wc = pattern.data();
#ifdef Q_OS_WIN
- const QLatin1Char nativePathSeparator('\\');
- const QLatin1String starEscape("[^/\\\\]*");
- const QLatin1String questionMarkEscape("[^/\\\\]");
+ const char16_t nativePathSeparator = u'\\';
+ const auto starEscape = "[^/\\\\]*"_L1;
+ const auto questionMarkEscape = "[^/\\\\]"_L1;
#else
- const QLatin1Char nativePathSeparator('/');
- const QLatin1String starEscape("[^/]*");
- const QLatin1String questionMarkEscape("[^/]");
+ const char16_t nativePathSeparator = u'/';
+ const auto starEscape = "[^/]*"_L1;
+ const auto questionMarkEscape = "[^/]"_L1;
#endif
while (i < wclen) {
@@ -1961,7 +1962,7 @@ QString QRegularExpression::wildcardToRegularExpression(QStringView pattern, Wil
case '\\':
#ifdef Q_OS_WIN
case '/':
- rx += QLatin1String("[/\\\\]");
+ rx += "[/\\\\]"_L1;
break;
#endif
case '$':
@@ -1973,29 +1974,29 @@ QString QRegularExpression::wildcardToRegularExpression(QStringView pattern, Wil
case '{':
case '|':
case '}':
- rx += QLatin1Char('\\');
+ rx += u'\\';
rx += c;
break;
case '[':
rx += c;
// Support for the [!abc] or [!a-c] syntax
if (i < wclen) {
- if (wc[i] == QLatin1Char('!')) {
- rx += QLatin1Char('^');
+ if (wc[i] == u'!') {
+ rx += u'^';
++i;
}
- if (i < wclen && wc[i] == QLatin1Char(']'))
+ if (i < wclen && wc[i] == u']')
rx += wc[i++];
- while (i < wclen && wc[i] != QLatin1Char(']')) {
+ while (i < wclen && wc[i] != u']') {
// The '/' appearing in a character class invalidates the
// regular expression parsing. It also concerns '\\' on
// Windows OS types.
- if (wc[i] == QLatin1Char('/') || wc[i] == nativePathSeparator)
+ if (wc[i] == u'/' || wc[i] == nativePathSeparator)
return rx;
- if (wc[i] == QLatin1Char('\\'))
- rx += QLatin1Char('\\');
+ if (wc[i] == u'\\')
+ rx += u'\\';
rx += wc[i++];
}
}
@@ -2050,9 +2051,9 @@ QRegularExpression QRegularExpression::fromWildcard(QStringView pattern, Qt::Cas
QString QRegularExpression::anchoredPattern(QStringView expression)
{
return QString()
- + QLatin1String("\\A(?:")
+ + "\\A(?:"_L1
+ expression
- + QLatin1String(")\\z");
+ + ")\\z"_L1;
}
/*!
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index de4df9fff3..644078f779 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -110,6 +110,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
const char16_t QString::_empty = 0;
// in qstringmatcher.cpp
@@ -4394,7 +4396,7 @@ QString &QString::replace(const QRegularExpression &re, const QString &after)
const QChar *ac = after.unicode();
for (qsizetype i = 0; i < al - 1; i++) {
- if (ac[i] == QLatin1Char('\\')) {
+ if (ac[i] == u'\\') {
int no = ac[i + 1].digitValue();
if (no > 0 && no <= numCaptures) {
QStringCapture backReference;
@@ -6878,11 +6880,11 @@ QString QString::vasprintf(const char *cformat, va_list ap)
++c;
if (*c == '\0') {
- result.append(QLatin1Char('%')); // a % at the end of the string - treat as non-escape text
+ result.append(u'%'); // a % at the end of the string - treat as non-escape text
break;
}
if (*c == '%') {
- result.append(QLatin1Char('%')); // %%
+ result.append(u'%'); // %%
++c;
continue;
}
@@ -8327,13 +8329,13 @@ QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) cons
unsigned flags = QLocaleData::NoFlags;
// ZeroPadded sorts out left-padding when the fill is zero, to the right of sign:
- if (fillChar == QLatin1Char('0'))
+ if (fillChar == u'0')
flags = QLocaleData::ZeroPadded;
QString arg;
if (d.occurrences > d.locale_occurrences) {
arg = QLocaleData::c()->longLongToString(a, -1, base, fieldWidth, flags);
- Q_ASSERT(fillChar != QLatin1Char('0') || !qIsFinite(a)
+ Q_ASSERT(fillChar != u'0' || !qIsFinite(a)
|| fieldWidth <= arg.length());
}
@@ -8343,7 +8345,7 @@ QString QString::arg(qlonglong a, int fieldWidth, int base, QChar fillChar) cons
if (!(locale.numberOptions() & QLocale::OmitGroupSeparator))
flags |= QLocaleData::GroupDigits;
localeArg = locale.d->m_data->longLongToString(a, -1, base, fieldWidth, flags);
- Q_ASSERT(fillChar != QLatin1Char('0') || !qIsFinite(a)
+ Q_ASSERT(fillChar != u'0' || !qIsFinite(a)
|| fieldWidth <= localeArg.length());
}
@@ -8375,13 +8377,13 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) con
unsigned flags = QLocaleData::NoFlags;
// ZeroPadded sorts out left-padding when the fill is zero, to the right of sign:
- if (fillChar == QLatin1Char('0'))
+ if (fillChar == u'0')
flags = QLocaleData::ZeroPadded;
QString arg;
if (d.occurrences > d.locale_occurrences) {
arg = QLocaleData::c()->unsLongLongToString(a, -1, base, fieldWidth, flags);
- Q_ASSERT(fillChar != QLatin1Char('0') || !qIsFinite(a)
+ Q_ASSERT(fillChar != u'0' || !qIsFinite(a)
|| fieldWidth <= arg.length());
}
@@ -8391,7 +8393,7 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, QChar fillChar) con
if (!(locale.numberOptions() & QLocale::OmitGroupSeparator))
flags |= QLocaleData::GroupDigits;
localeArg = locale.d->m_data->unsLongLongToString(a, -1, base, fieldWidth, flags);
- Q_ASSERT(fillChar != QLatin1Char('0') || !qIsFinite(a)
+ Q_ASSERT(fillChar != u'0' || !qIsFinite(a)
|| fieldWidth <= localeArg.length());
}
@@ -8475,7 +8477,7 @@ QString QString::arg(double a, int fieldWidth, char format, int precision, QChar
unsigned flags = QLocaleData::NoFlags;
// ZeroPadded sorts out left-padding when the fill is zero, to the right of sign:
- if (fillChar == QLatin1Char('0'))
+ if (fillChar == u'0')
flags |= QLocaleData::ZeroPadded;
if (qIsUpper(format))
@@ -8503,7 +8505,7 @@ QString QString::arg(double a, int fieldWidth, char format, int precision, QChar
if (d.occurrences > d.locale_occurrences) {
arg = QLocaleData::c()->doubleToString(a, precision, form, fieldWidth,
flags | QLocaleData::ZeroPadExponent);
- Q_ASSERT(fillChar != QLatin1Char('0') || !qIsFinite(a)
+ Q_ASSERT(fillChar != u'0' || !qIsFinite(a)
|| fieldWidth <= arg.length());
}
@@ -8519,7 +8521,7 @@ QString QString::arg(double a, int fieldWidth, char format, int precision, QChar
if (numberOptions & QLocale::IncludeTrailingZeroesAfterDot)
flags |= QLocaleData::AddTrailingZeroes;
localeArg = locale.d->m_data->doubleToString(a, precision, form, fieldWidth, flags);
- Q_ASSERT(fillChar != QLatin1Char('0') || !qIsFinite(a)
+ Q_ASSERT(fillChar != u'0' || !qIsFinite(a)
|| fieldWidth <= localeArg.length());
}
@@ -8534,7 +8536,7 @@ static int getEscape(const Char *uc, qsizetype *pos, qsizetype len, int maxNumbe
{
int i = *pos;
++i;
- if (i < len && uc[i] == QLatin1Char('L'))
+ if (i < len && uc[i] == u'L')
++i;
if (i < len) {
int escape = to_unicode(uc[i]) - '0';
@@ -8630,7 +8632,7 @@ static ParseResult parseMultiArgFormatString(StringView s)
qsizetype last = 0;
while (i < end) {
- if (uc[i] == QLatin1Char('%')) {
+ if (uc[i] == u'%') {
qsizetype percent = i;
int number = getEscape(uc, &i, len);
if (number != -1) {
@@ -10899,14 +10901,14 @@ QString QString::toHtmlEscaped() const
const int len = length();
rich.reserve(qsizetype(len * 1.1));
for (int i = 0; i < len; ++i) {
- if (at(i) == QLatin1Char('<'))
- rich += QLatin1String("&lt;");
- else if (at(i) == QLatin1Char('>'))
- rich += QLatin1String("&gt;");
- else if (at(i) == QLatin1Char('&'))
- rich += QLatin1String("&amp;");
- else if (at(i) == QLatin1Char('"'))
- rich += QLatin1String("&quot;");
+ if (at(i) == u'<')
+ rich += "&lt;"_L1;
+ else if (at(i) == u'>')
+ rich += "&gt;"_L1;
+ else if (at(i) == u'&')
+ rich += "&amp;"_L1;
+ else if (at(i) == u'"')
+ rich += "&quot;"_L1;
else
rich += at(i);
}
diff --git a/src/corelib/text/qunicodetools.cpp b/src/corelib/text/qunicodetools.cpp
index 8223c759e9..bba950102e 100644
--- a/src/corelib/text/qunicodetools.cpp
+++ b/src/corelib/text/qunicodetools.cpp
@@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_AUTOTEST_EXPORT int qt_initcharattributes_default_algorithm_only = 0;
namespace QUnicodeTools {
@@ -1409,8 +1411,8 @@ static int init_libthai() {
#if QT_CONFIG(library)
static bool initialized = false;
if (!initialized && (!th_brk || !th_next_cell)) {
- th_brk = reinterpret_cast<th_brk_def>(QLibrary::resolve(QLatin1String("thai"), static_cast<int>(LIBTHAI_MAJOR), "th_brk"));
- th_next_cell = (th_next_cell_def)QLibrary::resolve(QLatin1String("thai"), LIBTHAI_MAJOR, "th_next_cell");
+ th_brk = reinterpret_cast<th_brk_def>(QLibrary::resolve("thai"_L1, static_cast<int>(LIBTHAI_MAJOR), "th_brk"));
+ th_next_cell = (th_next_cell_def)QLibrary::resolve("thai"_L1, LIBTHAI_MAJOR, "th_next_cell");
initialized = true;
}
if (th_brk && th_next_cell)
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index fee6354b0a..239f463a18 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*
QThread wrapper, provides synchronization against a ThreadPool
*/
@@ -277,7 +279,7 @@ void QThreadPoolPrivate::startThread(QRunnable *runnable)
Q_ASSERT(runnable != nullptr);
auto thread = std::make_unique<QThreadPoolThread>(this);
if (objectName.isEmpty())
- objectName = QLatin1String("Thread (pooled)");
+ objectName = u"Thread (pooled)"_qs;
thread->setObjectName(objectName);
Q_ASSERT(!allThreads.contains(thread.get())); // if this assert hits, we have an ABA problem (deleted threads don't get removed here)
allThreads.insert(thread.get());
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 8de7637df5..9652d400d0 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -70,6 +70,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*****************************************************************************
Date/Time Constants
*****************************************************************************/
@@ -3885,9 +3887,9 @@ QString QDateTime::timeZoneAbbreviation() const
switch (getSpec(d)) {
case Qt::UTC:
- return QLatin1String("UTC");
+ return "UTC"_L1;
case Qt::OffsetFromUTC:
- return QLatin1String("UTC") + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
+ return "UTC"_L1 + toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
case Qt::TimeZone:
#if !QT_CONFIG(timezone)
break;
@@ -4272,9 +4274,9 @@ QString QDateTime::toString(Qt::DateFormat format) const
#endif
default:
#if 0 // ### Qt 7 GMT: use UTC instead, see qnamespace.qdoc documentation
- buf += QLatin1String(" UTC");
+ buf += " UTC"_L1;
#else
- buf += QLatin1String(" GMT");
+ buf += " GMT"_L1;
#endif
if (getSpec(d) == Qt::OffsetFromUTC)
buf += toOffsetString(Qt::TextDate, offsetFromUtc());
@@ -5177,9 +5179,9 @@ QDateTime QDateTime::fromString(QStringView string, Qt::DateFormat format)
return QDateTime(date, time, Qt::LocalTime);
QStringView tz = parts.at(5);
- if (tz.startsWith(QLatin1String("UTC"))
+ if (tz.startsWith("UTC"_L1)
// GMT has long been deprecated as an alias for UTC.
- || tz.startsWith(QLatin1String("GMT"), Qt::CaseInsensitive)) {
+ || tz.startsWith("GMT"_L1, Qt::CaseInsensitive)) {
tz = tz.sliced(3);
if (tz.isEmpty())
return QDateTime(date, time, Qt::UTC);
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index 13e1b2157e..b71d4f27b6 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -62,6 +62,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
template <typename T>
using ShortVector = QVarLengthArray<T, 13>; // enough for month (incl. leap) and day-of-week names
@@ -551,8 +553,7 @@ bool QDateTimeParser::parseFormat(QStringView newFormat)
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
newDisplay |= AmPmSection;
if (i + 1 < newFormat.size()
- && newFormat.sliced(i + 1).startsWith(QLatin1Char('p'),
- Qt::CaseInsensitive)) {
+ && newFormat.sliced(i + 1).startsWith(u'p', Qt::CaseInsensitive)) {
++i;
if (newFormat.at(i) != QLatin1Char(caseOpt == UpperCase ? 'P' : 'p'))
caseOpt = NativeCase;
@@ -645,7 +646,7 @@ bool QDateTimeParser::parseFormat(QStringView newFormat)
// }
QDTPDEBUG << newFormat << displayFormat;
- QDTPDEBUGN("separators:\n'%s'", separators.join(QLatin1String("\n")).toLatin1().constData());
+ QDTPDEBUGN("separators:\n'%s'", separators.join("\n"_L1).toLatin1().constData());
return true;
}
@@ -819,7 +820,7 @@ QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex, i
const int sectionmaxsize = sectionMaxSize(sectionIndex);
const bool negate = (sn.type == YearSection && m_text.size() > offset
- && m_text.at(offset) == QLatin1Char('-'));
+ && m_text.at(offset) == u'-');
const int negativeYearOffset = negate ? 1 : 0;
QStringView sectionTextRef =
@@ -896,8 +897,8 @@ QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex, i
case MSecSection: {
int used = negativeYearOffset;
// We already sliced off the - sign if it was legitimately present.
- if (sectionTextRef.startsWith(QLatin1Char('-'))
- || sectionTextRef.startsWith(QLatin1Char('+'))) {
+ if (sectionTextRef.startsWith(u'-')
+ || sectionTextRef.startsWith(u'+')) {
if (separators.at(sectionIndex + 1).startsWith(sectionTextRef[0]))
result = ParsedSection(Intermediate, 0, used);
break;
@@ -966,7 +967,7 @@ QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionIndex, i
if (skipToNextSection(sectionIndex, currentValue, digitsStr)) {
const int missingZeroes = sectionmaxsize - digitsStr.size();
result = ParsedSection(Acceptable, last, sectionmaxsize, missingZeroes);
- m_text.insert(offset, QString(missingZeroes, QLatin1Char('0')));
+ m_text.insert(offset, QString(missingZeroes, u'0'));
++(const_cast<QDateTimeParser*>(this)->sectionNodes[sectionIndex].zeroesAdded);
} else {
result = ParsedSection(Intermediate, last, used);;
@@ -1267,7 +1268,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, bool fixup) const
if (fixup && sect.state == Intermediate && sect.used < sn.count) {
const FieldInfo fi = fieldInfo(index);
if ((fi & (Numeric|FixedWidth)) == (Numeric|FixedWidth)) {
- const QString newText = QString::fromLatin1("%1").arg(sect.value, sn.count, 10, QLatin1Char('0'));
+ const QString newText = QString::fromLatin1("%1").arg(sect.value, sn.count, 10, '0'_L1);
m_text.replace(pos, sect.used, newText);
sect.used = sn.count;
}
@@ -1286,12 +1287,12 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, bool fixup) const
QStringView zoneName = QStringView{m_text}.sliced(pos, sect.used);
Q_ASSERT(!zoneName.isEmpty()); // sect.used > 0
- const QStringView offsetStr = zoneName.startsWith(QLatin1String("UTC"))
+ const QStringView offsetStr = zoneName.startsWith("UTC"_L1)
? zoneName.sliced(3) : zoneName;
- const bool isUtcOffset = offsetStr.startsWith(QLatin1Char('+'))
- || offsetStr.startsWith(QLatin1Char('-'));
- const bool isUtc = zoneName == QLatin1String("Z")
- || zoneName == QLatin1String("UTC");
+ const bool isUtcOffset = offsetStr.startsWith(u'+')
+ || offsetStr.startsWith(u'-');
+ const bool isUtc = zoneName == "Z"_L1
+ || zoneName == "UTC"_L1;
if (isUtc || isUtcOffset) {
tspec = sect.value ? Qt::OffsetFromUTC : Qt::UTC;
@@ -1501,7 +1502,7 @@ QDateTimeParser::parse(const QString &input, int position,
QDTPDEBUG << "parse" << input;
StateNode scan = scanString(defaultValue, fixup);
QDTPDEBUGN("'%s' => '%s'(%s)", m_text.toLatin1().constData(),
- scan.value.toString(QLatin1String("yyyy/MM/dd hh:mm:ss.zzz")).toLatin1().constData(),
+ scan.value.toString("yyyy/MM/dd hh:mm:ss.zzz"_L1).toLatin1().constData(),
stateName(scan.state).toLatin1().constData());
if (scan.value.isValid() && scan.state != Invalid) {
@@ -1735,7 +1736,7 @@ int QDateTimeParser::findDay(const QString &str1, int startDay, int sectionIndex
*/
QDateTimeParser::ParsedSection QDateTimeParser::findUtcOffset(QStringView str) const
{
- const bool startsWithUtc = str.startsWith(QLatin1String("UTC"));
+ const bool startsWithUtc = str.startsWith("UTC"_L1);
// Get rid of UTC prefix if it exists
if (startsWithUtc) {
str = str.sliced(3);
@@ -1743,13 +1744,13 @@ QDateTimeParser::ParsedSection QDateTimeParser::findUtcOffset(QStringView str) c
return ParsedSection(Acceptable, 0, 3);
}
- const bool negativeSign = str.startsWith(QLatin1Char('-'));
+ const bool negativeSign = str.startsWith(u'-');
// Must start with a sign:
- if (!negativeSign && !str.startsWith(QLatin1Char('+')))
+ if (!negativeSign && !str.startsWith(u'+'))
return ParsedSection();
str = str.sliced(1); // drop sign
- const int colonPosition = str.indexOf(QLatin1Char(':'));
+ const int colonPosition = str.indexOf(u':');
// Colon that belongs to offset is at most at position 2 (hh:mm)
bool hasColon = (colonPosition >= 0 && colonPosition < 3);
@@ -1827,7 +1828,7 @@ QDateTimeParser::findTimeZoneName(QStringView str, const QDateTime &when) const
int count = 0;
Q_ASSERT(index <= str.size());
while (lastSlash < index) {
- int slash = str.indexOf(QLatin1Char('/'), lastSlash + 1);
+ int slash = str.indexOf(u'/', lastSlash + 1);
if (slash < 0 || slash > index)
slash = index; // i.e. the end of the candidate text
else if (++count > 5)
@@ -1861,7 +1862,7 @@ QDateTimeParser::findTimeZone(QStringView str, const QDateTime &when,
int maxVal, int minVal) const
{
// Short-cut Zulu suffix when it's all there is (rather than a prefix match):
- if (str == QLatin1Char('Z'))
+ if (str == u'Z')
return ParsedSection(Acceptable, 0, 1);
ParsedSection section = findUtcOffset(str);
@@ -1874,9 +1875,9 @@ QDateTimeParser::findTimeZone(QStringView str, const QDateTime &when,
return section;
// Check if string is UTC or alias to UTC, after all other options
- if (str.startsWith(QLatin1String("UTC")))
+ if (str.startsWith("UTC"_L1))
return ParsedSection(Acceptable, 0, 3);
- if (str.startsWith(QLatin1Char('Z')))
+ if (str.startsWith(u'Z'))
return ParsedSection(Acceptable, 0, 1);
return ParsedSection();
@@ -2060,18 +2061,18 @@ QString QDateTimeParser::SectionNode::format() const
{
QChar fillChar;
switch (type) {
- case AmPmSection: return QLatin1String(count == 1 ? "ap" : count == 2 ? "AP" : "Ap");
- case MSecSection: fillChar = QLatin1Char('z'); break;
- case SecondSection: fillChar = QLatin1Char('s'); break;
- case MinuteSection: fillChar = QLatin1Char('m'); break;
- case Hour24Section: fillChar = QLatin1Char('H'); break;
- case Hour12Section: fillChar = QLatin1Char('h'); break;
+ case AmPmSection: return count == 1 ? "ap"_L1 : count == 2 ? "AP"_L1 : "Ap"_L1;
+ case MSecSection: fillChar = u'z'; break;
+ case SecondSection: fillChar = u's'; break;
+ case MinuteSection: fillChar = u'm'; break;
+ case Hour24Section: fillChar = u'H'; break;
+ case Hour12Section: fillChar = u'h'; break;
case DayOfWeekSectionShort:
case DayOfWeekSectionLong:
- case DaySection: fillChar = QLatin1Char('d'); break;
- case MonthSection: fillChar = QLatin1Char('M'); break;
+ case DaySection: fillChar = u'd'; break;
+ case MonthSection: fillChar = u'M'; break;
case YearSection2Digits:
- case YearSection: fillChar = QLatin1Char('y'); break;
+ case YearSection: fillChar = u'y'; break;
default:
qWarning("QDateTimeParser::sectionFormat Internal error (%ls)",
qUtf16Printable(name(type)));
@@ -2169,23 +2170,23 @@ bool QDateTimeParser::skipToNextSection(int index, const QDateTime &current, QSt
QString QDateTimeParser::SectionNode::name(QDateTimeParser::Section s)
{
switch (s) {
- case QDateTimeParser::AmPmSection: return QLatin1String("AmPmSection");
- case QDateTimeParser::DaySection: return QLatin1String("DaySection");
- case QDateTimeParser::DayOfWeekSectionShort: return QLatin1String("DayOfWeekSectionShort");
- case QDateTimeParser::DayOfWeekSectionLong: return QLatin1String("DayOfWeekSectionLong");
- case QDateTimeParser::Hour24Section: return QLatin1String("Hour24Section");
- case QDateTimeParser::Hour12Section: return QLatin1String("Hour12Section");
- case QDateTimeParser::MSecSection: return QLatin1String("MSecSection");
- case QDateTimeParser::MinuteSection: return QLatin1String("MinuteSection");
- case QDateTimeParser::MonthSection: return QLatin1String("MonthSection");
- case QDateTimeParser::SecondSection: return QLatin1String("SecondSection");
- case QDateTimeParser::TimeZoneSection: return QLatin1String("TimeZoneSection");
- case QDateTimeParser::YearSection: return QLatin1String("YearSection");
- case QDateTimeParser::YearSection2Digits: return QLatin1String("YearSection2Digits");
- case QDateTimeParser::NoSection: return QLatin1String("NoSection");
- case QDateTimeParser::FirstSection: return QLatin1String("FirstSection");
- case QDateTimeParser::LastSection: return QLatin1String("LastSection");
- default: return QLatin1String("Unknown section ") + QString::number(int(s));
+ case QDateTimeParser::AmPmSection: return "AmPmSection"_L1;
+ case QDateTimeParser::DaySection: return "DaySection"_L1;
+ case QDateTimeParser::DayOfWeekSectionShort: return "DayOfWeekSectionShort"_L1;
+ case QDateTimeParser::DayOfWeekSectionLong: return "DayOfWeekSectionLong"_L1;
+ case QDateTimeParser::Hour24Section: return "Hour24Section"_L1;
+ case QDateTimeParser::Hour12Section: return "Hour12Section"_L1;
+ case QDateTimeParser::MSecSection: return "MSecSection"_L1;
+ case QDateTimeParser::MinuteSection: return "MinuteSection"_L1;
+ case QDateTimeParser::MonthSection: return "MonthSection"_L1;
+ case QDateTimeParser::SecondSection: return "SecondSection"_L1;
+ case QDateTimeParser::TimeZoneSection: return "TimeZoneSection"_L1;
+ case QDateTimeParser::YearSection: return "YearSection"_L1;
+ case QDateTimeParser::YearSection2Digits: return "YearSection2Digits"_L1;
+ case QDateTimeParser::NoSection: return "NoSection"_L1;
+ case QDateTimeParser::FirstSection: return "FirstSection"_L1;
+ case QDateTimeParser::LastSection: return "LastSection"_L1;
+ default: return "Unknown section "_L1 + QString::number(int(s));
}
}
@@ -2197,10 +2198,10 @@ QString QDateTimeParser::SectionNode::name(QDateTimeParser::Section s)
QString QDateTimeParser::stateName(State s) const
{
switch (s) {
- case Invalid: return QLatin1String("Invalid");
- case Intermediate: return QLatin1String("Intermediate");
- case Acceptable: return QLatin1String("Acceptable");
- default: return QLatin1String("Unknown state ") + QString::number(s);
+ case Invalid: return "Invalid"_L1;
+ case Intermediate: return "Intermediate"_L1;
+ case Acceptable: return "Acceptable"_L1;
+ default: return "Unknown state "_L1 + QString::number(s);
}
}
diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp
index cabbbad3b5..b1ef9b172b 100644
--- a/src/corelib/time/qtimezone.cpp
+++ b/src/corelib/time/qtimezone.cpp
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// Create default time zone using appropriate backend
static QTimeZonePrivate *newBackendTimeZone()
{
@@ -991,7 +993,7 @@ QDataStream &operator>>(QDataStream &ds, QTimeZone &tz)
ds >> ianaId;
if (ianaId == invalidId()) {
tz = QTimeZone();
- } else if (ianaId == QLatin1String("OffsetFromUtc")) {
+ } else if (ianaId == "OffsetFromUtc"_L1) {
int utcOffset;
QString name;
QString abbreviation;
diff --git a/src/corelib/time/qtimezoneprivate_data_p.h b/src/corelib/time/qtimezoneprivate_data_p.h
index ebc04e1217..5a5c74d74b 100644
--- a/src/corelib/time/qtimezoneprivate_data_p.h
+++ b/src/corelib/time/qtimezoneprivate_data_p.h
@@ -81,7 +81,7 @@ struct QZoneData
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
inline QLatin1String id() const;
- inline auto ids() const { return id().tokenize(QLatin1String(" ")); }
+ inline auto ids() const { return id().tokenize(u' '); }
};
struct QWindowsData
diff --git a/src/corelib/time/qtimezoneprivate_tz.cpp b/src/corelib/time/qtimezoneprivate_tz.cpp
index aa8ff6d554..8cb34e254b 100644
--- a/src/corelib/time/qtimezoneprivate_tz.cpp
+++ b/src/corelib/time/qtimezoneprivate_tz.cpp
@@ -64,6 +64,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if QT_CONFIG(icu)
static QBasicMutex s_icu_mutex;
#endif
@@ -550,7 +552,7 @@ PosixZone PosixZone::parse(const char *&pos, const char *end)
pos = zoneEnd;
// UTC+hh:mm:ss or GMT+hh:mm:ss should be read as offsets from UTC, not as a
// POSIX rule naming a zone as UTC or GMT and specifying a non-zero offset.
- if (offset != 0 && (name == QLatin1String("UTC") || name == QLatin1String("GMT")))
+ if (offset != 0 && (name =="UTC"_L1 || name == "GMT"_L1))
return invalid();
return {std::move(name), offset};
}
@@ -763,9 +765,9 @@ QTzTimeZoneCacheEntry QTzTimeZoneCache::findEntry(const QByteArray &ianaId)
return ret;
} else {
// Open named tz, try modern path first, if fails try legacy path
- tzif.setFileName(QLatin1String("/usr/share/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+ tzif.setFileName("/usr/share/zoneinfo/"_L1 + QString::fromLocal8Bit(ianaId));
if (!tzif.open(QIODevice::ReadOnly)) {
- tzif.setFileName(QLatin1String("/usr/lib/zoneinfo/") + QString::fromLocal8Bit(ianaId));
+ tzif.setFileName("/usr/lib/zoneinfo/"_L1 + QString::fromLocal8Bit(ianaId));
if (!tzif.open(QIODevice::ReadOnly)) {
// ianaId may be a POSIX rule, taken from $TZ or /etc/TZ
auto check = validatePosixRule(ianaId);
@@ -1317,7 +1319,7 @@ private:
{
// On most distros /etc/localtime is a symlink to a real file so extract
// name from the path
- const QLatin1String zoneinfo("/zoneinfo/");
+ const auto zoneinfo = "/zoneinfo/"_L1;
QString path = QStringLiteral("/etc/localtime");
long iteration = getSymloopMax();
// Symlink may point to another symlink etc. before being under zoneinfo/
diff --git a/src/corelib/time/qtimezoneprivate_win.cpp b/src/corelib/time/qtimezoneprivate_win.cpp
index 997d8043c8..32eef3b163 100644
--- a/src/corelib/time/qtimezoneprivate_win.cpp
+++ b/src/corelib/time/qtimezoneprivate_win.cpp
@@ -51,6 +51,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*
Private
@@ -179,7 +181,7 @@ TIME_ZONE_INFORMATION getRegistryTzi(const QByteArray &windowsId, bool *ok)
TIME_ZONE_INFORMATION tzi;
REG_TZI_FORMAT regTzi;
DWORD regTziSize = sizeof(regTzi);
- const QString tziKeyPath = QString::fromWCharArray(tzRegPath) + QLatin1Char('\\')
+ const QString tziKeyPath = QString::fromWCharArray(tzRegPath) + u'\\'
+ QString::fromUtf8(windowsId);
QWinRegistryKey key(HKEY_LOCAL_MACHINE, tziKeyPath);
@@ -557,7 +559,7 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
bool badMonth = false; // Only warn once per zone, if at all.
if (!m_windowsId.isEmpty()) {
// Open the base TZI for the time zone
- const QString baseKeyPath = QString::fromWCharArray(tzRegPath) + QLatin1Char('\\')
+ const QString baseKeyPath = QString::fromWCharArray(tzRegPath) + u'\\'
+ QString::fromUtf8(m_windowsId);
QWinRegistryKey baseKey(HKEY_LOCAL_MACHINE, baseKeyPath);
if (baseKey.isValid()) {
@@ -566,7 +568,7 @@ void QWinTimeZonePrivate::init(const QByteArray &ianaId)
m_standardName = baseKey.stringValue(L"Std");
m_daylightName = baseKey.stringValue(L"Dlt");
// On Vista and later the optional dynamic key holds historic data
- const QString dynamicKeyPath = baseKeyPath + QLatin1String("\\Dynamic DST");
+ const QString dynamicKeyPath = baseKeyPath + "\\Dynamic DST"_L1;
QWinRegistryKey dynamicKey(HKEY_LOCAL_MACHINE, dynamicKeyPath);
if (dynamicKey.isValid()) {
// Find out the start and end years stored, then iterate over them
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp
index bfb6f68f08..1e9ade2a76 100644
--- a/src/corelib/tools/qcommandlineoption.cpp
+++ b/src/corelib/tools/qcommandlineoption.cpp
@@ -261,11 +261,11 @@ namespace {
return warn("be empty");
const QChar c = name.at(0);
- if (Q_UNLIKELY(c == QLatin1Char('-')))
+ if (Q_UNLIKELY(c == u'-'))
return warn("start with a '-'");
- if (Q_UNLIKELY(c == QLatin1Char('/')))
+ if (Q_UNLIKELY(c == u'/'))
return warn("start with a '/'");
- if (Q_UNLIKELY(name.contains(QLatin1Char('='))))
+ if (Q_UNLIKELY(name.contains(u'=')))
return warn("contain a '='");
return false;
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index d8899009d8..92f391c39a 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -54,6 +54,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
extern void Q_CORE_EXPORT qt_call_post_routines();
typedef QHash<QString, int> NameHash_t;
@@ -593,7 +595,7 @@ static void showParserMessage(const QString &message, MessageType type)
void QCommandLineParser::process(const QStringList &arguments)
{
if (!d->parse(arguments)) {
- showParserMessage(QCoreApplication::applicationName() + QLatin1String(": ") + errorText() + QLatin1Char('\n'), ErrorMessage);
+ showParserMessage(QCoreApplication::applicationName() + ": "_L1 + errorText() + u'\n', ErrorMessage);
qt_call_post_routines();
::exit(EXIT_FAILURE);
}
@@ -1018,8 +1020,8 @@ QStringList QCommandLineParser::unknownOptionNames() const
*/
Q_NORETURN void QCommandLineParser::showVersion()
{
- showParserMessage(QCoreApplication::applicationName() + QLatin1Char(' ')
- + QCoreApplication::applicationVersion() + QLatin1Char('\n'),
+ showParserMessage(QCoreApplication::applicationName() + u' '
+ + QCoreApplication::applicationVersion() + u'\n',
UsageMessage);
qt_call_post_routines();
::exit(EXIT_SUCCESS);
@@ -1060,8 +1062,8 @@ QString QCommandLineParser::helpText() const
static QString wrapText(const QString &names, int optionNameMaxWidth, const QString &description)
{
- const QLatin1Char nl('\n');
- const QLatin1String indentation(" ");
+ const auto nl = u'\n';
+ const auto indentation = " "_L1;
// In case the list of option names is very long, wrap it as well
int nameIndex = 0;
@@ -1103,7 +1105,7 @@ static QString wrapText(const QString &names, int optionNameMaxWidth, const QStr
if (breakAt != -1) {
const int numChars = breakAt - lineStart;
//qDebug() << "breakAt=" << description.at(breakAt) << "breakAtSpace=" << breakAtSpace << lineStart << "to" << breakAt << description.mid(lineStart, numChars);
- text += indentation + nextNameSection().leftJustified(optionNameMaxWidth) + QLatin1Char(' ');
+ text += indentation + nextNameSection().leftJustified(optionNameMaxWidth) + u' ';
text += QStringView{description}.mid(lineStart, numChars) + nl;
x = 0;
lastBreakable = -1;
@@ -1132,9 +1134,9 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const
if (includeQtOptions && qApp)
qApp->d_func()->addQtOptions(&options);
if (!options.isEmpty())
- usage += QLatin1Char(' ') + QCommandLineParser::tr("[options]");
+ usage += u' ' + QCommandLineParser::tr("[options]");
for (const PositionalArgumentDefinition &arg : positionalArgumentDefinitions)
- usage += QLatin1Char(' ') + arg.syntax;
+ usage += u' ' + arg.syntax;
text += QCommandLineParser::tr("Usage: %1").arg(usage) + nl;
if (!description.isEmpty())
text += description + nl;
@@ -1151,13 +1153,13 @@ QString QCommandLineParserPrivate::helpText(bool includeQtOptions) const
QString optionNamesString;
for (const QString &optionName : optionNames) {
const int numDashes = optionName.length() == 1 ? 1 : 2;
- optionNamesString += QLatin1String("--", numDashes) + optionName + QLatin1String(", ");
+ optionNamesString += QLatin1String("--", numDashes) + optionName + ", "_L1;
}
if (!optionNames.isEmpty())
optionNamesString.chop(2); // remove trailing ", "
const auto valueName = option.valueName();
if (!valueName.isEmpty())
- optionNamesString += QLatin1String(" <") + valueName + QLatin1Char('>');
+ optionNamesString += " <"_L1 + valueName + u'>';
optionNameList.append(optionNamesString);
longestOptionNameString = qMax(longestOptionNameString, optionNamesString.length());
}
diff --git a/src/corelib/tools/qversionnumber.cpp b/src/corelib/tools/qversionnumber.cpp
index 3f70d42ae3..784022f7bd 100644
--- a/src/corelib/tools/qversionnumber.cpp
+++ b/src/corelib/tools/qversionnumber.cpp
@@ -403,7 +403,7 @@ QString QVersionNumber::toString() const
bool first = true;
for (qsizetype i = 0; i < segmentCount(); ++i) {
if (!first)
- version += QLatin1Char('.');
+ version += u'.';
version += QString::number(segmentAt(i));
first = false;
}