Initial commit
Bigfoot / Sonarqube (push) Failing after 0s
Bigfoot / Build & Test Debug (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test Debug (Unity Build: ON) (push) Failing after 0s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: ON) (push) Failing after 0s
Bigfoot / Build & Test Release (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test Release (Unity Build: ON) (push) Failing after 0s
Bigfoot / Clang Format Checks (push) Failing after 0s
Bigfoot / Sonarqube (push) Failing after 0s
Bigfoot / Build & Test Debug (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test Debug (Unity Build: ON) (push) Failing after 0s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test RelWithDebInfo (Unity Build: ON) (push) Failing after 0s
Bigfoot / Build & Test Release (Unity Build: OFF) (push) Failing after 0s
Bigfoot / Build & Test Release (Unity Build: ON) (push) Failing after 0s
Bigfoot / Clang Format Checks (push) Failing after 0s
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/*********************************************************************
|
||||
* \file UUID.cpp
|
||||
*
|
||||
* \author Romain BOULLARD
|
||||
* \date October 2025
|
||||
*********************************************************************/
|
||||
#include <System/UUID/UUID.hpp>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
UUID UUID::NULL_UUID {"00000000-0000-0000-0000-000000000000"};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::UUID():
|
||||
m_uuid(ms_uuidGenerator())
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::UUID(const std::string_view p_string):
|
||||
UUID(NULL_UUID)
|
||||
{
|
||||
if (const std::optional<uuids::uuid> value = uuids::uuid::from_string(p_string); value.has_value())
|
||||
{
|
||||
m_uuid = value.value();
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::UUID(const std::span<const std::byte, UUID_BYTE_SIZE> p_raw)
|
||||
{
|
||||
const std::span<std::uint8_t, UUID_BYTE_SIZE> raw {
|
||||
const_cast<std::uint8_t*>(std::bit_cast<const std::uint8_t*>(p_raw.data())),
|
||||
UUID_BYTE_SIZE};
|
||||
|
||||
m_uuid = uuids::uuid {raw};
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::operator std::span<const std::byte, UUID::UUID_BYTE_SIZE>() const
|
||||
{
|
||||
return m_uuid.as_bytes();
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::operator std::string() const
|
||||
{
|
||||
return uuids::to_string(m_uuid);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
UUID::operator bool() const
|
||||
{
|
||||
return *this != NULL_UUID;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
bool UUID::operator<(const UUID& p_uuid) const
|
||||
{
|
||||
return m_uuid < p_uuid.m_uuid;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
std::mt19937 UUID::GetRandomGenerator()
|
||||
{
|
||||
std::random_device randomDevice;
|
||||
std::array<std::uint32_t, std::mt19937::state_size> seed {};
|
||||
std::generate(seed.begin(), seed.end(), std::reference_wrapper {randomDevice});
|
||||
std::seed_seq seedSeq(seed.begin(), seed.end());
|
||||
return std::mt19937 {seedSeq};
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
uuids::uuid_random_generator UUID::GetUUIDGenerator()
|
||||
{
|
||||
return uuids::uuid_random_generator {ms_randomGenerator};
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
Reference in New Issue
Block a user