[libcalamares] Put the units in a nested namespace

- this makes it much easier to use the literal suffixes
  by using the namespace rather than individual operators.
main
Adriaan de Groot 4 years ago
parent 1ebb807624
commit ea63f48c31

@ -19,7 +19,7 @@
#include <QJsonDocument>
#include <QMutexLocker>
using CalamaresUtils::operator""_MiB;
using namespace CalamaresUtils::Units;
namespace Calamares
{

@ -18,6 +18,9 @@
namespace CalamaresUtils
{
namespace Units
{
/** User defined literals, 1_KB is 1 KiloByte (= 10^3 bytes) */
constexpr qint64 operator""_KB( unsigned long long m )
{
@ -54,40 +57,42 @@ constexpr qint64 operator""_GiB( unsigned long long m )
return operator""_MiB(m)*1024;
}
}
constexpr qint64
KBtoBytes( unsigned long long m )
{
return operator""_KB( m );
return Units::operator""_KB( m );
}
constexpr qint64
KiBtoBytes( unsigned long long m )
{
return operator""_KiB( m );
return Units::operator""_KiB( m );
}
constexpr qint64
MBtoBytes( unsigned long long m )
{
return operator""_MB( m );
return Units::operator""_MB( m );
}
constexpr qint64
MiBtoBytes( unsigned long long m )
{
return operator""_MiB( m );
return Units::operator""_MiB( m );
}
constexpr qint64
GBtoBytes( unsigned long long m )
{
return operator""_GB( m );
return Units::operator""_GB( m );
}
constexpr qint64
GiBtoBytes( unsigned long long m )
{
return operator""_GiB( m );
return Units::operator""_GiB( m );
}
constexpr qint64
@ -157,4 +162,5 @@ bytesToSectors( qint64 bytes, qint64 blocksize )
}
} // namespace CalamaresUtils
#endif

@ -18,7 +18,7 @@
#include <QFile>
using CalamaresUtils::operator""_MiB;
using namespace CalamaresUtils::Units;
QString
targetPrefix()

Loading…
Cancel
Save