mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Use nested namespaces definition syntax
This commit is contained in:
parent
04a9ce6e81
commit
552ff0489d
@ -33,15 +33,12 @@
|
|||||||
|
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::ByteArray
|
||||||
{
|
{
|
||||||
namespace ByteArray
|
// Mimic QString::splitRef(sep, behavior)
|
||||||
{
|
QVector<QByteArray> splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior = QString::KeepEmptyParts);
|
||||||
// Mimic QString::splitRef(sep, behavior)
|
|
||||||
QVector<QByteArray> splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior = QString::KeepEmptyParts);
|
|
||||||
|
|
||||||
// Mimic QByteArray::mid(pos, len) but instead of returning a full-copy,
|
// Mimic QByteArray::mid(pos, len) but instead of returning a full-copy,
|
||||||
// we only return a partial view
|
// we only return a partial view
|
||||||
const QByteArray midView(const QByteArray &in, int pos, int len = -1);
|
const QByteArray midView(const QByteArray &in, int pos, int len = -1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -33,21 +33,18 @@
|
|||||||
|
|
||||||
#include "base/utils/version.h"
|
#include "base/utils/version.h"
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::ForeignApps
|
||||||
{
|
{
|
||||||
namespace ForeignApps
|
struct PythonInfo
|
||||||
{
|
{
|
||||||
struct PythonInfo
|
using Version = Utils::Version<quint8, 3, 1>;
|
||||||
{
|
|
||||||
using Version = Utils::Version<quint8, 3, 1>;
|
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
bool isSupportedVersion() const;
|
bool isSupportedVersion() const;
|
||||||
|
|
||||||
QString executableName;
|
QString executableName;
|
||||||
Version version;
|
Version version;
|
||||||
};
|
};
|
||||||
|
|
||||||
PythonInfo pythonInfo();
|
PythonInfo pythonInfo();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,47 +34,44 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::Fs
|
||||||
{
|
{
|
||||||
namespace Fs
|
/**
|
||||||
{
|
* Converts a path to a string suitable for display.
|
||||||
/**
|
* This function makes sure the directory separator used is consistent
|
||||||
* Converts a path to a string suitable for display.
|
* with the OS being run.
|
||||||
* This function makes sure the directory separator used is consistent
|
*/
|
||||||
* with the OS being run.
|
QString toNativePath(const QString &path);
|
||||||
*/
|
/**
|
||||||
QString toNativePath(const QString &path);
|
* Converts a path to a string suitable for processing.
|
||||||
/**
|
* This function makes sure the directory separator used is independent
|
||||||
* Converts a path to a string suitable for processing.
|
* from the OS being run so it is the same on all supported platforms.
|
||||||
* This function makes sure the directory separator used is independent
|
* Slash ('/') is used as "uniform" directory separator.
|
||||||
* from the OS being run so it is the same on all supported platforms.
|
*/
|
||||||
* Slash ('/') is used as "uniform" directory separator.
|
QString toUniformPath(const QString &path);
|
||||||
*/
|
|
||||||
QString toUniformPath(const QString &path);
|
|
||||||
|
|
||||||
QString fileExtension(const QString &filename);
|
QString fileExtension(const QString &filename);
|
||||||
QString fileName(const QString &filePath);
|
QString fileName(const QString &filePath);
|
||||||
QString folderName(const QString &filePath);
|
QString folderName(const QString &filePath);
|
||||||
qint64 computePathSize(const QString &path);
|
qint64 computePathSize(const QString &path);
|
||||||
bool sameFiles(const QString &path1, const QString &path2);
|
bool sameFiles(const QString &path1, const QString &path2);
|
||||||
QString toValidFileSystemName(const QString &name, bool allowSeparators = false
|
QString toValidFileSystemName(const QString &name, bool allowSeparators = false
|
||||||
, const QString &pad = QLatin1String(" "));
|
, const QString &pad = QLatin1String(" "));
|
||||||
bool isValidFileSystemName(const QString &name, bool allowSeparators = false);
|
bool isValidFileSystemName(const QString &name, bool allowSeparators = false);
|
||||||
qint64 freeDiskSpaceOnPath(const QString &path);
|
qint64 freeDiskSpaceOnPath(const QString &path);
|
||||||
QString branchPath(const QString &filePath, QString *removed = nullptr);
|
QString branchPath(const QString &filePath, QString *removed = nullptr);
|
||||||
bool sameFileNames(const QString &first, const QString &second);
|
bool sameFileNames(const QString &first, const QString &second);
|
||||||
QString expandPath(const QString &path);
|
QString expandPath(const QString &path);
|
||||||
QString expandPathAbs(const QString &path);
|
QString expandPathAbs(const QString &path);
|
||||||
bool isRegularFile(const QString &path);
|
bool isRegularFile(const QString &path);
|
||||||
|
|
||||||
bool smartRemoveEmptyFolderTree(const QString &path);
|
bool smartRemoveEmptyFolderTree(const QString &path);
|
||||||
bool forceRemove(const QString &filePath);
|
bool forceRemove(const QString &filePath);
|
||||||
void removeDirRecursive(const QString &path);
|
void removeDirRecursive(const QString &path);
|
||||||
|
|
||||||
QString tempPath();
|
QString tempPath();
|
||||||
|
|
||||||
#if !defined Q_OS_HAIKU
|
#if !defined Q_OS_HAIKU
|
||||||
bool isNetworkFileSystem(const QString &path);
|
bool isNetworkFileSystem(const QString &path);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,8 @@
|
|||||||
|
|
||||||
class QByteArray;
|
class QByteArray;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::Gzip
|
||||||
{
|
{
|
||||||
namespace Gzip
|
QByteArray compress(const QByteArray &data, int level = 6, bool *ok = nullptr);
|
||||||
{
|
QByteArray decompress(const QByteArray &data, bool *ok = nullptr);
|
||||||
QByteArray compress(const QByteArray &data, int level = 6, bool *ok = nullptr);
|
|
||||||
QByteArray decompress(const QByteArray &data, bool *ok = nullptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -34,47 +34,44 @@
|
|||||||
class QByteArray;
|
class QByteArray;
|
||||||
class QFileDevice;
|
class QFileDevice;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::IO
|
||||||
{
|
{
|
||||||
namespace IO
|
// A wrapper class that satisfy LegacyOutputIterator requirement
|
||||||
|
class FileDeviceOutputIterator
|
||||||
{
|
{
|
||||||
// A wrapper class that satisfy LegacyOutputIterator requirement
|
public:
|
||||||
class FileDeviceOutputIterator
|
// std::iterator_traits
|
||||||
|
using iterator_category = std::output_iterator_tag;
|
||||||
|
using difference_type = void;
|
||||||
|
using value_type = void;
|
||||||
|
using pointer = void;
|
||||||
|
using reference = void;
|
||||||
|
|
||||||
|
explicit FileDeviceOutputIterator(QFileDevice &device, const int bufferSize = (4 * 1024));
|
||||||
|
FileDeviceOutputIterator(const FileDeviceOutputIterator &other) = default;
|
||||||
|
~FileDeviceOutputIterator();
|
||||||
|
|
||||||
|
// mimic std::ostream_iterator behavior
|
||||||
|
FileDeviceOutputIterator &operator=(char c);
|
||||||
|
|
||||||
|
constexpr FileDeviceOutputIterator &operator*()
|
||||||
{
|
{
|
||||||
public:
|
return *this;
|
||||||
// std::iterator_traits
|
}
|
||||||
using iterator_category = std::output_iterator_tag;
|
|
||||||
using difference_type = void;
|
|
||||||
using value_type = void;
|
|
||||||
using pointer = void;
|
|
||||||
using reference = void;
|
|
||||||
|
|
||||||
explicit FileDeviceOutputIterator(QFileDevice &device, const int bufferSize = (4 * 1024));
|
constexpr FileDeviceOutputIterator &operator++()
|
||||||
FileDeviceOutputIterator(const FileDeviceOutputIterator &other) = default;
|
{
|
||||||
~FileDeviceOutputIterator();
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
// mimic std::ostream_iterator behavior
|
constexpr FileDeviceOutputIterator &operator++(int)
|
||||||
FileDeviceOutputIterator &operator=(char c);
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr FileDeviceOutputIterator &operator*()
|
private:
|
||||||
{
|
QFileDevice *m_device;
|
||||||
return *this;
|
std::shared_ptr<QByteArray> m_buffer;
|
||||||
}
|
int m_bufferSize;
|
||||||
|
};
|
||||||
constexpr FileDeviceOutputIterator &operator++()
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr FileDeviceOutputIterator &operator++(int)
|
|
||||||
{
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
QFileDevice *m_device;
|
|
||||||
std::shared_ptr<QByteArray> m_buffer;
|
|
||||||
int m_bufferSize;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -41,69 +41,66 @@ enum class ShutdownDialogAction;
|
|||||||
|
|
||||||
/* Miscellaneous functions that can be useful */
|
/* Miscellaneous functions that can be useful */
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::Misc
|
||||||
{
|
{
|
||||||
namespace Misc
|
// use binary prefix standards from IEC 60027-2
|
||||||
|
// see http://en.wikipedia.org/wiki/Kilobyte
|
||||||
|
enum class SizeUnit
|
||||||
{
|
{
|
||||||
// use binary prefix standards from IEC 60027-2
|
Byte, // 1024^0,
|
||||||
// see http://en.wikipedia.org/wiki/Kilobyte
|
KibiByte, // 1024^1,
|
||||||
enum class SizeUnit
|
MebiByte, // 1024^2,
|
||||||
{
|
GibiByte, // 1024^3,
|
||||||
Byte, // 1024^0,
|
TebiByte, // 1024^4,
|
||||||
KibiByte, // 1024^1,
|
PebiByte, // 1024^5,
|
||||||
MebiByte, // 1024^2,
|
ExbiByte // 1024^6,
|
||||||
GibiByte, // 1024^3,
|
// int64 is used for sizes and thus the next units can not be handled
|
||||||
TebiByte, // 1024^4,
|
// ZebiByte, // 1024^7,
|
||||||
PebiByte, // 1024^5,
|
// YobiByte, // 1024^8
|
||||||
ExbiByte // 1024^6,
|
};
|
||||||
// int64 is used for sizes and thus the next units can not be handled
|
|
||||||
// ZebiByte, // 1024^7,
|
|
||||||
// YobiByte, // 1024^8
|
|
||||||
};
|
|
||||||
|
|
||||||
QString parseHtmlLinks(const QString &rawText);
|
QString parseHtmlLinks(const QString &rawText);
|
||||||
|
|
||||||
void shutdownComputer(const ShutdownDialogAction &action);
|
void shutdownComputer(const ShutdownDialogAction &action);
|
||||||
|
|
||||||
QString osName();
|
QString osName();
|
||||||
QString boostVersionString();
|
QString boostVersionString();
|
||||||
QString libtorrentVersionString();
|
QString libtorrentVersionString();
|
||||||
QString opensslVersionString();
|
QString opensslVersionString();
|
||||||
QString zlibVersionString();
|
QString zlibVersionString();
|
||||||
|
|
||||||
QString unitString(SizeUnit unit, bool isSpeed = false);
|
QString unitString(SizeUnit unit, bool isSpeed = false);
|
||||||
|
|
||||||
// return the best user friendly storage unit (B, KiB, MiB, GiB, TiB)
|
// return the best user friendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||||
// value must be given in bytes
|
// value must be given in bytes
|
||||||
QString friendlyUnit(qint64 bytesValue, bool isSpeed = false);
|
QString friendlyUnit(qint64 bytesValue, bool isSpeed = false);
|
||||||
int friendlyUnitPrecision(SizeUnit unit);
|
int friendlyUnitPrecision(SizeUnit unit);
|
||||||
qint64 sizeInBytes(qreal size, SizeUnit unit);
|
qint64 sizeInBytes(qreal size, SizeUnit unit);
|
||||||
|
|
||||||
bool isPreviewable(const QString &extension);
|
bool isPreviewable(const QString &extension);
|
||||||
|
|
||||||
// Take a number of seconds and return a user-friendly
|
// Take a number of seconds and return a user-friendly
|
||||||
// time duration like "1d 2h 10m".
|
// time duration like "1d 2h 10m".
|
||||||
QString userFriendlyDuration(qlonglong seconds, qlonglong maxCap = -1);
|
QString userFriendlyDuration(qlonglong seconds, qlonglong maxCap = -1);
|
||||||
QString getUserIDString();
|
QString getUserIDString();
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString windowsSystemPath();
|
QString windowsSystemPath();
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T loadWinAPI(const QString &source, const char *funcName)
|
T loadWinAPI(const QString &source, const char *funcName)
|
||||||
{
|
{
|
||||||
QString path = windowsSystemPath();
|
QString path = windowsSystemPath();
|
||||||
if (!path.endsWith('\\'))
|
if (!path.endsWith('\\'))
|
||||||
path += '\\';
|
path += '\\';
|
||||||
|
|
||||||
path += source;
|
path += source;
|
||||||
|
|
||||||
auto pathWchar = std::make_unique<wchar_t[]>(path.length() + 1);
|
auto pathWchar = std::make_unique<wchar_t[]>(path.length() + 1);
|
||||||
path.toWCharArray(pathWchar.get());
|
path.toWCharArray(pathWchar.get());
|
||||||
|
|
||||||
return reinterpret_cast<T>(
|
return reinterpret_cast<T>(
|
||||||
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName));
|
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName));
|
||||||
}
|
|
||||||
#endif // Q_OS_WIN
|
|
||||||
}
|
}
|
||||||
|
#endif // Q_OS_WIN
|
||||||
}
|
}
|
||||||
|
@ -35,24 +35,21 @@ class QSslCertificate;
|
|||||||
class QSslKey;
|
class QSslKey;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::Net
|
||||||
{
|
{
|
||||||
namespace Net
|
using Subnet = QPair<QHostAddress, int>;
|
||||||
{
|
|
||||||
using Subnet = QPair<QHostAddress, int>;
|
|
||||||
|
|
||||||
bool isValidIP(const QString &ip);
|
bool isValidIP(const QString &ip);
|
||||||
Subnet parseSubnet(const QString &subnetStr, bool *ok = nullptr);
|
Subnet parseSubnet(const QString &subnetStr, bool *ok = nullptr);
|
||||||
bool canParseSubnet(const QString &subnetStr);
|
bool canParseSubnet(const QString &subnetStr);
|
||||||
bool isLoopbackAddress(const QHostAddress &addr);
|
bool isLoopbackAddress(const QHostAddress &addr);
|
||||||
bool isIPInRange(const QHostAddress &addr, const QVector<Subnet> &subnets);
|
bool isIPInRange(const QHostAddress &addr, const QVector<Subnet> &subnets);
|
||||||
QString subnetToString(const Subnet &subnet);
|
QString subnetToString(const Subnet &subnet);
|
||||||
QHostAddress canonicalIPv6Addr(const QHostAddress &addr);
|
QHostAddress canonicalIPv6Addr(const QHostAddress &addr);
|
||||||
|
|
||||||
const int MAX_SSL_FILE_SIZE = 1024 * 1024;
|
const int MAX_SSL_FILE_SIZE = 1024 * 1024;
|
||||||
QList<QSslCertificate> loadSSLCertificate(const QByteArray &data);
|
QList<QSslCertificate> loadSSLCertificate(const QByteArray &data);
|
||||||
bool isSSLCertificatesValid(const QByteArray &data);
|
bool isSSLCertificatesValid(const QByteArray &data);
|
||||||
QSslKey loadSSLKey(const QByteArray &data);
|
QSslKey loadSSLKey(const QByteArray &data);
|
||||||
bool isSSLKeyValid(const QByteArray &data);
|
bool isSSLKeyValid(const QByteArray &data);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -31,21 +31,18 @@
|
|||||||
class QByteArray;
|
class QByteArray;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::Password
|
||||||
{
|
{
|
||||||
namespace Password
|
// Implements constant-time comparison to protect against timing attacks
|
||||||
|
// Taken from https://crackstation.net/hashing-security.htm
|
||||||
|
bool slowEquals(const QByteArray &a, const QByteArray &b);
|
||||||
|
|
||||||
|
namespace PBKDF2
|
||||||
{
|
{
|
||||||
// Implements constant-time comparison to protect against timing attacks
|
QByteArray generate(const QString &password);
|
||||||
// Taken from https://crackstation.net/hashing-security.htm
|
QByteArray generate(const QByteArray &password);
|
||||||
bool slowEquals(const QByteArray &a, const QByteArray &b);
|
|
||||||
|
|
||||||
namespace PBKDF2
|
bool verify(const QByteArray &secret, const QString &password);
|
||||||
{
|
bool verify(const QByteArray &secret, const QByteArray &password);
|
||||||
QByteArray generate(const QString &password);
|
|
||||||
QByteArray generate(const QByteArray &password);
|
|
||||||
|
|
||||||
bool verify(const QByteArray &secret, const QString &password);
|
|
||||||
bool verify(const QByteArray &secret, const QByteArray &password);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::Random
|
||||||
{
|
{
|
||||||
namespace Random
|
uint32_t rand(uint32_t min = 0, uint32_t max = std::numeric_limits<uint32_t>::max());
|
||||||
{
|
|
||||||
uint32_t rand(uint32_t min = 0, uint32_t max = std::numeric_limits<uint32_t>::max());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -37,59 +37,56 @@
|
|||||||
|
|
||||||
class QStringRef;
|
class QStringRef;
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils::String
|
||||||
{
|
{
|
||||||
namespace String
|
QString fromDouble(double n, int precision);
|
||||||
|
|
||||||
|
int naturalCompare(const QString &left, const QString &right, const Qt::CaseSensitivity caseSensitivity);
|
||||||
|
template <Qt::CaseSensitivity caseSensitivity>
|
||||||
|
bool naturalLessThan(const QString &left, const QString &right)
|
||||||
{
|
{
|
||||||
QString fromDouble(double n, int precision);
|
return (naturalCompare(left, right, caseSensitivity) < 0);
|
||||||
|
}
|
||||||
|
|
||||||
int naturalCompare(const QString &left, const QString &right, const Qt::CaseSensitivity caseSensitivity);
|
QString wildcardToRegex(const QString &pattern);
|
||||||
template <Qt::CaseSensitivity caseSensitivity>
|
|
||||||
bool naturalLessThan(const QString &left, const QString &right)
|
template <typename T>
|
||||||
|
T unquote(const T &str, const QString "es = QChar('"'))
|
||||||
|
{
|
||||||
|
if (str.length() < 2) return str;
|
||||||
|
|
||||||
|
for (const QChar quote : quotes)
|
||||||
{
|
{
|
||||||
return (naturalCompare(left, right, caseSensitivity) < 0);
|
if (str.startsWith(quote) && str.endsWith(quote))
|
||||||
|
return str.mid(1, (str.length() - 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString wildcardToRegex(const QString &pattern);
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
bool parseBool(const QString &string, bool defaultValue);
|
||||||
T unquote(const T &str, const QString "es = QChar('"'))
|
|
||||||
{
|
|
||||||
if (str.length() < 2) return str;
|
|
||||||
|
|
||||||
for (const QChar quote : quotes)
|
QString join(const QVector<QStringRef> &strings, const QString &separator);
|
||||||
{
|
|
||||||
if (str.startsWith(quote) && str.endsWith(quote))
|
|
||||||
return str.mid(1, (str.length() - 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
template <typename T, typename std::enable_if_t<std::is_enum_v<T>, int> = 0>
|
||||||
}
|
QString fromEnum(const T &value)
|
||||||
|
{
|
||||||
|
static_assert(std::is_same_v<int, typename std::underlying_type_t<T>>,
|
||||||
|
"Enumeration underlying type has to be int.");
|
||||||
|
|
||||||
bool parseBool(const QString &string, bool defaultValue);
|
const auto metaEnum = QMetaEnum::fromType<T>();
|
||||||
|
return QString::fromLatin1(metaEnum.valueToKey(static_cast<int>(value)));
|
||||||
|
}
|
||||||
|
|
||||||
QString join(const QVector<QStringRef> &strings, const QString &separator);
|
template <typename T, typename std::enable_if_t<std::is_enum_v<T>, int> = 0>
|
||||||
|
T toEnum(const QString &serializedValue, const T &defaultValue)
|
||||||
|
{
|
||||||
|
static_assert(std::is_same_v<int, typename std::underlying_type_t<T>>,
|
||||||
|
"Enumeration underlying type has to be int.");
|
||||||
|
|
||||||
template <typename T, typename std::enable_if_t<std::is_enum_v<T>, int> = 0>
|
const auto metaEnum = QMetaEnum::fromType<T>();
|
||||||
QString fromEnum(const T &value)
|
bool ok = false;
|
||||||
{
|
const T value = static_cast<T>(metaEnum.keyToValue(serializedValue.toLatin1().constData(), &ok));
|
||||||
static_assert(std::is_same_v<int, typename std::underlying_type_t<T>>,
|
return (ok ? value : defaultValue);
|
||||||
"Enumeration underlying type has to be int.");
|
|
||||||
|
|
||||||
const auto metaEnum = QMetaEnum::fromType<T>();
|
|
||||||
return QString::fromLatin1(metaEnum.valueToKey(static_cast<int>(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, typename std::enable_if_t<std::is_enum_v<T>, int> = 0>
|
|
||||||
T toEnum(const QString &serializedValue, const T &defaultValue)
|
|
||||||
{
|
|
||||||
static_assert(std::is_same_v<int, typename std::underlying_type_t<T>>,
|
|
||||||
"Enumeration underlying type has to be int.");
|
|
||||||
|
|
||||||
const auto metaEnum = QMetaEnum::fromType<T>();
|
|
||||||
bool ok = false;
|
|
||||||
const T value = static_cast<T>(metaEnum.keyToValue(serializedValue.toLatin1().constData(), &ok));
|
|
||||||
return (ok ? value : defaultValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user