Browse Source

Merge pull request #14140 from glassez/namespace

Use nested namespaces definition syntax
adaptive-webui-19844
Vladimir Golovnev 4 years ago committed by GitHub
parent
commit
08e0349ca3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/base/utils/bytearray.h
  2. 5
      src/base/utils/foreignapps.h
  3. 5
      src/base/utils/fs.h
  4. 5
      src/base/utils/gzip.h
  5. 5
      src/base/utils/io.h
  6. 5
      src/base/utils/misc.h
  7. 5
      src/base/utils/net.h
  8. 5
      src/base/utils/password.h
  9. 5
      src/base/utils/random.h
  10. 5
      src/base/utils/string.h

5
src/base/utils/bytearray.h

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

5
src/base/utils/foreignapps.h

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

5
src/base/utils/fs.h

@ -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
}
} }

5
src/base/utils/gzip.h

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

5
src/base/utils/io.h

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

5
src/base/utils/misc.h

@ -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
}
} }

5
src/base/utils/net.h

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

5
src/base/utils/password.h

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

5
src/base/utils/random.h

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

5
src/base/utils/string.h

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

Loading…
Cancel
Save