Fix acronym naming standard
- Now follow standard that acronyms should only capitalize the first letter
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
#include "copium/util/UUID.h"
|
||||
#include "copium/util/Uuid.h"
|
||||
|
||||
#include "copium/util/Common.h"
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
|
||||
std::random_device UUID::randomDevice{};
|
||||
std::mt19937 UUID::randomGenerator{randomDevice()};
|
||||
std::uniform_int_distribution<uint64_t> UUID::randomDistribution{std::numeric_limits<uint64_t>::min(), std::numeric_limits<uint64_t>::max()};
|
||||
std::random_device Uuid::randomDevice{};
|
||||
std::mt19937 Uuid::randomGenerator{randomDevice()};
|
||||
std::uniform_int_distribution<uint64_t> Uuid::randomDistribution{std::numeric_limits<uint64_t>::min(), std::numeric_limits<uint64_t>::max()};
|
||||
|
||||
UUID::UUID()
|
||||
Uuid::Uuid()
|
||||
: msb{randomDistribution(randomGenerator)}, lsb{randomDistribution(randomGenerator)}
|
||||
{}
|
||||
|
||||
UUID::UUID(uint64_t msb, uint64_t lsb)
|
||||
Uuid::Uuid(uint64_t msb, uint64_t lsb)
|
||||
: msb{msb}, lsb{lsb}
|
||||
{}
|
||||
|
||||
UUID::UUID(const std::string& uuidString)
|
||||
Uuid::Uuid(const std::string& uuidString)
|
||||
: msb{0}, lsb{0}
|
||||
{
|
||||
CP_ASSERT(uuidString.size() == 36, "Invalid UUID string size: %s", uuidString.c_str());
|
||||
CP_ASSERT(uuidString.size() == 36, "Invalid Uuid string size: %s", uuidString.c_str());
|
||||
for (int i = 0; i < 18; i++)
|
||||
{
|
||||
if (i == 8 || i == 13) // skip "-"
|
||||
@@ -37,7 +37,7 @@ namespace Copium
|
||||
}
|
||||
}
|
||||
|
||||
std::string UUID::ToString() const
|
||||
std::string Uuid::ToString() const
|
||||
{
|
||||
std::string string;
|
||||
string.reserve(36);
|
||||
@@ -55,36 +55,36 @@ namespace Copium
|
||||
return string;
|
||||
}
|
||||
|
||||
bool UUID::operator==(const UUID& rhs)
|
||||
bool Uuid::operator==(const Uuid& rhs)
|
||||
{
|
||||
return msb == rhs.msb && lsb == rhs.lsb;
|
||||
}
|
||||
|
||||
bool UUID::operator!=(const UUID& rhs)
|
||||
bool Uuid::operator!=(const Uuid& rhs)
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
bool UUID::operator<(const UUID& rhs)
|
||||
bool Uuid::operator<(const Uuid& rhs)
|
||||
{
|
||||
if (msb != rhs.msb)
|
||||
return msb < rhs.msb;
|
||||
return lsb < rhs.lsb;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const UUID& uuid)
|
||||
std::ostream& operator<<(std::ostream& os, const Uuid& uuid)
|
||||
{
|
||||
return os << uuid.ToString();
|
||||
}
|
||||
|
||||
uint8_t UUID::HexToDec(char c) const
|
||||
uint8_t Uuid::HexToDec(char c) const
|
||||
{
|
||||
if (c >= '0' && c <= '9') return c - '0';
|
||||
if (c >= 'a' && c <= 'f') return c - 'a' + 10;
|
||||
CP_ABORT("Invalid char value: %c (%d)", c, (int)c);
|
||||
}
|
||||
|
||||
char UUID::DecToHex(uint8_t nibble) const
|
||||
char Uuid::DecToHex(uint8_t nibble) const
|
||||
{
|
||||
if (nibble >= 0 && nibble <= 9) return '0' + nibble;
|
||||
if (nibble >= 10 && nibble <= 15) return 'a' + nibble - 10;
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace Copium
|
||||
{
|
||||
class UUID
|
||||
class Uuid
|
||||
{
|
||||
private:
|
||||
uint64_t msb;
|
||||
@@ -15,18 +15,18 @@ namespace Copium
|
||||
static std::mt19937 randomGenerator;
|
||||
static std::uniform_int_distribution<uint64_t> randomDistribution;
|
||||
public:
|
||||
UUID();
|
||||
UUID(uint64_t msb, uint64_t lsb);
|
||||
Uuid();
|
||||
Uuid(uint64_t msb, uint64_t lsb);
|
||||
// Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
UUID(const std::string& uuidString);
|
||||
Uuid(const std::string& uuidString);
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
bool operator==(const UUID& rhs);
|
||||
bool operator!=(const UUID& rhs);
|
||||
bool operator<(const UUID& rhs);
|
||||
bool operator==(const Uuid& rhs);
|
||||
bool operator!=(const Uuid& rhs);
|
||||
bool operator<(const Uuid& rhs);
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const UUID& uuid);
|
||||
friend std::ostream& operator<<(std::ostream& os, const Uuid& uuid);
|
||||
|
||||
private:
|
||||
uint8_t HexToDec(char c) const;
|
||||
Reference in New Issue
Block a user