Use nested namespaces definition syntax

This commit is contained in:
Vladimir Golovnev (Glassez) 2021-01-03 16:53:24 +03:00
parent 04a9ce6e81
commit 552ff0489d
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
10 changed files with 196 additions and 226 deletions

View file

@ -33,15 +33,12 @@
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 QByteArray::mid(pos, len) but instead of returning a full-copy,
// we only return a partial view
const QByteArray midView(const QByteArray &in, int pos, int len = -1);
}
}

View file

@ -33,10 +33,8 @@
#include "base/utils/version.h"
namespace Utils
namespace Utils::ForeignApps
{
namespace ForeignApps
{
struct PythonInfo
{
using Version = Utils::Version<quint8, 3, 1>;
@ -49,5 +47,4 @@ namespace Utils
};
PythonInfo pythonInfo();
}
}

View file

@ -34,10 +34,8 @@
#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
@ -76,5 +74,4 @@ namespace Utils
#if !defined Q_OS_HAIKU
bool isNetworkFileSystem(const QString &path);
#endif
}
}

View file

@ -31,11 +31,8 @@
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);
}
}

View file

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

View file

@ -41,10 +41,8 @@ enum class ShutdownDialogAction;
/* 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
@ -105,5 +103,4 @@ namespace Utils
::GetProcAddress(::LoadLibraryW(pathWchar.get()), funcName));
}
#endif // Q_OS_WIN
}
}

View file

@ -35,10 +35,8 @@ class QSslCertificate;
class QSslKey;
class QString;
namespace Utils
namespace Utils::Net
{
namespace Net
{
using Subnet = QPair<QHostAddress, int>;
bool isValidIP(const QString &ip);
@ -54,5 +52,4 @@ namespace Utils
bool isSSLCertificatesValid(const QByteArray &data);
QSslKey loadSSLKey(const QByteArray &data);
bool isSSLKeyValid(const QByteArray &data);
}
}

View file

@ -31,10 +31,8 @@
class QByteArray;
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);
@ -47,5 +45,4 @@ namespace Utils
bool verify(const QByteArray &secret, const QString &password);
bool verify(const QByteArray &secret, const QByteArray &password);
}
}
}

View file

@ -31,10 +31,7 @@
#include <cstdint>
#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());
}
}

View file

@ -37,10 +37,8 @@
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);
@ -91,5 +89,4 @@ namespace Utils
const T value = static_cast<T>(metaEnum.keyToValue(serializedValue.toLatin1().constData(), &ok));
return (ok ? value : defaultValue);
}
}
}