Skip to content

Commit

Permalink
More compile-time strings
Browse files Browse the repository at this point in the history
  • Loading branch information
oblivioncth committed Jul 23, 2023
1 parent a6f65d5 commit 5c4b3a0
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if(QX_DOCS)
add_subdirectory(doc)
endif()

#================ Build Documentation ======================
#================ Build Tests ======================
if(QX_TESTS)
enable_testing()
set(TESTS_TARGET_PREFIX ${PROJECT_NAMESPACE_LC})
Expand Down
10 changes: 5 additions & 5 deletions lib/io/src/qx-common-io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ IoOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos star

// If there was a trailing line break that isn't to be ignored, last line is actually blank
if(!readOptions.testFlag(IgnoreTrailingBreak) && fileTextStream.precedingBreak())
returnBuffer = "";
returnBuffer = u""_s;
else if(startPos.character().isLast()) // Last char is desired
returnBuffer = lastLine.right(1);
else // Some range of last line is desired
Expand Down Expand Up @@ -755,7 +755,7 @@ IoOpReport readTextFromFile(QString& returnBuffer, QFile& textFile, TextPos star

// If there was a trailing line break that isn't to be ignored, last line is actually blank
if(!readOptions.testFlag(IgnoreTrailingBreak) && fileTextStream.precedingBreak())
returnBuffer = "";
returnBuffer = u""_s;
else if(startPos.character().isLast()) // Last char is desired
returnBuffer = lastLine.right(1);
else // Some range of last line is desired
Expand Down Expand Up @@ -882,7 +882,7 @@ IoOpReport readTextFromFile(QStringList& returnBuffer, QFile& textFile, Index32

// If there was a trailing line break that isn't to be ignored, last line is actually blank
if(!readOptions.testFlag(IgnoreTrailingBreak) && fileTextStream.precedingBreak())
lastLine = "";
lastLine = u""_s;

// Add last line to list
returnBuffer.append(lastLine);
Expand Down Expand Up @@ -1179,7 +1179,7 @@ IoOpReport deleteTextFromFile(QFile& textFile, TextPos startPos, TextPos endPos)

// Determine beforeDeletion
if(startPos == TextPos::START) // (0,0)
beforeDeletion = "";
beforeDeletion = u""_s;
else if(startPos.character().isLast())
{
transientReport = readTextFromFile(beforeDeletion, textFile, TextPos::START, startPos);
Expand All @@ -1194,7 +1194,7 @@ IoOpReport deleteTextFromFile(QFile& textFile, TextPos startPos, TextPos endPos)

// Determine afterDeletion
if(endPos == TextPos::END)
afterDeletion = "";
afterDeletion = u""_s;
else if(endPos.character().isLast())
transientReport = readTextFromFile(afterDeletion, textFile, TextPos(endPos.line() + 1, 0), TextPos::END);
else
Expand Down
34 changes: 17 additions & 17 deletions lib/linux/src/qx-applicationdesktopentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,33 @@ QString ApplicationDesktopEntry::toString() const
QString entryString = DesktopEntry::toString();

// Add standard application key/values
entryString += keyValueString("DBusActivatable", mDBusActivatable) + '\n';
entryString += keyValueString(u"DBusActivatable"_s, mDBusActivatable) + '\n';
if(!mTryExec.isEmpty())
entryString += keyValueString("TryExec", mTryExec) + '\n';
entryString += keyValueString(u"TryExec"_s, mTryExec) + '\n';
if(!mExec.isEmpty())
entryString += keyValueString("Exec", mExec) + '\n';
entryString += keyValueString(u"Exec"_s, mExec) + '\n';
if(!mPath.isEmpty())
entryString += keyValueString("Path", mPath) + '\n';
entryString += keyValueString("Terminal", mTerminal) + '\n';
entryString += keyValueString(u"Path"_s, mPath) + '\n';
entryString += keyValueString(u"Terminal"_s, mTerminal) + '\n';
if(!mMimeTypes.isEmpty())
entryString += keyValueString("MimeType", mMimeTypes) + '\n';
entryString += keyValueString(u"MimeType"_s, mMimeTypes) + '\n';
if(!mCategories.isEmpty())
entryString += keyValueString("Categories", mCategories) + '\n';
entryString += keyValueString(u"Categories"_s, mCategories) + '\n';
if(!mImplements.isEmpty())
entryString += keyValueString("Implements", mImplements) + '\n';
entryString += keyValueString(u"Implements"_s, mImplements) + '\n';
if(!mKeywords.isEmpty())
entryString += keyValueString("Keywords", mKeywords) + '\n';
entryString += keyValueString("StartupNotify", mStartupNotify) + '\n';
entryString += keyValueString(u"Keywords"_s, mKeywords) + '\n';
entryString += keyValueString(u"StartupNotify"_s, mStartupNotify) + '\n';
if(!mStartupWMClass.isEmpty())
entryString += keyValueString("StartupWMClass", mStartupWMClass) + '\n';
entryString += keyValueString("PrefersNonDefaultGPU", mPrefersNonDefaultGPU) + '\n';
entryString += keyValueString("SingleMainWindow", mSingleMainWindow) + '\n';
entryString += keyValueString(u"StartupWMClass"_s, mStartupWMClass) + '\n';
entryString += keyValueString(u"PrefersNonDefaultGPU"_s, mPrefersNonDefaultGPU) + '\n';
entryString += keyValueString(u"SingleMainWindow"_s, mSingleMainWindow) + '\n';

// Add actions
if(!mActions.isEmpty())
{
// Add identifiers
entryString += keyValueString("Actions", mActions.keys()) + '\n';
entryString += keyValueString(u"Actions"_s, mActions.keys()) + '\n';
entryString += '\n';

// Add action groups
Expand All @@ -142,11 +142,11 @@ QString ApplicationDesktopEntry::toString() const

// Add group key/values
if(!action.name().isEmpty())
entryString += keyValueString("Name", action.name()) + '\n';
entryString += keyValueString(u"Name"_s, action.name()) + '\n';
if(!action.icon().isEmpty())
entryString += keyValueString("Icon", action.icon()) + '\n';
entryString += keyValueString(u"Icon"_s, action.icon()) + '\n';
if(!action.exec().isEmpty())
entryString += keyValueString("Exec", action.exec()) + '\n';
entryString += keyValueString(u"Exec"_s, action.exec()) + '\n';
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/linux/src/qx-linkdesktopentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ QString LinkDesktopEntry::toString() const
QString entryString = DesktopEntry::toString();

// Add link key/value
entryString += keyValueString("URL", mUrl.toString()) + '\n';
entryString += keyValueString(u"URL"_s, mUrl.toString()) + '\n';

return entryString;
}
Expand Down
16 changes: 8 additions & 8 deletions lib/network/include/qx/network/qx-downloadmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,18 @@ class QX_NETWORK_EXPORT AsyncDownloadManager: public QObject
static const qint64 SIZE_QUERY_TIMEOUT_MS = 500;

// Errors - Finish
static inline const QString ERR_TIMEOUT = "The data transfer failed to start before the timeout was reached.";
static inline const QString ERR_TIMEOUT = u"The data transfer failed to start before the timeout was reached."_s;

// Errors - Messages
static inline const QString SSL_ERR = "The following SSL issues occurred while attempting to download %1";
static inline const QString CONTINUE_QUES = "Continue downloading?";
static inline const QString AUTH_REQUIRED = "Authentication is required to connect to %1";
static inline const QString PROXY_AUTH_REQUIRED = "Authentication is required to connect to the proxy %1";
static inline const QString SSL_ERR = u"The following SSL issues occurred while attempting to download %1"_s;
static inline const QString CONTINUE_QUES = u"Continue downloading?"_s;
static inline const QString AUTH_REQUIRED = u"Authentication is required to connect to %1"_s;
static inline const QString PROXY_AUTH_REQUIRED = u"Authentication is required to connect to the proxy %1"_s;

// Prompts
static inline const QString PROMPT_AUTH = "Authentication is required for %1";
static inline const QString PROMPT_PRESHARED_AUTH = "Pre-shared key authentication is required for %1";
static inline const QString PROMPT_PROXY_AUTH = "Proxy authentication is required for %1";
static inline const QString PROMPT_AUTH = u"Authentication is required for %1"_s;
static inline const QString PROMPT_PRESHARED_AUTH = u"Pre-shared key authentication is required for %1"_s;
static inline const QString PROMPT_PROXY_AUTH = u"Proxy authentication is required for %1"_s;

//-Instance Members---------------------------------------------------------------------------------------------------
private:
Expand Down
30 changes: 16 additions & 14 deletions lib/windows/include/qx/windows/qx-filedetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
// Extra-component Includes
#include "qx/core/qx-versionnumber.h"

using namespace Qt::Literals::StringLiterals;

namespace Qx
{

Expand Down Expand Up @@ -51,20 +53,20 @@ class QX_WINDOWS_EXPORT FileDetails

//-Class Members----------------------------------------------------------------------------------------------------
private:
static inline const QString LANG_CODE_PAGE_QUERY = "\\VarFileInfo\\Translation";
static inline const QString SUB_BLOCK_BASE_TEMPLATE = "\\StringFileInfo\\%1%2\\";
static inline const QString ST_COMMENTS_QUERY = "Comments";
static inline const QString ST_COMPANY_NAME_QUERY = "CompanyName";
static inline const QString ST_FILE_DESCRIPTION_QUERY = "FileDescription";
static inline const QString ST_FILE_VERSION_QUERY = "FileVersion";
static inline const QString ST_INTERNAL_NAME_QUERY = "InternalName";
static inline const QString ST_LEGAL_COPYRIGHT_QUERY = "LegalCopyright";
static inline const QString ST_LEGAL_TRADEMARKS_QUERY = "LegalTrademarks";
static inline const QString ST_ORIGINAL_FILENAME_QUERY = "OriginalFilename";
static inline const QString ST_PRODUCT_NAME_QUERY = "ProductName";
static inline const QString ST_PRODUCT_VERSION_QUERY = "ProductVersion";
static inline const QString ST_PRIVATE_BUILD_QUERY = "PrivateBuild";
static inline const QString ST_SPECIAL_BUILD_QUERY = "SpecialBuild";
static inline const QString LANG_CODE_PAGE_QUERY = u"\\VarFileInfo\\Translation"_s;
static inline const QString SUB_BLOCK_BASE_TEMPLATE = u"\\StringFileInfo\\%1%2\\"_s;
static inline const QString ST_COMMENTS_QUERY = u"Comments"_s;
static inline const QString ST_COMPANY_NAME_QUERY = u"CompanyName"_s;
static inline const QString ST_FILE_DESCRIPTION_QUERY = u"FileDescription"_s;
static inline const QString ST_FILE_VERSION_QUERY = u"FileVersion"_s;
static inline const QString ST_INTERNAL_NAME_QUERY = u"InternalName"_s;
static inline const QString ST_LEGAL_COPYRIGHT_QUERY = u"LegalCopyright"_s;
static inline const QString ST_LEGAL_TRADEMARKS_QUERY = u"LegalTrademarks"_s;
static inline const QString ST_ORIGINAL_FILENAME_QUERY = u"OriginalFilename"_s;
static inline const QString ST_PRODUCT_NAME_QUERY = u"ProductName"_s;
static inline const QString ST_PRODUCT_VERSION_QUERY = u"ProductVersion"_s;
static inline const QString ST_PRIVATE_BUILD_QUERY = u"PrivateBuild"_s;
static inline const QString ST_SPECIAL_BUILD_QUERY = u"SpecialBuild"_s;

//-Instance Members-------------------------------------------------------------------------------------------------
private:
Expand Down

0 comments on commit 5c4b3a0

Please sign in to comment.