diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-04-14 15:46:14 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-05-03 01:38:46 +0200 |
commit | 39a6307178603211e070580ed0c25ec65c0b8a70 (patch) | |
tree | e3f95d155a92a0d9c49f6694d9aa4874d49764d0 /src | |
parent | a0539ed53f45619df7e4aad664369301dd6da091 (diff) |
Tools: use _L1 for for creating Latin-1 string literals
As a drive-by, fix qsizetype -> int narrowing conversion warnings for
the touched lines.
Task-number: QTBUG-98434
Change-Id: I6d4712a71b5ebf3f379f1f98ea476557bce963ef
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/cmake_automoc_parser/main.cpp | 30 | ||||
-rw-r--r-- | src/tools/macdeployqt/shared/shared.cpp | 14 | ||||
-rw-r--r-- | src/tools/moc/main.cpp | 20 | ||||
-rw-r--r-- | src/tools/moc/moc.cpp | 90 | ||||
-rw-r--r-- | src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 26 | ||||
-rw-r--r-- | src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp | 96 | ||||
-rw-r--r-- | src/tools/qlalr/cppgenerator.cpp | 26 | ||||
-rw-r--r-- | src/tools/qlalr/lalr.cpp | 6 | ||||
-rw-r--r-- | src/tools/qlalr/lalr.g | 40 | ||||
-rw-r--r-- | src/tools/qlalr/main.cpp | 28 | ||||
-rw-r--r-- | src/tools/qlalr/recognizer.cpp | 40 | ||||
-rw-r--r-- | src/tools/rcc/main.cpp | 54 | ||||
-rw-r--r-- | src/tools/rcc/rcc.cpp | 55 | ||||
-rw-r--r-- | src/tools/tracegen/etw.cpp | 4 | ||||
-rw-r--r-- | src/tools/tracegen/helpers.cpp | 6 | ||||
-rw-r--r-- | src/tools/tracegen/provider.cpp | 10 | ||||
-rw-r--r-- | src/tools/windeployqt/elfreader.cpp | 6 | ||||
-rw-r--r-- | src/tools/windeployqt/main.cpp | 60 | ||||
-rw-r--r-- | src/tools/windeployqt/qmlutils.cpp | 4 | ||||
-rw-r--r-- | src/tools/windeployqt/utils.cpp | 14 |
20 files changed, 326 insertions, 303 deletions
diff --git a/src/tools/cmake_automoc_parser/main.cpp b/src/tools/cmake_automoc_parser/main.cpp index 6d8ae5d9fa..671a93797a 100644 --- a/src/tools/cmake_automoc_parser/main.cpp +++ b/src/tools/cmake_automoc_parser/main.cpp @@ -51,6 +51,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + using AutoGenHeaderMap = QMap<QString, QString>; using AutoGenSourcesList = QList<QString>; @@ -75,9 +77,9 @@ static bool readAutogenInfoJson(AutoGenHeaderMap &headers, AutoGenSourcesList &s } QJsonObject rootObject = doc.object(); - QJsonValue headersValue = rootObject.value(QLatin1String("HEADERS")); - QJsonValue sourcesValue = rootObject.value(QLatin1String("SOURCES")); - QJsonValue headerExtValue = rootObject.value(QLatin1String("HEADER_EXTENSIONS")); + QJsonValue headersValue = rootObject.value("HEADERS"_L1); + QJsonValue sourcesValue = rootObject.value("SOURCES"_L1); + QJsonValue headerExtValue = rootObject.value("HEADER_EXTENSIONS"_L1); if (!headersValue.isArray() || !sourcesValue.isArray() || !headerExtValue.isArray()) { fprintf(stderr, @@ -154,12 +156,12 @@ static bool readParseCache(ParseCacheMap &entries, const QString &parseCacheFile // .... QTextStream textStream(&file); - const QString mmcKey = QString(QLatin1String(" mmc:")); - const QString miuKey = QString(QLatin1String(" miu:")); - const QString uicKey = QString(QLatin1String(" uic:")); - const QString midKey = QString(QLatin1String(" mid:")); - const QString mdpKey = QString(QLatin1String(" mdp:")); - const QString udpKey = QString(QLatin1String(" udp:")); + const QString mmcKey = QString(" mmc:"_L1); + const QString miuKey = QString(" miu:"_L1); + const QString uicKey = QString(" uic:"_L1); + const QString midKey = QString(" mid:"_L1); + const QString mdpKey = QString(" mdp:"_L1); + const QString udpKey = QString(" udp:"_L1); QString line; bool mmc_key_found = false; while (textStream.readLineInto(&line)) { @@ -356,12 +358,11 @@ int main(int argc, char **argv) } } // Add extra moc files - for (const auto &mocFile : it.value().mocFiles) { - jsonFileList.push_back(dir.filePath(mocFile) + QLatin1String(".json")); - } + for (const auto &mocFile : it.value().mocFiles) + jsonFileList.push_back(dir.filePath(mocFile) + ".json"_L1); // Add main moc files for (const auto &mocFile : it.value().mocIncludes) { - jsonFileList.push_back(dir.filePath(mocFile) + QLatin1String(".json")); + jsonFileList.push_back(dir.filePath(mocFile) + ".json"_L1); // 1b) Locate this header and delete it constexpr int mocKeyLen = 4; // length of "moc_" const QString headerBaseName = @@ -394,8 +395,7 @@ int main(int argc, char **argv) const QString pathPrefix = !isMultiConfig ? QStringLiteral("../") : QString(); - const QString jsonPath = - dir.filePath(pathPrefix + mapIt.value() + QLatin1String(".json")); + const QString jsonPath = dir.filePath(pathPrefix + mapIt.value() + ".json"_L1); jsonFileList.push_back(jsonPath); } diff --git a/src/tools/macdeployqt/shared/shared.cpp b/src/tools/macdeployqt/shared/shared.cpp index 4e550750f6..be442e28e7 100644 --- a/src/tools/macdeployqt/shared/shared.cpp +++ b/src/tools/macdeployqt/shared/shared.cpp @@ -64,6 +64,7 @@ bool deployFramework = false; using std::cout; using std::endl; +using namespace Qt::StringLiterals; bool operator==(const FrameworkInfo &a, const FrameworkInfo &b) { @@ -850,7 +851,7 @@ void changeInstallName(const QString &bundlePath, const FrameworkInfo &framework for (const QString &binary : binaryPaths) { QString deployedInstallName; if (useLoaderPath) { - deployedInstallName = QLatin1String("@loader_path/") + deployedInstallName = "@loader_path/"_L1 + QFileInfo(binary).absoluteDir().relativeFilePath(absBundlePath + u'/' + framework.binaryDestinationDirectory + u'/' + framework.binaryName); } else { deployedInstallName = framework.deployedInstallName; @@ -873,9 +874,9 @@ void addRPath(const QString &rpath, const QString &binaryPath) void deployRPaths(const QString &bundlePath, const QList<QString> &rpaths, const QString &binaryPath, bool useLoaderPath) { const QString absFrameworksPath = QFileInfo(bundlePath).absoluteFilePath() - + QLatin1String("/Contents/Frameworks"); + + "/Contents/Frameworks"_L1; const QString relativeFrameworkPath = QFileInfo(binaryPath).absoluteDir().relativeFilePath(absFrameworksPath); - const QString loaderPathToFrameworks = QLatin1String("@loader_path/") + relativeFrameworkPath; + const QString loaderPathToFrameworks = "@loader_path/"_L1 + relativeFrameworkPath; bool rpathToFrameworksFound = false; QStringList args; QList<QString> binaryRPaths = getBinaryRPaths(binaryPath, false); @@ -945,13 +946,10 @@ void stripAppBinary(const QString &bundlePath) bool DeploymentInfo::containsModule(const QString &module, const QString &libInFix) const { // Check for framework first - if (deployedFrameworks.contains(QLatin1String("Qt") + module + libInFix + - QLatin1String(".framework"))) { + if (deployedFrameworks.contains("Qt"_L1 + module + libInFix + ".framework"_L1)) return true; - } // Check for dylib - const QRegularExpression dylibRegExp(QLatin1String("libQt[0-9]+") + module + - libInFix + QLatin1String(".[0-9]+.dylib")); + const QRegularExpression dylibRegExp("libQt[0-9]+"_L1 + module + libInFix + ".[0-9]+.dylib"_L1); return deployedFrameworks.filter(dylibRegExp).size() > 0; } diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 3fcb32e482..f05bf15366 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -48,6 +48,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /* This function looks at two file names and returns the name of the infile with a path relative to outfile. @@ -354,7 +356,7 @@ int runMoc(int argc, char **argv) return collectJson(files, output, hasOptionFiles); if (files.count() > 1) { - error(qPrintable(QLatin1String("Too many input files specified: '") + files.join(QLatin1String("' '")) + u'\'')); + error(qPrintable("Too many input files specified: '"_L1 + files.join("' '"_L1) + u'\'')); parser.showHelp(1); } else if (!files.isEmpty()) { filename = files.first(); @@ -390,7 +392,7 @@ int runMoc(int argc, char **argv) for (const QString &path : includePaths) pp.includes += Preprocessor::IncludePath(QFile::encodeName(path)); QString compilerFlavor = parser.value(compilerFlavorOption); - if (compilerFlavor.isEmpty() || compilerFlavor == QLatin1String("unix")) { + if (compilerFlavor.isEmpty() || compilerFlavor == "unix"_L1) { // traditional Unix compilers use both CPATH and CPLUS_INCLUDE_PATH // $CPATH feeds to #include <...> and #include "...", whereas // CPLUS_INCLUDE_PATH is equivalent to GCC's -isystem, so we parse later @@ -400,14 +402,14 @@ int runMoc(int argc, char **argv) const auto cplus_include_path = qgetenv("CPLUS_INCLUDE_PATH").split(QDir::listSeparator().toLatin1()); for (const QByteArray &p : cplus_include_path) pp.includes += Preprocessor::IncludePath(p); - } else if (compilerFlavor == QLatin1String("msvc")) { + } else if (compilerFlavor == "msvc"_L1) { // MSVC uses one environment variable: INCLUDE const auto include = qgetenv("INCLUDE").split(QDir::listSeparator().toLatin1()); for (const QByteArray &p : include) pp.includes += Preprocessor::IncludePath(p); } else { - error(qPrintable(QLatin1String("Unknown compiler flavor '") + compilerFlavor + - QLatin1String("'; valid values are: msvc, unix."))); + error(qPrintable("Unknown compiler flavor '"_L1 + compilerFlavor + + "'; valid values are: msvc, unix."_L1)); parser.showHelp(1); } @@ -446,9 +448,9 @@ int runMoc(int argc, char **argv) pp.macros.remove(macro); } const QStringList noNotesCompatValues = parser.values(noNotesWarningsCompatOption); - if (parser.isSet(noNotesOption) || noNotesCompatValues.contains(QLatin1String("n"))) + if (parser.isSet(noNotesOption) || noNotesCompatValues.contains("n"_L1)) moc.displayNotes = false; - if (parser.isSet(noWarningsOption) || noNotesCompatValues.contains(QLatin1String("w"))) + if (parser.isSet(noWarningsOption) || noNotesCompatValues.contains("w"_L1)) moc.displayWarnings = moc.displayNotes = false; if (autoInclude) { @@ -564,7 +566,7 @@ int runMoc(int argc, char **argv) } if (parser.isSet(jsonOption)) { - const QString jsonOutputFileName = output + QLatin1String(".json"); + const QString jsonOutputFileName = output + ".json"_L1; FILE *f; #if defined(_MSC_VER) if (_wfopen_s(&f, reinterpret_cast<const wchar_t *>(jsonOutputFileName.utf16()), L"w") != 0) @@ -605,7 +607,7 @@ int runMoc(int argc, char **argv) if (parser.isSet(depFilePathOption)) { depOutputFileName = parser.value(depFilePathOption); } else if (outputToFile) { - depOutputFileName = output + QLatin1String(".d"); + depOutputFileName = output + ".d"_L1; } else { fprintf(stderr, "moc: Writing to stdout, but no depfile path specified.\n"); } diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 65512997fd..04f4b2a95a 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -43,6 +43,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // only moc needs this function static QByteArray normalizeType(const QByteArray &ba) { @@ -1143,8 +1145,8 @@ void Moc::generate(FILE *out, FILE *jsonOutput) if (jsonOutput) { QJsonObject mocData; - mocData[QLatin1String("outputRevision")] = mocOutputRevision; - mocData[QLatin1String("inputFile")] = QLatin1String(fn.constData()); + mocData["outputRevision"_L1] = mocOutputRevision; + mocData["inputFile"_L1] = QLatin1String(fn.constData()); QJsonArray classesJsonFormatted; @@ -1152,7 +1154,7 @@ void Moc::generate(FILE *out, FILE *jsonOutput) classesJsonFormatted.append(cdef.toJson()); if (!classesJsonFormatted.isEmpty()) - mocData[QLatin1String("classes")] = classesJsonFormatted; + mocData["classes"_L1] = classesJsonFormatted; QJsonDocument jsonDoc(mocData); fputs(jsonDoc.toJson().constData(), jsonOutput); @@ -1920,19 +1922,19 @@ void Moc::checkProperties(ClassDef *cdef) QJsonObject ClassDef::toJson() const { QJsonObject cls; - cls[QLatin1String("className")] = QString::fromUtf8(classname.constData()); - cls[QLatin1String("qualifiedClassName")] = QString::fromUtf8(qualified.constData()); + cls["className"_L1] = QString::fromUtf8(classname.constData()); + cls["qualifiedClassName"_L1] = QString::fromUtf8(qualified.constData()); QJsonArray classInfos; for (const auto &info: qAsConst(classInfoList)) { QJsonObject infoJson; - infoJson[QLatin1String("name")] = QString::fromUtf8(info.name); - infoJson[QLatin1String("value")] = QString::fromUtf8(info.value); + infoJson["name"_L1] = QString::fromUtf8(info.name); + infoJson["value"_L1] = QString::fromUtf8(info.value); classInfos.append(infoJson); } if (classInfos.size()) - cls[QLatin1String("classInfos")] = classInfos; + cls["classInfos"_L1] = classInfos; const auto appendFunctions = [&cls](const QString &type, const QList<FunctionDef> &funcs) { QJsonArray jsonFuncs; @@ -1944,10 +1946,10 @@ QJsonObject ClassDef::toJson() const cls[type] = jsonFuncs; }; - appendFunctions(QLatin1String("signals"), signalList); - appendFunctions(QLatin1String("slots"), slotList); - appendFunctions(QLatin1String("constructors"), constructorList); - appendFunctions(QLatin1String("methods"), methodList); + appendFunctions("signals"_L1, signalList); + appendFunctions("slots"_L1, slotList); + appendFunctions("constructors"_L1, constructorList); + appendFunctions("methods"_L1, methodList); QJsonArray props; @@ -1955,14 +1957,14 @@ QJsonObject ClassDef::toJson() const props.append(propDef.toJson()); if (!props.isEmpty()) - cls[QLatin1String("properties")] = props; + cls["properties"_L1] = props; if (hasQObject) - cls[QLatin1String("object")] = true; + cls["object"_L1] = true; if (hasQGadget) - cls[QLatin1String("gadget")] = true; + cls["gadget"_L1] = true; if (hasQNamespace) - cls[QLatin1String("namespace")] = true; + cls["namespace"_L1] = true; QJsonArray superClasses; @@ -1970,33 +1972,33 @@ QJsonObject ClassDef::toJson() const const auto name = super.first; const auto access = super.second; QJsonObject superCls; - superCls[QLatin1String("name")] = QString::fromUtf8(name); + superCls["name"_L1] = QString::fromUtf8(name); FunctionDef::accessToJson(&superCls, access); superClasses.append(superCls); } if (!superClasses.isEmpty()) - cls[QLatin1String("superClasses")] = superClasses; + cls["superClasses"_L1] = superClasses; QJsonArray enums; for (const EnumDef &enumDef: qAsConst(enumList)) enums.append(enumDef.toJson(*this)); if (!enums.isEmpty()) - cls[QLatin1String("enums")] = enums; + cls["enums"_L1] = enums; QJsonArray ifaces; for (const QList<Interface> &ifaceList : interfaceList) { QJsonArray jsonList; for (const Interface &iface: ifaceList) { QJsonObject ifaceJson; - ifaceJson[QLatin1String("id")] = QString::fromUtf8(iface.interfaceId); - ifaceJson[QLatin1String("className")] = QString::fromUtf8(iface.className); + ifaceJson["id"_L1] = QString::fromUtf8(iface.interfaceId); + ifaceJson["className"_L1] = QString::fromUtf8(iface.className); jsonList.append(ifaceJson); } ifaces.append(jsonList); } if (!ifaces.isEmpty()) - cls[QLatin1String("interfaces")] = ifaces; + cls["interfaces"_L1] = ifaces; return cls; } @@ -2004,22 +2006,22 @@ QJsonObject ClassDef::toJson() const QJsonObject FunctionDef::toJson() const { QJsonObject fdef; - fdef[QLatin1String("name")] = QString::fromUtf8(name); + fdef["name"_L1] = QString::fromUtf8(name); if (!tag.isEmpty()) - fdef[QLatin1String("tag")] = QString::fromUtf8(tag); - fdef[QLatin1String("returnType")] = QString::fromUtf8(normalizedType); + fdef["tag"_L1] = QString::fromUtf8(tag); + fdef["returnType"_L1] = QString::fromUtf8(normalizedType); QJsonArray args; for (const ArgumentDef &arg: arguments) args.append(arg.toJson()); if (!args.isEmpty()) - fdef[QLatin1String("arguments")] = args; + fdef["arguments"_L1] = args; accessToJson(&fdef, access); if (revision > 0) - fdef[QLatin1String("revision")] = revision; + fdef["revision"_L1] = revision; return fdef; } @@ -2027,26 +2029,26 @@ QJsonObject FunctionDef::toJson() const void FunctionDef::accessToJson(QJsonObject *obj, FunctionDef::Access acs) { switch (acs) { - case Private: (*obj)[QLatin1String("access")] = QLatin1String("private"); break; - case Public: (*obj)[QLatin1String("access")] = QLatin1String("public"); break; - case Protected: (*obj)[QLatin1String("access")] = QLatin1String("protected"); break; + case Private: (*obj)["access"_L1] = "private"_L1; break; + case Public: (*obj)["access"_L1] = "public"_L1; break; + case Protected: (*obj)["access"_L1] = "protected"_L1; break; } } QJsonObject ArgumentDef::toJson() const { QJsonObject arg; - arg[QLatin1String("type")] = QString::fromUtf8(normalizedType); + arg["type"_L1] = QString::fromUtf8(normalizedType); if (!name.isEmpty()) - arg[QLatin1String("name")] = QString::fromUtf8(name); + arg["name"_L1] = QString::fromUtf8(name); return arg; } QJsonObject PropertyDef::toJson() const { QJsonObject prop; - prop[QLatin1String("name")] = QString::fromUtf8(name); - prop[QLatin1String("type")] = QString::fromUtf8(type); + prop["name"_L1] = QString::fromUtf8(name); + prop["type"_L1] = QString::fromUtf8(type); const auto jsonify = [&prop](const char *str, const QByteArray &member) { if (!member.isEmpty()) @@ -2077,12 +2079,12 @@ QJsonObject PropertyDef::toJson() const jsonifyBoolOrString("stored", stored); jsonifyBoolOrString("user", user); - prop[QLatin1String("constant")] = constant; - prop[QLatin1String("final")] = final; - prop[QLatin1String("required")] = required; - prop[QLatin1String("index")] = relativeIndex; + prop["constant"_L1] = constant; + prop["final"_L1] = final; + prop["required"_L1] = required; + prop["index"_L1] = relativeIndex; if (revision > 0) - prop[QLatin1String("revision")] = revision; + prop["revision"_L1] = revision; return prop; } @@ -2090,17 +2092,17 @@ QJsonObject PropertyDef::toJson() const QJsonObject EnumDef::toJson(const ClassDef &cdef) const { QJsonObject def; - def[QLatin1String("name")] = QString::fromUtf8(name); + def["name"_L1] = QString::fromUtf8(name); if (!enumName.isEmpty()) - def[QLatin1String("alias")] = QString::fromUtf8(enumName); - def[QLatin1String("isFlag")] = cdef.enumDeclarations.value(name); - def[QLatin1String("isClass")] = isEnumClass; + def["alias"_L1] = QString::fromUtf8(enumName); + def["isFlag"_L1] = cdef.enumDeclarations.value(name); + def["isClass"_L1] = isEnumClass; QJsonArray valueArr; for (const QByteArray &value: values) valueArr.append(QString::fromUtf8(value)); if (!valueArr.isEmpty()) - def[QLatin1String("values")] = valueArr; + def["values"_L1] = valueArr; return def; } diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index ee46970c74..914402bbbf 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -41,6 +41,8 @@ #include <qdbusconnection.h> // for the Export* flags #include <private/qdbusconnection_p.h> // for the qDBusCheckAsyncTag +using namespace Qt::StringLiterals; + // copied from dbus-protocol.h: static const char docTypeHeader[] = "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" " @@ -156,13 +158,13 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) { xml += QString::fromLatin1(" <arg %1type=\"%2\" direction=\"%3\"/>\n") .arg(name, QLatin1String(signature), - isOutput ? QLatin1String("out") : QLatin1String("in")); + isOutput ? "out"_L1 : "in"_L1); // do we need to describe this argument? if (!QDBusMetaType::signatureToMetaType(signature).isValid()) { const char *typeName = QMetaType(types.at(j)).name(); xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n") - .arg(isOutput ? QLatin1String("Out") : QLatin1String("In")) + .arg(isOutput ? "Out"_L1 : "In"_L1) .arg(isOutput && !isSignal ? j - inputCount : j - 1) .arg(typeNameToXml(typeName)); } @@ -180,12 +182,10 @@ static QString addFunction(const FunctionDef &mm, bool isSignal = false) { if (qDBusCheckAsyncTag(mm.tag.constData())) // add the no-reply annotation - xml += QLatin1String(" <annotation name=\"" ANNOTATION_NO_WAIT "\"" - " value=\"true\"/>\n"); + xml += " <annotation name=\"" ANNOTATION_NO_WAIT "\" value=\"true\"/>\n"_L1; QString retval = xml; - retval += QString::fromLatin1(" </%1>\n") - .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")); + retval += QString::fromLatin1(" </%1>\n").arg(isSignal ? "signal"_L1 : "method"_L1); return retval; } @@ -229,7 +229,7 @@ static QString generateInterfaceXml(const ClassDef *mo) retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n") .arg(typeNameToXml(mp.type.constData())); } else { - retval += QLatin1String("/>\n"); + retval += "/>\n"_L1; } } } @@ -273,16 +273,16 @@ QString qDBusInterfaceFromClassDef(const ClassDef *mo) return QString::fromUtf8(cid.value); } interface = QLatin1String(mo->classname); - interface.replace(QLatin1String("::"), QLatin1String(".")); + interface.replace("::"_L1, "."_L1); - if (interface.startsWith(QLatin1String("QDBus"))) { - interface.prepend(QLatin1String("org.qtproject.QtDBus.")); + if (interface.startsWith("QDBus"_L1)) { + interface.prepend("org.qtproject.QtDBus."_L1); } else if (interface.startsWith(u'Q') && interface.length() >= 2 && interface.at(1).isUpper()) { // assume it's Qt - interface.prepend(QLatin1String("local.org.qtproject.Qt.")); + interface.prepend("local.org.qtproject.Qt."_L1); } else { - interface.prepend(QLatin1String("local.")); + interface.prepend("local."_L1); } return interface; @@ -361,7 +361,7 @@ static void parseCmdLine(QStringList &arguments) for (int i = 0; i < arguments.count(); ++i) { const QString arg = arguments.at(i); - if (arg == QLatin1String("--help")) + if (arg == "--help"_L1) showHelp(); if (!arg.startsWith(u'-')) diff --git a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp index 9ed18e1659..df60b4a18d 100644 --- a/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/src/tools/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -50,6 +50,8 @@ #define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply" +using namespace Qt::StringLiterals; + static QString globalClassName; static QString parentClassName; static QString proxyFile; @@ -76,11 +78,10 @@ static const char forwardDeclarations[] = static QDBusIntrospection::Interfaces readInput() { QFile input(inputFile); - if (inputFile.isEmpty() || inputFile == QLatin1String("-")) { + if (inputFile.isEmpty() || inputFile == "-"_L1) input.open(stdin, QIODevice::ReadOnly); - } else { + else input.open(QIODevice::ReadOnly); - } QByteArray data = input.readAll(); @@ -114,12 +115,11 @@ static QString header(const QString &name) QStringList parts = name.split(u':'); QString retval = parts.first(); - if (retval.isEmpty() || retval == QLatin1String("-")) + if (retval.isEmpty() || retval == "-"_L1) return retval; - if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) && - !retval.endsWith(QLatin1String(".cc"))) - retval.append(QLatin1String(".h")); + if (!retval.endsWith(".h"_L1) && !retval.endsWith(".cpp"_L1) && !retval.endsWith(".cc"_L1)) + retval.append(".h"_L1); return retval; } @@ -130,12 +130,11 @@ static QString cpp(const QString &name) QStringList parts = name.split(u':'); QString retval = parts.last(); - if (retval.isEmpty() || retval == QLatin1String("-")) + if (retval.isEmpty() || retval == "-"_L1) return retval; - if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) && - !retval.endsWith(QLatin1String(".cc"))) - retval.append(QLatin1String(".cpp")); + if (!retval.endsWith(".h"_L1) && !retval.endsWith(".cpp"_L1) && !retval.endsWith(".cc"_L1)) + retval.append(".cpp"_L1); return retval; } @@ -148,7 +147,7 @@ static QString moc(const QString &name) return retval; retval.truncate(retval.length() - 1); // drop the h in .h - retval += QLatin1String("moc"); + retval += "moc"_L1; return retval; } @@ -193,9 +192,9 @@ static QString classNameForInterface(const QString &interface, ClassType classTy } if (classType == Proxy) - retval += QLatin1String("Interface"); + retval += "Interface"_L1; else - retval += QLatin1String("Adaptor"); + retval += "Adaptor"_L1; return retval; } @@ -265,7 +264,7 @@ static QString constRefArg(const QByteArray &arg) if (!arg.startsWith('Q')) return QLatin1String(arg + ' '); else - return QString( QLatin1String("const %1 &") ).arg( QLatin1String(arg) ); + return QString( "const %1 &"_L1 ).arg( QLatin1String(arg) ); } static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs, @@ -280,22 +279,22 @@ static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs, const QDBusIntrospection::Argument &arg = inputArgs.at(i); QString name = arg.name; if (name.isEmpty()) - name = QString( QLatin1String("in%1") ).arg(i); + name = QString( "in%1"_L1 ).arg(i); else name.replace(u'-', u'_'); while (retval.contains(name)) - name += QLatin1String("_"); + name += "_"_L1; retval << name; } for (int i = 0; i < numOutputArgs; ++i) { const QDBusIntrospection::Argument &arg = outputArgs.at(i); QString name = arg.name; if (name.isEmpty()) - name = QString( QLatin1String("out%1") ).arg(i); + name = QString( "out%1"_L1 ).arg(i); else name.replace(u'-', u'_'); while (retval.contains(name)) - name += QLatin1String("_"); + name += "_"_L1; retval << name; } return retval; @@ -354,11 +353,11 @@ static void writeSignalArgList(QTextStream &ts, const QStringList &argNames, static QString propertyGetter(const QDBusIntrospection::Property &property) { - QString getter = property.annotations.value(QLatin1String("org.qtproject.QtDBus.PropertyGetter")); + QString getter = property.annotations.value("org.qtproject.QtDBus.PropertyGetter"_L1); if (!getter.isEmpty()) return getter; - getter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertyGetter")); + getter = property.annotations.value("com.trolltech.QtDBus.propertyGetter"_L1); if (!getter.isEmpty()) { fprintf(stderr, "%s: Warning: deprecated annotation 'com.trolltech.QtDBus.propertyGetter' found" " while processing '%s';" @@ -374,11 +373,11 @@ static QString propertyGetter(const QDBusIntrospection::Property &property) static QString propertySetter(const QDBusIntrospection::Property &property) { - QString setter = property.annotations.value(QLatin1String("org.qtproject.QtDBus.PropertySetter")); + QString setter = property.annotations.value("org.qtproject.QtDBus.PropertySetter"_L1); if (!setter.isEmpty()) return setter; - setter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertySetter")); + setter = property.annotations.value("com.trolltech.QtDBus.propertySetter"_L1); if (!setter.isEmpty()) { fprintf(stderr, "%s: Warning: deprecated annotation 'com.trolltech.QtDBus.propertySetter' found" " while processing '%s';" @@ -387,7 +386,7 @@ static QString propertySetter(const QDBusIntrospection::Property &property) return setter; } - setter = QLatin1String("set") + property.name; + setter = "set"_L1 + property.name; setter[3] = setter[3].toUpper(); return setter; } @@ -409,12 +408,12 @@ static QString stringify(const QString &data) retval += u'\"'; for ( ; i < data.length() && data[i] != u'\n' && data[i] != u'\r'; ++i) if (data[i] == u'\"') - retval += QLatin1String("\\\""); + retval += "\\\""_L1; else retval += data[i]; if (i+1 < data.length() && data[i] == u'\r' && data[i+1] == u'\n') i++; - retval += QLatin1String("\\n\"\n"); + retval += "\\n\"\n"_L1; } return retval; } @@ -425,7 +424,7 @@ static bool openFile(const QString &fileName, QFile &file) return false; bool isOk = false; - if (fileName == QLatin1String("-")) { + if (fileName == "-"_L1) { isOk = file.open(stdout, QIODevice::WriteOnly | QIODevice::Text); } else { file.setFileName(fileName); @@ -456,16 +455,15 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf // include guards: QString includeGuard; - if (!headerName.isEmpty() && headerName != QLatin1String("-")) { + if (!headerName.isEmpty() && headerName != "-"_L1) { includeGuard = headerName.toUpper().replace(u'.', u'_'); qsizetype pos = includeGuard.lastIndexOf(u'/'); if (pos != -1) includeGuard = includeGuard.mid(pos + 1); } else { - includeGuard = QLatin1String("QDBUSXML2CPP_PROXY"); + includeGuard = "QDBUSXML2CPP_PROXY"_L1; } - includeGuard = QString(QLatin1String("%1")) - .arg(includeGuard); + includeGuard = "%1"_L1.arg(includeGuard); hs << "#ifndef " << includeGuard << Qt::endl << "#define " << includeGuard << Qt::endl << Qt::endl; @@ -489,7 +487,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf hs << Qt::endl; if (cppName != headerName) { - if (!headerName.isEmpty() && headerName != QLatin1String("-")) + if (!headerName.isEmpty() && headerName != "-"_L1) cs << "#include \"" << headerName << "\"" << Qt::endl << Qt::endl; } @@ -572,9 +570,9 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf // methods: hs << "public Q_SLOTS: // METHODS" << Qt::endl; for (const QDBusIntrospection::Method &method : interface->methods) { - bool isDeprecated = method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == QLatin1String("true"); + bool isDeprecated = method.annotations.value("org.freedesktop.DBus.Deprecated"_L1) == "true"_L1; bool isNoReply = - method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true"); + method.annotations.value(ANNOTATION_NO_WAIT ""_L1) == "true"_L1; if (isNoReply && !method.outputArgs.isEmpty()) { fprintf(stderr, "%s: warning while processing '%s': method %s in interface %s is marked 'no-reply' but has output arguments.\n", PROGRAMNAME, qPrintable(inputFile), qPrintable(method.name), @@ -669,8 +667,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf hs << "Q_SIGNALS: // SIGNALS" << Qt::endl; for (const QDBusIntrospection::Signal &signal : interface->signals_) { hs << " "; - if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == - QLatin1String("true")) + if (signal.annotations.value("org.freedesktop.DBus.Deprecated"_L1) == "true"_L1) hs << "Q_DECL_DEPRECATED "; hs << "void " << signal.name << "("; @@ -769,16 +766,15 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte // include guards: QString includeGuard; - if (!headerName.isEmpty() && headerName != QLatin1String("-")) { + if (!headerName.isEmpty() && headerName != "-"_L1) { includeGuard = headerName.toUpper().replace(u'.', u'_'); qsizetype pos = includeGuard.lastIndexOf(u'/'); if (pos != -1) includeGuard = includeGuard.mid(pos + 1); } else { - includeGuard = QLatin1String("QDBUSXML2CPP_ADAPTOR"); + includeGuard = "QDBUSXML2CPP_ADAPTOR"_L1; } - includeGuard = QString(QLatin1String("%1")) - .arg(includeGuard); + includeGuard = "%1"_L1.arg(includeGuard); hs << "#ifndef " << includeGuard << Qt::endl << "#define " << includeGuard << Qt::endl << Qt::endl; @@ -802,7 +798,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte } if (cppName != headerName) { - if (!headerName.isEmpty() && headerName != QLatin1String("-")) + if (!headerName.isEmpty() && headerName != "-"_L1) cs << "#include \"" << headerName << "\"" << Qt::endl; cs << "#include <QtCore/QMetaObject>" << Qt::endl @@ -817,7 +813,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte QString parent = parentClassName; if (parentClassName.isEmpty()) - parent = QLatin1String("QObject"); + parent = "QObject"_L1; for (const QDBusIntrospection::Interface *interface : interfaces) { QString className = classNameForInterface(interface->name, Adaptor); @@ -896,7 +892,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte << "{" << Qt::endl << " // set the value of property " << property.name << Qt::endl << " parent()->setProperty(\"" << property.name << "\", QVariant::fromValue(value"; - if (constRefType.contains(QLatin1String("QDBusVariant"))) + if (constRefType.contains("QDBusVariant"_L1)) cs << ".variant()"; cs << "));" << Qt::endl << "}" << Qt::endl @@ -909,7 +905,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte hs << "public Q_SLOTS: // METHODS" << Qt::endl; for (const QDBusIntrospection::Method &method : interface->methods) { bool isNoReply = - method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true"); + method.annotations.value(ANNOTATION_NO_WAIT ""_L1) == "true"_L1; if (isNoReply && !method.outputArgs.isEmpty()) { fprintf(stderr, "%s: warning while processing '%s': method %s in interface %s is marked 'no-reply' but has output arguments.\n", PROGRAMNAME, qPrintable(inputFile), qPrintable(method.name), qPrintable(interface->name)); @@ -917,8 +913,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte } hs << " "; - if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == - QLatin1String("true")) + if (method.annotations.value("org.freedesktop.DBus.Deprecated"_L1) == "true"_L1) hs << "Q_DECL_DEPRECATED "; QByteArray returnType; @@ -1015,8 +1010,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte hs << "Q_SIGNALS: // SIGNALS" << Qt::endl; for (const QDBusIntrospection::Signal &signal : interface->signals_) { hs << " "; - if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == - QLatin1String("true")) + if (signal.annotations.value("org.freedesktop.DBus.Deprecated"_L1) == "true"_L1) hs << "Q_DECL_DEPRECATED "; hs << "void " << signal.name << "("; @@ -1065,14 +1059,14 @@ int main(int argc, char **argv) QCoreApplication::setApplicationVersion(QStringLiteral(PROGRAMVERSION)); QCommandLineParser parser; - parser.setApplicationDescription(QLatin1String( + parser.setApplicationDescription( "Produces the C++ code to implement the interfaces defined in the input file.\n\n" "If the file name given to the options -a and -p does not end in .cpp or .h, the\n" "program will automatically append the suffixes and produce both files.\n" "You can also use a colon (:) to separate the header name from the source file\n" "name, as in '-a filename_p.h:filename.cpp'.\n\n" "If you pass a dash (-) as the argument to either -p or -a, the output is written\n" - "to the standard output.")); + "to the standard output."_L1); parser.addHelpOption(); parser.addVersionOption(); @@ -1142,7 +1136,7 @@ int main(int argc, char **argv) QStringList args = app.arguments(); args.removeFirst(); - commandLine = QLatin1String(PROGRAMNAME " "); + commandLine = PROGRAMNAME " "_L1; commandLine += args.join(u' '); if (!proxyFile.isEmpty() || adaptorFile.isEmpty()) diff --git a/src/tools/qlalr/cppgenerator.cpp b/src/tools/qlalr/cppgenerator.cpp index 2179d33b74..7db3d7c3b1 100644 --- a/src/tools/qlalr/cppgenerator.cpp +++ b/src/tools/qlalr/cppgenerator.cpp @@ -38,6 +38,8 @@ #include <iterator> +using namespace Qt::StringLiterals; + namespace { void generateSeparator(int i, QTextStream &out) @@ -64,7 +66,7 @@ void generateList(const QList<int> &list, QTextStream &out) QString CppGenerator::copyrightHeader() const { - return QLatin1String( + return "/****************************************************************************\n" "**\n" "** Copyright (C) 2016 The Qt Company Ltd.\n" @@ -92,12 +94,12 @@ QString CppGenerator::copyrightHeader() const "** $QT_END_LICENSE$\n" "**\n" "****************************************************************************/\n" - "\n"); + "\n"_L1; } QString CppGenerator::privateCopyrightHeader() const { - return QLatin1String( + return "//\n" "// W A R N I N G\n" "// -------------\n" @@ -107,7 +109,7 @@ QString CppGenerator::privateCopyrightHeader() const "// version without notice, or even be removed.\n" "//\n" "// We mean it.\n" - "//\n"); + "//\n"_L1; } QString CppGenerator::startIncludeGuard(const QString &fileName) @@ -374,8 +376,8 @@ void CppGenerator::operator () () } // default behaviour - QString declFileName = grammar.table_name.toLower () + QLatin1String("_p.h"); - QString bitsFileName = grammar.table_name.toLower () + QLatin1String(".cpp"); + QString declFileName = grammar.table_name.toLower () + "_p.h"_L1; + QString bitsFileName = grammar.table_name.toLower () + ".cpp"_L1; { // decls... QFile f (declFileName); @@ -448,9 +450,9 @@ void CppGenerator::operator () () QString CppGenerator::debugInfoProt() const { - QString prot = QLatin1String("QLALR_NO_"); + QString prot = "QLALR_NO_"_L1; prot += grammar.table_name.toUpper(); - prot += QLatin1String("_DEBUG_INFO"); + prot += "_DEBUG_INFO"_L1; return prot; } @@ -466,11 +468,11 @@ void CppGenerator::generateDecl (QTextStream &out) QString name = *t; int value = std::distance (grammar.names.begin (), t); - if (name == QLatin1String ("$end")) - name = QLatin1String ("EOF_SYMBOL"); + if (name == "$end"_L1) + name = "EOF_SYMBOL"_L1; - else if (name == QLatin1String ("$accept")) - name = QLatin1String ("ACCEPT_SYMBOL"); + else if (name == "$accept"_L1) + name = "ACCEPT_SYMBOL"_L1; else name.prepend (grammar.token_prefix); diff --git a/src/tools/qlalr/lalr.cpp b/src/tools/qlalr/lalr.cpp index 853465c272..3b01f9a3d8 100644 --- a/src/tools/qlalr/lalr.cpp +++ b/src/tools/qlalr/lalr.cpp @@ -39,6 +39,8 @@ #define QLALR_NO_DEBUG_INCLUDES #define QLALR_NO_DEBUG_LOOKAHEADS +using namespace Qt::StringLiterals; + QT_BEGIN_NAMESPACE QTextStream &qerr() { @@ -194,11 +196,11 @@ Grammar::Grammar (): current_prec = 0; current_assoc = NonAssoc; - table_name = QLatin1String ("parser_table"); + table_name = "parser_table"_L1; tk_end = intern ("$end"); terminals.insert (tk_end); - spells.insert (tk_end, QLatin1String("end of file")); + spells.insert (tk_end, "end of file"_L1); /*tk_error= terminals.insert (intern ("error"))*/; } diff --git a/src/tools/qlalr/lalr.g b/src/tools/qlalr/lalr.g index d59bb03a76..ff3d88a973 100644 --- a/src/tools/qlalr/lalr.g +++ b/src/tools/qlalr/lalr.g @@ -198,6 +198,8 @@ protected: #include <cstring> #include <cctype> +using namespace Qt::StringLiterals; + Recognizer::Recognizer (Grammar *grammar, bool no_lines): tos(0), stack_size(0), @@ -286,31 +288,31 @@ int Recognizer::nextToken() do { text += ch; inp (); } while (ch.isLetterOrNumber () || ch == u'_' || ch == u'-'); - if (text == QLatin1String("token_prefix")) + if (text == "token_prefix"_L1) return (token = TOKEN_PREFIX); - else if (text == QLatin1String("merged_output")) + else if (text == "merged_output"_L1) return (token = MERGED_OUTPUT); - else if (text == QLatin1String("token")) + else if (text == "token"_L1) return (token = TOKEN); - else if (text == QLatin1String("start")) + else if (text == "start"_L1) return (token = START); - else if (text == QLatin1String("parser")) + else if (text == "parser"_L1) return (token = PARSER); - else if (text == QLatin1String("decl")) + else if (text == "decl"_L1) return (token = DECL_FILE); - else if (text == QLatin1String("impl")) + else if (text == "impl"_L1) return (token = IMPL_FILE); - else if (text == QLatin1String("expect")) + else if (text == "expect"_L1) return (token = EXPECT); - else if (text == QLatin1String("expect-rr")) + else if (text == "expect-rr"_L1) return (token = EXPECT_RR); - else if (text == QLatin1String("left")) + else if (text == "left"_L1) return (token = LEFT); - else if (text == QLatin1String("right")) + else if (text == "right"_L1) return (token = RIGHT); - else if (text == QLatin1String("nonassoc")) + else if (text == "nonassoc"_L1) return (token = NONASSOC); - else if (text == QLatin1String("prec")) + else if (text == "prec"_L1) return (token = PREC); else { @@ -344,8 +346,8 @@ int Recognizer::nextToken() text.clear (); if (! _M_no_lines) - text += QLatin1String("\n#line ") + QString::number(_M_action_line) + - QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n"); + text += "\n#line "_L1 + QString::number(_M_action_line) + + " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1; inp (); // skip ':' forever @@ -372,7 +374,7 @@ int Recognizer::nextToken() return (token = DECL); } else - text += QLatin1String (":/"); + text += ":/"_L1; } } @@ -382,8 +384,8 @@ int Recognizer::nextToken() text.clear (); if (! _M_no_lines) - text += QLatin1String("\n#line ") + QString::number(_M_action_line) + - QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n"); + text += "\n#line "_L1 + QString::number(_M_action_line) + + " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1; inp (); // skip ':' @@ -411,7 +413,7 @@ int Recognizer::nextToken() return (token = IMPL); } else - text += QLatin1String ("./"); + text += "./"_L1; } } diff --git a/src/tools/qlalr/main.cpp b/src/tools/qlalr/main.cpp index 6a57c7aa7a..08f097d1d4 100644 --- a/src/tools/qlalr/main.cpp +++ b/src/tools/qlalr/main.cpp @@ -42,6 +42,8 @@ #define QLALR_NO_DEBUG_TABLE #define QLALR_NO_DEBUG_DOT +using namespace Qt::StringLiterals; + static void help_me () { qerr() << "Usage: qlalr [options] [input file name]" << Qt::endl @@ -69,22 +71,22 @@ int main (int argc, char *argv[]) const QStringList args = app.arguments().mid(1); for (const QString &arg : args) { - if (arg == QLatin1String ("-h") || arg == QLatin1String ("--help")) + if (arg == "-h"_L1 || arg == "--help"_L1) help_me (); - else if (arg == QLatin1String ("-v") || arg == QLatin1String ("--verbose")) + else if (arg == "-v"_L1 || arg == "--verbose"_L1) generate_report = true; - else if (arg == QLatin1String ("--dot")) + else if (arg == "--dot"_L1) generate_dot = true; - else if (arg == QLatin1String ("--no-lines")) + else if (arg == "--no-lines"_L1) no_lines = true; - else if (arg == QLatin1String ("--no-debug")) + else if (arg == "--no-debug"_L1) debug_info = false; - else if (arg == QLatin1String ("--qt")) + else if (arg == "--qt"_L1) qt_copyright = true; else if (file_name.isEmpty ()) @@ -150,19 +152,19 @@ QString Recognizer::expand (const QString &text) const if (_M_grammar->start != _M_grammar->names.end ()) { - code = code.replace (QLatin1String("$start_id"), QString::number (std::distance (_M_grammar->names.begin (), _M_grammar->start))); - code = code.replace (QLatin1String("$start"), *_M_grammar->start); + code = code.replace ("$start_id"_L1, QString::number (std::distance (_M_grammar->names.begin (), _M_grammar->start))); + code = code.replace ("$start"_L1, *_M_grammar->start); } - code = code.replace (QLatin1String("$header"), _M_grammar->table_name.toLower () + QLatin1String("_p.h")); + code = code.replace ("$header"_L1, _M_grammar->table_name.toLower () + "_p.h"_L1); - code = code.replace (QLatin1String("$table"), _M_grammar->table_name); - code = code.replace (QLatin1String("$parser"), _M_grammar->table_name); + code = code.replace ("$table"_L1, _M_grammar->table_name); + code = code.replace ("$parser"_L1, _M_grammar->table_name); if (_M_current_rule != _M_grammar->rules.end ()) { - code = code.replace (QLatin1String("$rule_number"), QString::number (std::distance (_M_grammar->rules.begin (), _M_current_rule))); - code = code.replace (QLatin1String("$rule"), *_M_current_rule->lhs); + code = code.replace ("$rule_number"_L1, QString::number (std::distance (_M_grammar->rules.begin (), _M_current_rule))); + code = code.replace ("$rule"_L1, *_M_current_rule->lhs); } return code; diff --git a/src/tools/qlalr/recognizer.cpp b/src/tools/qlalr/recognizer.cpp index f4526d164b..111780e3fb 100644 --- a/src/tools/qlalr/recognizer.cpp +++ b/src/tools/qlalr/recognizer.cpp @@ -34,6 +34,8 @@ #include <cstring> #include <cctype> +using namespace Qt::StringLiterals; + Recognizer::Recognizer (Grammar *grammar, bool no_lines): tos(0), stack_size(0), @@ -122,31 +124,31 @@ int Recognizer::nextToken() do { text += ch; inp (); } while (ch.isLetterOrNumber () || ch == u'_' || ch == u'-'); - if (text == QLatin1String("token_prefix")) + if (text == "token_prefix"_L1) return (token = TOKEN_PREFIX); - else if (text == QLatin1String("merged_output")) + else if (text == "merged_output"_L1) return (token = MERGED_OUTPUT); - else if (text == QLatin1String("token")) + else if (text == "token"_L1) return (token = TOKEN); - else if (text == QLatin1String("start")) + else if (text == "start"_L1) return (token = START); - else if (text == QLatin1String("parser")) + else if (text == "parser"_L1) return (token = PARSER); - else if (text == QLatin1String("decl")) + else if (text == "decl"_L1) return (token = DECL_FILE); - else if (text == QLatin1String("impl")) + else if (text == "impl"_L1) return (token = IMPL_FILE); - else if (text == QLatin1String("expect")) + else if (text == "expect"_L1) return (token = EXPECT); - else if (text == QLatin1String("expect-rr")) + else if (text == "expect-rr"_L1) return (token = EXPECT_RR); - else if (text == QLatin1String("left")) + else if (text == "left"_L1) return (token = LEFT); - else if (text == QLatin1String("right")) + else if (text == "right"_L1) return (token = RIGHT); - else if (text == QLatin1String("nonassoc")) + else if (text == "nonassoc"_L1) return (token = NONASSOC); - else if (text == QLatin1String("prec")) + else if (text == "prec"_L1) return (token = PREC); else { @@ -180,8 +182,8 @@ int Recognizer::nextToken() text.clear (); if (! _M_no_lines) - text += QLatin1String("\n#line ") + QString::number(_M_action_line) + - QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n"); + text += "\n#line "_L1 + QString::number(_M_action_line) + + " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1; inp (); // skip ':' forever @@ -208,7 +210,7 @@ int Recognizer::nextToken() return (token = DECL); } else - text += QLatin1String (":/"); + text += ":/"_L1; } } @@ -218,8 +220,8 @@ int Recognizer::nextToken() text.clear (); if (! _M_no_lines) - text += QLatin1String("\n#line ") + QString::number(_M_action_line) + - QLatin1String(" \"") + QDir::fromNativeSeparators(_M_input_file) + QLatin1String("\"\n"); + text += "\n#line "_L1 + QString::number(_M_action_line) + + " \""_L1 + QDir::fromNativeSeparators(_M_input_file) + "\"\n"_L1; inp (); // skip ':' @@ -247,7 +249,7 @@ int Recognizer::nextToken() return (token = IMPL); } else - text += QLatin1String (""); + text += ""_L1; } } diff --git a/src/tools/rcc/main.cpp b/src/tools/rcc/main.cpp index 14da7099e5..0be339dce2 100644 --- a/src/tools/rcc/main.cpp +++ b/src/tools/rcc/main.cpp @@ -49,6 +49,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + void dumpRecursive(const QDir &dir, QTextStream &out) { const QFileInfoList entries = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot @@ -57,9 +59,9 @@ void dumpRecursive(const QDir &dir, QTextStream &out) if (entry.isDir()) { dumpRecursive(entry.filePath(), out); } else { - out << QLatin1String("<file>") + out << "<file>"_L1 << entry.filePath() - << QLatin1String("</file>\n"); + << "</file>\n"_L1; } } } @@ -69,7 +71,7 @@ int createProject(const QString &outFileName) QDir currentDir = QDir::current(); QString currentDirName = currentDir.dirName(); if (currentDirName.isEmpty()) - currentDirName = QLatin1String("root"); + currentDirName = "root"_L1; QFile file; bool isOk = false; @@ -87,14 +89,14 @@ int createProject(const QString &outFileName) } QTextStream out(&file); - out << QLatin1String("<!DOCTYPE RCC><RCC version=\"1.0\">\n" - "<qresource>\n"); + out << "<!DOCTYPE RCC><RCC version=\"1.0\">\n" + "<qresource>\n"_L1; // use "." as dir to get relative file paths - dumpRecursive(QDir(QLatin1String(".")), out); + dumpRecursive(QDir("."_L1), out); - out << QLatin1String("</qresource>\n" - "</RCC>\n"); + out << "</qresource>\n" + "</RCC>\n"_L1; return 0; } @@ -105,11 +107,11 @@ QString makefileEscape(const QString &filepath) // Always use forward slashes QString result = QDir::cleanPath(filepath); // Spaces are escaped with a backslash - result.replace(u' ', QLatin1String("\\ ")); + result.replace(u' ', "\\ "_L1); // Pipes are escaped with a backslash - result.replace(u'|', QLatin1String("\\|")); + result.replace(u'|', "\\|"_L1); // Dollars are escaped with a dollar - result.replace(u'$', QLatin1String("$$")); + result.replace(u'$', "$$"_L1); return result; } @@ -139,7 +141,7 @@ int runRcc(int argc, char *argv[]) // If you use this code as an example for a translated app, make sure to translate the strings. QCommandLineParser parser; parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); - parser.setApplicationDescription(QLatin1String("Qt Resource Compiler version " QT_VERSION_STR)); + parser.setApplicationDescription("Qt Resource Compiler version " QT_VERSION_STR ""_L1); parser.addHelpOption(); parser.addVersionOption(); @@ -233,9 +235,9 @@ int runRcc(int argc, char *argv[]) bool ok = false; formatVersion = parser.value(formatVersionOption).toUInt(&ok); if (!ok) { - errorMsg = QLatin1String("Invalid format version specified"); + errorMsg = "Invalid format version specified"_L1; } else if (formatVersion < 1 || formatVersion > 3) { - errorMsg = QLatin1String("Unsupported format version specified"); + errorMsg = "Unsupported format version specified"_L1; } } @@ -245,13 +247,13 @@ int runRcc(int argc, char *argv[]) if (parser.isSet(rootOption)) { library.setResourceRoot(QDir::cleanPath(parser.value(rootOption))); if (library.resourceRoot().isEmpty() || library.resourceRoot().at(0) != u'/') - errorMsg = QLatin1String("Root must start with a /"); + errorMsg = "Root must start with a /"_L1; } if (parser.isSet(compressionAlgoOption)) library.setCompressionAlgorithm(RCCResourceLibrary::parseCompressionAlgorithm(parser.value(compressionAlgoOption), &errorMsg)); if (formatVersion < 3 && library.compressionAlgorithm() == RCCResourceLibrary::CompressionAlgorithm::Zstd) - errorMsg = QLatin1String("Zstandard compression requires format version 3 or higher"); + errorMsg = "Zstandard compression requires format version 3 or higher"_L1; if (parser.isSet(nocompressOption)) library.setCompressionAlgorithm(RCCResourceLibrary::CompressionAlgorithm::None); if (parser.isSet(noZstdOption)) @@ -266,25 +268,25 @@ int runRcc(int argc, char *argv[]) library.setFormat(RCCResourceLibrary::Binary); if (parser.isSet(generatorOption)) { auto value = parser.value(generatorOption); - if (value == QLatin1String("cpp")) { + if (value == "cpp"_L1) { library.setFormat(RCCResourceLibrary::C_Code); - } else if (value == QLatin1String("python")) { + } else if (value == "python"_L1) { library.setFormat(RCCResourceLibrary::Python_Code); - } else if (value == QLatin1String("python2")) { // ### fixme Qt 7: remove + } else if (value == "python2"_L1) { // ### fixme Qt 7: remove qWarning("Format python2 is no longer supported, defaulting to python."); library.setFormat(RCCResourceLibrary::Python_Code); } else { - errorMsg = QLatin1String("Invalid generator: ") + value; + errorMsg = "Invalid generator: "_L1 + value; } } if (parser.isSet(passOption)) { - if (parser.value(passOption) == QLatin1String("1")) + if (parser.value(passOption) == "1"_L1) library.setFormat(RCCResourceLibrary::Pass1); - else if (parser.value(passOption) == QLatin1String("2")) + else if (parser.value(passOption) == "2"_L1) library.setFormat(RCCResourceLibrary::Pass2); else - errorMsg = QLatin1String("Pass number must be 1 or 2"); + errorMsg = "Pass number must be 1 or 2"_L1; } if (parser.isSet(namespaceOption)) library.setUseNameSpace(!library.useNameSpace()); @@ -297,7 +299,7 @@ int runRcc(int argc, char *argv[]) const QStringList filenamesIn = parser.positionalArguments(); for (const QString &file : filenamesIn) { - if (file == QLatin1String("-")) + if (file == "-"_L1) continue; else if (!QFile::exists(file)) { qWarning("%s: File does not exist '%s'", argv[0], qPrintable(file)); @@ -349,7 +351,7 @@ int runRcc(int argc, char *argv[]) } - if (outFilename.isEmpty() || outFilename == QLatin1String("-")) { + if (outFilename.isEmpty() || outFilename == "-"_L1) { #ifdef Q_OS_WIN // Make sure fwrite to stdout doesn't do LF->CRLF if (library.format() == RCCResourceLibrary::Binary) @@ -397,7 +399,7 @@ int runRcc(int argc, char *argv[]) QFile depout; depout.setFileName(depFilename); - if (outFilename.isEmpty() || outFilename == QLatin1String("-")) { + if (outFilename.isEmpty() || outFilename == "-"_L1) { const QString msg = QString::fromUtf8("Unable to write depfile when outputting to stdout!\n"); errorDevice.write(msg.toUtf8()); return 1; diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index a01d5bc310..edd833ca31 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { CONSTANT_USENAMESPACE = 1, CONSTANT_COMPRESSLEVEL_DEFAULT = -1, @@ -445,14 +447,14 @@ qint64 RCCFileInfo::writeDataName(RCCResourceLibrary &lib, qint64 offset) /////////////////////////////////////////////////////////// RCCResourceLibrary::Strings::Strings() : - TAG_RCC(QLatin1String("RCC")), - TAG_RESOURCE(QLatin1String("qresource")), - TAG_FILE(QLatin1String("file")), - ATTRIBUTE_LANG(QLatin1String("lang")), - ATTRIBUTE_PREFIX(QLatin1String("prefix")), - ATTRIBUTE_ALIAS(QLatin1String("alias")), - ATTRIBUTE_THRESHOLD(QLatin1String("threshold")), - ATTRIBUTE_COMPRESS(QLatin1String("compress")), + TAG_RCC("RCC"_L1), + TAG_RESOURCE("qresource"_L1), + TAG_FILE("file"_L1), + ATTRIBUTE_LANG("lang"_L1), + ATTRIBUTE_PREFIX("prefix"_L1), + ATTRIBUTE_ALIAS("alias"_L1), + ATTRIBUTE_THRESHOLD("threshold"_L1), + ATTRIBUTE_COMPRESS("compress"_L1), ATTRIBUTE_COMPRESSALGO(QStringLiteral("compression-algorithm")) { } @@ -520,12 +522,12 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, case QXmlStreamReader::StartElement: if (reader.name() == m_strings.TAG_RCC) { if (!tokens.isEmpty()) - reader.raiseError(QLatin1String("expected <RCC> tag")); + reader.raiseError("expected <RCC> tag"_L1); else tokens.push(RccTag); } else if (reader.name() == m_strings.TAG_RESOURCE) { if (tokens.isEmpty() || tokens.top() != RccTag) { - reader.raiseError(QLatin1String("unexpected <RESOURCE> tag")); + reader.raiseError("unexpected <RESOURCE> tag"_L1); } else { tokens.push(ResourceTag); @@ -555,7 +557,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, } } else if (reader.name() == m_strings.TAG_FILE) { if (tokens.isEmpty() || tokens.top() != ResourceTag) { - reader.raiseError(QLatin1String("unexpected <FILE> tag")); + reader.raiseError("unexpected <FILE> tag"_L1); } else { tokens.push(FileTag); @@ -587,7 +589,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, reader.raiseError(errorString); } } else { - reader.raiseError(QString(QLatin1String("unexpected tag: %1")).arg(reader.name().toString())); + reader.raiseError(QString("unexpected tag: %1"_L1).arg(reader.name().toString())); } break; @@ -596,17 +598,17 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (!tokens.isEmpty() && tokens.top() == RccTag) tokens.pop(); else - reader.raiseError(QLatin1String("unexpected closing tag")); + reader.raiseError("unexpected closing tag"_L1); } else if (reader.name() == m_strings.TAG_RESOURCE) { if (!tokens.isEmpty() && tokens.top() == ResourceTag) tokens.pop(); else - reader.raiseError(QLatin1String("unexpected closing tag")); + reader.raiseError("unexpected closing tag"_L1); } else if (reader.name() == m_strings.TAG_FILE) { if (!tokens.isEmpty() && tokens.top() == FileTag) tokens.pop(); else - reader.raiseError(QLatin1String("unexpected closing tag")); + reader.raiseError("unexpected closing tag"_L1); } break; @@ -614,7 +616,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, if (reader.isWhitespace()) break; if (tokens.isEmpty() || tokens.top() != FileTag) { - reader.raiseError(QLatin1String("unexpected text")); + reader.raiseError("unexpected text"_L1); } else { QString fileName = reader.text().toString(); if (fileName.isEmpty()) { @@ -626,7 +628,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, alias = fileName; alias = QDir::cleanPath(alias); - while (alias.startsWith(QLatin1String("../"))) + while (alias.startsWith("../"_L1)) alias.remove(0, 3); alias = QDir::cleanPath(m_resourceRoot) + prefix + alias; @@ -643,8 +645,7 @@ bool RCCResourceLibrary::interpretResourceFile(QIODevice *inputDevice, QDirIterator it(dir, QDirIterator::FollowSymlinks|QDirIterator::Subdirectories); while (it.hasNext()) { it.next(); - if (it.fileName() == QLatin1String(".") - || it.fileName() == QLatin1String("..")) + if (it.fileName() == "."_L1 || it.fileName() == ".."_L1) continue; filePaths.append(it.filePath()); } @@ -793,8 +794,8 @@ bool RCCResourceLibrary::readFiles(bool listMode, QIODevice &errorDevice) QFile fileIn; QString fname = m_fileNames.at(i); QString pwd; - if (fname == QLatin1String("-")) { - fname = QLatin1String("(stdin)"); + if (fname == "-"_L1) { + fname = "(stdin)"_L1; pwd = QDir::currentPath(); fileIn.setFileName(fname); if (!fileIn.open(stdin, QIODevice::ReadOnly)) { @@ -868,21 +869,21 @@ RCCResourceLibrary::ResourceDataFileMap RCCResourceLibrary::resourceDataFileMap( RCCResourceLibrary::CompressionAlgorithm RCCResourceLibrary::parseCompressionAlgorithm(QStringView value, QString *errorMsg) { - if (value == QLatin1String("best")) + if (value == "best"_L1) return CompressionAlgorithm::Best; - if (value == QLatin1String("zlib")) { + if (value == "zlib"_L1) { #ifdef QT_NO_COMPRESS - *errorMsg = QLatin1String("zlib support not compiled in"); + *errorMsg = "zlib support not compiled in"_L1; #else return CompressionAlgorithm::Zlib; #endif - } else if (value == QLatin1String("zstd")) { + } else if (value == "zstd"_L1) { #if QT_CONFIG(zstd) return CompressionAlgorithm::Zstd; #else - *errorMsg = QLatin1String("Zstandard support not compiled in"); + *errorMsg = "Zstandard support not compiled in"_L1; #endif - } else if (value != QLatin1String("none")) { + } else if (value != "none"_L1) { *errorMsg = QString::fromLatin1("Unknown compression algorithm '%1'").arg(value); } diff --git a/src/tools/tracegen/etw.cpp b/src/tools/tracegen/etw.cpp index 7363236c5f..894eef6b22 100644 --- a/src/tools/tracegen/etw.cpp +++ b/src/tools/tracegen/etw.cpp @@ -47,9 +47,11 @@ #include <qtextstream.h> #include <quuid.h> +using namespace Qt::StringLiterals; + static inline QString providerVar(const QString &providerName) { - return providerName + QLatin1String("_provider"); + return providerName + "_provider"_L1; } static void writeEtwMacro(QTextStream &stream, const Tracepoint::Field &field) diff --git a/src/tools/tracegen/helpers.cpp b/src/tools/tracegen/helpers.cpp index aa34f81b75..29ca955b4f 100644 --- a/src/tools/tracegen/helpers.cpp +++ b/src/tools/tracegen/helpers.cpp @@ -40,6 +40,8 @@ #include "helpers.h" #include <qdebug.h> +using namespace Qt::StringLiterals; + QString includeGuard(const QString &filename) { QString guard = filename.toUpper(); @@ -60,7 +62,7 @@ static QString joinArguments(const QList<Tracepoint::Argument> &args, T joinFunc for (const Tracepoint::Argument &arg : args) { if (!first) - ret += QLatin1String(", "); + ret += ", "_L1; ret += joinFunction(arg); @@ -83,7 +85,7 @@ QString formatParameterList(const QList<Tracepoint::Argument> &args, ParamType t QString ret; for (const Tracepoint::Argument &arg : args) - ret += QLatin1String(", ") + arg.name; + ret += ", "_L1 + arg.name; return ret; } diff --git a/src/tools/tracegen/provider.cpp b/src/tools/tracegen/provider.cpp index 7e40d7de0e..5fa93bf8a9 100644 --- a/src/tools/tracegen/provider.cpp +++ b/src/tools/tracegen/provider.cpp @@ -46,6 +46,8 @@ #include <qregularexpression.h> #include <qstring.h> +using namespace Qt::StringLiterals; + #ifdef TRACEGEN_DEBUG #include <qdebug.h> @@ -197,10 +199,10 @@ static Tracepoint::Field::BackendType backendType(QString rawType) rawType = rawType.trimmed(); rawType.replace(QStringLiteral(" "), QStringLiteral("_")); - if (rawType == QLatin1String("char_ptr")) + if (rawType == "char_ptr"_L1) return Tracepoint::Field::String; - if (rawType.endsWith(QLatin1String("_ptr"))) + if (rawType.endsWith("_ptr"_L1)) return Tracepoint::Field::Pointer; return backendType(rawType); @@ -280,10 +282,10 @@ Provider parseProvider(const QString &filename) for (int lineNumber = 1; !s.atEnd(); ++lineNumber) { QString line = s.readLine().trimmed(); - if (line == QLatin1String("{")) { + if (line == "{"_L1) { parsingPrefixText = true; continue; - } else if (parsingPrefixText && line == QLatin1String("}")) { + } else if (parsingPrefixText && line == "}"_L1) { parsingPrefixText = false; continue; } else if (parsingPrefixText) { diff --git a/src/tools/windeployqt/elfreader.cpp b/src/tools/windeployqt/elfreader.cpp index f375f5841d..aa5be67d31 100644 --- a/src/tools/windeployqt/elfreader.cpp +++ b/src/tools/windeployqt/elfreader.cpp @@ -32,6 +32,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /* This is a copy of the ELF reader contained in Qt Creator (src/libs/utils), * extended by the dependencies() function to read out the dependencies of a dynamic executable. */ @@ -185,7 +187,7 @@ ElfReader::Result ElfReader::readIt() // || (sizeof(void*) == 8 && bits != 64)) { // if (errorString) // *errorString = QLibrary::QStringLiteral("'%1' is an invalid ELF object (%2)") - // .arg(m_binary).arg(QLatin1String("wrong cpu architecture")); + // .arg(m_binary).arg("wrong cpu architecture"_L1); // return Corrupt; // } @@ -245,7 +247,7 @@ ElfReader::Result ElfReader::readIt() // if ((soff + e_shentsize) > fdlen || soff % 4 || soff == 0) { // m_errorString = QLibrary::QStringLiteral("'%1' is an invalid ELF object (%2)") // .arg(m_binary) -// .arg(QLatin1String("shstrtab section header seems to be at %1")) +// .arg("shstrtab section header seems to be at %1"_L1) // .arg(QString::number(soff, 16)); // return Corrupt; // } diff --git a/src/tools/windeployqt/main.cpp b/src/tools/windeployqt/main.cpp index 9cf7ff9aa1..d3b821c088 100644 --- a/src/tools/windeployqt/main.cpp +++ b/src/tools/windeployqt/main.cpp @@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum QtModule #if defined(Q_COMPILER_CLASS_ENUM) || defined(Q_CC_MSVC) : quint64 @@ -200,14 +202,14 @@ static QByteArray formatQtModules(quint64 mask, bool option = false) static Platform platformFromMkSpec(const QString &xSpec) { - if (xSpec == QLatin1String("linux-g++")) + if (xSpec == "linux-g++"_L1) return Unix; - if (xSpec.startsWith(QLatin1String("win32-"))) { - if (xSpec.contains(QLatin1String("clang-g++"))) + if (xSpec.startsWith("win32-"_L1)) { + if (xSpec.contains("clang-g++"_L1)) return WindowsDesktopClangMinGW; - if (xSpec.contains(QLatin1String("clang-msvc++"))) + if (xSpec.contains("clang-msvc++"_L1)) return WindowsDesktopClangMsvc; - return xSpec.contains(QLatin1String("g++")) ? WindowsDesktopMinGW : WindowsDesktopMsvc; + return xSpec.contains("g++"_L1) ? WindowsDesktopMinGW : WindowsDesktopMsvc; } return UnknownPlatform; } @@ -306,10 +308,10 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse using OptionPtrVector = QList<CommandLineOptionPtr>; parser->setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); - parser->setApplicationDescription(QStringLiteral("Qt Deploy Tool ") + QLatin1String(QT_VERSION_STR) - + QLatin1String("\n\nThe simplest way to use windeployqt is to add the bin directory of your Qt\n" + parser->setApplicationDescription(QStringLiteral("Qt Deploy Tool ") + QT_VERSION_STR ""_L1 + + "\n\nThe simplest way to use windeployqt is to add the bin directory of your Qt\n" "installation (e.g. <QT_DIR\\bin>) to the PATH variable and then run:\n windeployqt <path-to-app-binary>\n\n" - "If your application uses Qt Quick, run:\n windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>")); + "If your application uses Qt Quick, run:\n windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>"_L1); const QCommandLineOption helpOption = parser->addHelpOption(); parser->addVersionOption(); @@ -429,7 +431,7 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse parser->addOption(suppressSoftwareRasterizerOption); QCommandLineOption listOption(QStringLiteral("list"), - QLatin1String("Print only the names of the files copied.\n" + "Print only the names of the files copied.\n" "Available options:\n" " source: absolute path of the source files\n" " target: absolute path of the target files\n" @@ -437,7 +439,7 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse " to the target directory\n" " mapping: outputs the source and the relative\n" " target, suitable for use within an\n" - " Appx mapping file"), + " Appx mapping file"_L1, QStringLiteral("option")); parser->addOption(listOption); @@ -664,7 +666,7 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse options->binaries.append(path); } } - options->translationsDirectory = options->directory + QLatin1String("/translations"); + options->translationsDirectory = options->directory + "/translations"_L1; return 0; } @@ -686,13 +688,13 @@ static inline QString helpText(const QCommandLineParser &p) QString result = p.helpText(); // Replace the default-generated text which is too long by a short summary // explaining how to enable single libraries. - const int moduleStart = result.indexOf(QLatin1String("\n --bluetooth")); - const int argumentsStart = result.lastIndexOf(QLatin1String("\nArguments:")); + const qsizetype moduleStart = result.indexOf("\n --bluetooth"_L1); + const qsizetype argumentsStart = result.lastIndexOf("\nArguments:"_L1); if (moduleStart >= argumentsStart) return result; - QString moduleHelp = QLatin1String( + QString moduleHelp = "\n\nQt libraries can be added by passing their name (-xml) or removed by passing\n" - "the name prepended by --no- (--no-xml). Available libraries:\n"); + "the name prepended by --no- (--no-xml). Available libraries:\n"_L1; moduleHelp += lineBreak(QString::fromLatin1(formatQtModules(0xFFFFFFFFFFFFFFFFull, true))); moduleHelp += u'\n'; result.replace(moduleStart, argumentsStart - moduleStart, moduleHelp); @@ -702,7 +704,7 @@ static inline QString helpText(const QCommandLineParser &p) static inline bool isQtModule(const QString &libName) { // Match Standard modules named Qt6XX.dll - if (libName.size() < 3 || !libName.startsWith(QLatin1String("Qt"), Qt::CaseInsensitive)) + if (libName.size() < 3 || !libName.startsWith("Qt"_L1, Qt::CaseInsensitive)) return false; const QChar version = libName.at(2); return version.isDigit() && (version.toLatin1() - '0') == QT_VERSION_MAJOR; @@ -719,8 +721,8 @@ static bool findDependentQtLibraries(const QString &qtBinDir, const QString &bin if (directDependencyCount) *directDependencyCount = 0; if (!readExecutable(binary, platform, errorMessage, &dependentLibs, wordSize, isDebug, machineArch)) { - errorMessage->prepend(QLatin1String("Unable to find dependent libraries of ") + - QDir::toNativeSeparators(binary) + QLatin1String(" :")); + errorMessage->prepend("Unable to find dependent libraries of "_L1 + + QDir::toNativeSeparators(binary) + " :"_L1); return false; } // Filter out the Qt libraries. Note that depends.exe finds libs from optDirectory if we @@ -766,7 +768,7 @@ static QString pdbFileName(QString libraryFileName) const qsizetype lastDot = libraryFileName.lastIndexOf(u'.') + 1; if (lastDot <= 0) return QString(); - libraryFileName.replace(lastDot, libraryFileName.size() - lastDot, QLatin1String("pdb")); + libraryFileName.replace(lastDot, libraryFileName.size() - lastDot, "pdb"_L1); return libraryFileName; } static inline QStringList qmlCacheFileFilters() @@ -883,7 +885,7 @@ static quint64 qtModule(QString module, const QString &infix) const qsizetype lastSlashPos = module.lastIndexOf(u'/'); if (lastSlashPos > 0) module.remove(0, lastSlashPos + 1); - if (module.startsWith(QLatin1String("lib"))) + if (module.startsWith("lib"_L1)) module.remove(0, 3); int endPos = infix.isEmpty() ? -1 : module.lastIndexOf(infix); if (endPos == -1) @@ -912,7 +914,7 @@ QStringList findQtPlugins(quint64 *usedQtModules, quint64 disabledQtModules, return QStringList(); QDir pluginsDir(qtPluginsDirName); QStringList result; - const QFileInfoList &pluginDirs = pluginsDir.entryInfoList(QStringList(QLatin1String("*")), QDir::Dirs | QDir::NoDotAndDotDot); + const QFileInfoList &pluginDirs = pluginsDir.entryInfoList(QStringList("*"_L1), QDir::Dirs | QDir::NoDotAndDotDot); for (const QFileInfo &subDirFi : pluginDirs) { const QString subDirName = subDirFi.fileName(); const quint64 module = qtModuleForPlugin(subDirName); @@ -922,13 +924,13 @@ QStringList findQtPlugins(quint64 *usedQtModules, quint64 disabledQtModules, : debugMatchModeIn; QDir subDir(subDirFi.absoluteFilePath()); // Filter out disabled plugins - if ((disabledPlugins & QtVirtualKeyboardPlugin) && subDirName == QLatin1String("virtualkeyboard")) + if ((disabledPlugins & QtVirtualKeyboardPlugin) && subDirName == "virtualkeyboard"_L1) continue; - if (disabledQtModules & QtQmlToolingModule && subDirName == QLatin1String("qmltooling")) + if (disabledQtModules & QtQmlToolingModule && subDirName == "qmltooling"_L1) continue; // Filter for platform or any. QString filter; - const bool isPlatformPlugin = subDirName == QLatin1String("platforms"); + const bool isPlatformPlugin = subDirName == "platforms"_L1; if (isPlatformPlugin) { switch (platform) { case WindowsDesktopMsvc: @@ -942,13 +944,13 @@ QStringList findQtPlugins(quint64 *usedQtModules, quint64 disabledQtModules, break; } } else { - filter = QLatin1String("*"); + filter = "*"_L1; } const QStringList plugins = findSharedLibraries(subDir, platform, debugMatchMode, filter); for (const QString &plugin : plugins) { // Filter out disabled plugins if ((disabledPlugins & QtVirtualKeyboardPlugin) - && plugin.startsWith(QLatin1String("qtvirtualkeyboardplugin"))) { + && plugin.startsWith("qtvirtualkeyboardplugin"_L1)) { continue; } const QString pluginPath = subDir.absoluteFilePath(plugin); @@ -1149,7 +1151,7 @@ static QStringList compilerRunTimeLibs(Platform platform, bool isDebug, unsigned if (vcRedistDir.cd(vcDebugRedistDir()) && vcRedistDir.cd(machineArchString)) { const QStringList names = vcRedistDir.entryList(QStringList(QStringLiteral("Microsoft.VC*.DebugCRT")), QDir::Dirs); if (!names.isEmpty() && vcRedistDir.cd(names.first())) { - const QFileInfoList &dlls = vcRedistDir.entryInfoList(QStringList(QLatin1String("*.dll"))); + const QFileInfoList &dlls = vcRedistDir.entryInfoList(QStringList("*.dll"_L1)); for (const QFileInfo &dll : dlls) redistFiles.append(dll.absoluteFilePath()); } @@ -1493,7 +1495,7 @@ static DeployResult deploy(const Options &options, const QMap<QString, QString> options.directory : options.pluginDirectory; QDir dir(targetPath); if (!dir.exists() && !dir.mkpath(QStringLiteral("."))) { - *errorMessage = QLatin1String("Cannot create ") + + *errorMessage = "Cannot create "_L1 + QDir::toNativeSeparators(dir.absolutePath()) + u'.'; return result; } @@ -1642,7 +1644,7 @@ QT_USE_NAMESPACE int main(int argc, char **argv) { QCoreApplication a(argc, argv); - QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR)); + QCoreApplication::setApplicationVersion(QT_VERSION_STR ""_L1); const QByteArray qtBinPath = QFile::encodeName(QDir::toNativeSeparators(QCoreApplication::applicationDirPath())); QByteArray path = qgetenv("PATH"); diff --git a/src/tools/windeployqt/qmlutils.cpp b/src/tools/windeployqt/qmlutils.cpp index f51462b2df..62af9e12f3 100644 --- a/src/tools/windeployqt/qmlutils.cpp +++ b/src/tools/windeployqt/qmlutils.cpp @@ -39,6 +39,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + bool operator==(const QmlImportScanResult::Module &m1, const QmlImportScanResult::Module &m2) { return m1.className.isEmpty() ? m1.name == m2.name : m1.className == m2.className; @@ -128,7 +130,7 @@ QmlImportScanResult runQmlImportScanner(const QString &directory, const QStringL const int childCount = array.count(); for (int c = 0; c < childCount; ++c) { const QJsonObject object = array.at(c).toObject(); - if (object.value(QStringLiteral("type")).toString() == QLatin1String("module")) { + if (object.value(QStringLiteral("type")).toString() == "module"_L1) { const QString path = object.value(QStringLiteral("path")).toString(); if (!path.isEmpty()) { QmlImportScanResult::Module module; diff --git a/src/tools/windeployqt/utils.cpp b/src/tools/windeployqt/utils.cpp index 9dfff9dbd0..5781d2d8f6 100644 --- a/src/tools/windeployqt/utils.cpp +++ b/src/tools/windeployqt/utils.cpp @@ -55,12 +55,14 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + int optVerboseLevel = 1; bool isBuildDirectory(Platform platform, const QString &dirName) { return (platform.testFlag(Msvc) || platform.testFlag(ClangMsvc)) - && (dirName == QLatin1String("debug") || dirName == QLatin1String("release")); + && (dirName == "debug"_L1 || dirName == "release"_L1); } // Create a symbolic link by changing to the source directory to make sure the @@ -175,7 +177,7 @@ QString findSdkTool(const QString &tool) QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(u';'); const QByteArray sdkDir = qgetenv("WindowsSdkDir"); if (!sdkDir.isEmpty()) - paths.prepend(QDir::cleanPath(QString::fromLocal8Bit(sdkDir)) + QLatin1String("/Tools/x64")); + paths.prepend(QDir::cleanPath(QString::fromLocal8Bit(sdkDir)) + "/Tools/x64"_L1); return QStandardPaths::findExecutable(tool, paths); } @@ -737,14 +739,14 @@ static inline MsvcDebugRuntimeResult checkMsvcDebugRuntime(const QStringList &de { for (const QString &lib : dependentLibraries) { qsizetype pos = 0; - if (lib.startsWith(QLatin1String("MSVCR"), Qt::CaseInsensitive) - || lib.startsWith(QLatin1String("MSVCP"), Qt::CaseInsensitive) - || lib.startsWith(QLatin1String("VCRUNTIME"), Qt::CaseInsensitive)) { + if (lib.startsWith("MSVCR"_L1, Qt::CaseInsensitive) + || lib.startsWith("MSVCP"_L1, Qt::CaseInsensitive) + || lib.startsWith("VCRUNTIME"_L1, Qt::CaseInsensitive)) { qsizetype lastDotPos = lib.lastIndexOf(u'.'); pos = -1 == lastDotPos ? 0 : lastDotPos - 1; } - if (pos > 0 && lib.contains(QLatin1String("_app"), Qt::CaseInsensitive)) + if (pos > 0 && lib.contains("_app"_L1, Qt::CaseInsensitive)) pos -= 4; if (pos) |