1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-30 16:34:16 +00:00

Merge pull request #14140 from glassez/namespace

Use nested namespaces definition syntax
This commit is contained in:
Vladimir Golovnev 2021-01-04 08:12:43 +03:00 committed by GitHub
commit 08e0349ca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 196 additions and 226 deletions

View File

@ -33,15 +33,12 @@
class QByteArray; class QByteArray;
namespace Utils namespace Utils::ByteArray
{ {
namespace ByteArray
{
// Mimic QString::splitRef(sep, behavior) // Mimic QString::splitRef(sep, behavior)
QVector<QByteArray> splitToViews(const QByteArray &in, const QByteArray &sep, const QString::SplitBehavior behavior = QString::KeepEmptyParts); 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);
}
} }

View File

@ -33,10 +33,8 @@
#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>;
@ -49,5 +47,4 @@ namespace Utils
}; };
PythonInfo pythonInfo(); PythonInfo pythonInfo();
}
} }

View File

@ -34,10 +34,8 @@
#include <QString> #include <QString>
namespace Utils namespace Utils::Fs
{ {
namespace Fs
{
/** /**
* Converts a path to a string suitable for display. * Converts a path to a string suitable for display.
* This function makes sure the directory separator used is consistent * This function makes sure the directory separator used is consistent
@ -76,5 +74,4 @@ namespace Utils
#if !defined Q_OS_HAIKU #if !defined Q_OS_HAIKU
bool isNetworkFileSystem(const QString &path); bool isNetworkFileSystem(const QString &path);
#endif #endif
}
} }

View File

@ -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 compress(const QByteArray &data, int level = 6, bool *ok = nullptr);
QByteArray decompress(const QByteArray &data, bool *ok = nullptr); QByteArray decompress(const QByteArray &data, bool *ok = nullptr);
}
} }

View File

@ -34,10 +34,8 @@
class QByteArray; class QByteArray;
class QFileDevice; class QFileDevice;
namespace Utils namespace Utils::IO
{ {
namespace IO
{
// A wrapper class that satisfy LegacyOutputIterator requirement // A wrapper class that satisfy LegacyOutputIterator requirement
class FileDeviceOutputIterator class FileDeviceOutputIterator
{ {
@ -76,5 +74,4 @@ namespace Utils
std::shared_ptr<QByteArray> m_buffer; std::shared_ptr<QByteArray> m_buffer;
int m_bufferSize; int m_bufferSize;
}; };
}
} }

View File

@ -41,10 +41,8 @@ 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 // use binary prefix standards from IEC 60027-2
// see http://en.wikipedia.org/wiki/Kilobyte // see http://en.wikipedia.org/wiki/Kilobyte
enum class SizeUnit enum class SizeUnit
@ -105,5 +103,4 @@ namespace Utils
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName)); ::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName));
} }
#endif // Q_OS_WIN #endif // Q_OS_WIN
}
} }

View File

@ -35,10 +35,8 @@ 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);
@ -54,5 +52,4 @@ namespace Utils
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);
}
} }

View File

@ -31,10 +31,8 @@
class QByteArray; class QByteArray;
class QString; class QString;
namespace Utils namespace Utils::Password
{ {
namespace Password
{
// Implements constant-time comparison to protect against timing attacks // Implements constant-time comparison to protect against timing attacks
// Taken from https://crackstation.net/hashing-security.htm // Taken from https://crackstation.net/hashing-security.htm
bool slowEquals(const QByteArray &a, const QByteArray &b); bool slowEquals(const QByteArray &a, const QByteArray &b);
@ -47,5 +45,4 @@ namespace Utils
bool verify(const QByteArray &secret, const QString &password); bool verify(const QByteArray &secret, const QString &password);
bool verify(const QByteArray &secret, const QByteArray &password); bool verify(const QByteArray &secret, const QByteArray &password);
} }
}
} }

View File

@ -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());
}
} }

View File

@ -37,10 +37,8 @@
class QStringRef; class QStringRef;
namespace Utils namespace Utils::String
{ {
namespace String
{
QString fromDouble(double n, int precision); QString fromDouble(double n, int precision);
int naturalCompare(const QString &left, const QString &right, const Qt::CaseSensitivity caseSensitivity); int naturalCompare(const QString &left, const QString &right, const Qt::CaseSensitivity caseSensitivity);
@ -91,5 +89,4 @@ namespace Utils
const T value = static_cast<T>(metaEnum.keyToValue(serializedValue.toLatin1().constData(), &ok)); const T value = static_cast<T>(metaEnum.keyToValue(serializedValue.toLatin1().constData(), &ok));
return (ok ? value : defaultValue); return (ok ? value : defaultValue);
} }
}
} }