From 2dd0c8bf5d2d981ca768e76ce6a631659ea102b5 Mon Sep 17 00:00:00 2001 From: Robert Adam Date: Wed, 10 Nov 2021 09:15:48 +0100 Subject: [PATCH] REFAC(client): Don't use class as namespace The EnvUtils class only served as a namespace (containing static functions). Thus, it makes more sense to convert EnvUtils into an actual namespace. --- src/EnvUtils.cpp | 8 ++++++-- src/EnvUtils.h | 27 ++++++++++++++------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/EnvUtils.cpp b/src/EnvUtils.cpp index 507df81c8..7dce1095d 100644 --- a/src/EnvUtils.cpp +++ b/src/EnvUtils.cpp @@ -7,7 +7,9 @@ #include -QString EnvUtils::getenv(QString name) { +namespace EnvUtils { + +QString getenv(QString name) { #ifdef Q_OS_WIN QByteArray buf; size_t requiredSize = 0; @@ -43,7 +45,7 @@ QString EnvUtils::getenv(QString name) { #endif } -bool EnvUtils::setenv(QString name, QString value) { +bool setenv(QString name, QString value) { #ifdef Q_OS_WIN return _wputenv_s(reinterpret_cast< const wchar_t * >(name.utf16()), reinterpret_cast< const wchar_t * >(value.utf16())) @@ -53,3 +55,5 @@ bool EnvUtils::setenv(QString name, QString value) { return ::setenv(name.toLocal8Bit().constData(), value.toLocal8Bit().constData(), OVERWRITE) == 0; #endif } + +}; // namespace EnvUtils diff --git a/src/EnvUtils.h b/src/EnvUtils.h index b5a5da102..1cd454963 100644 --- a/src/EnvUtils.h +++ b/src/EnvUtils.h @@ -8,19 +8,20 @@ #include -class EnvUtils { -public: - // getenv is a wrapper around _wgetenv_s (on Windows) - // and getenv (on everything else). - // - // On Windows, it expects a Unicode environment -- so variables - // are expected to be UTF16. - // - // On everything else, it expects environment variables to use the - // locale-defined encoding. (From a Qt-perspective, we use toLocal8Bit/fromLocal8Bit.) - static QString getenv(QString name); +namespace EnvUtils { - static bool setenv(QString name, QString value); -}; +// getenv is a wrapper around _wgetenv_s (on Windows) +// and getenv (on everything else). +// +// On Windows, it expects a Unicode environment -- so variables +// are expected to be UTF16. +// +// On everything else, it expects environment variables to use the +// locale-defined encoding. (From a Qt-perspective, we use toLocal8Bit/fromLocal8Bit.) +QString getenv(QString name); + +bool setenv(QString name, QString value); + +}; // namespace EnvUtils #endif