Open 3D Engine AzCore API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Uuid Struct Reference

Public Types

enum  Variant {
  VAR_UNKNOWN = -1 , VAR_NCS = 0 , VAR_RFC_4122 = 2 , VAR_MICROSOFT = 6 ,
  VAR_RESERVED = 7
}
 
enum  Version {
  VER_UNKNOWN = -1 , VER_TIME = 1 , VER_DCE = 2 , VER_NAME_MD5 = 3 ,
  VER_RANDOM = 4 , VER_NAME_SHA1 = 5
}
 
using FixedString = AZStd::fixed_string< MaxStringBuffer >
 32 Uuid + 4 dashes + 2 brackets + 1 terminate
 
using iterator = AZStd::byte *
 
using const_iterator = const AZStd::byte *
 

Public Member Functions

constexpr Uuid (AZStd::string_view uuidString)
 
constexpr Uuid (const char *string, size_t stringLength)
 
constexpr bool IsNull () const
 
constexpr Variant GetVariant () const
 
constexpr Version GetVersion () const
 
constexpr int ToString (char *output, int outputSize, bool isBrackets=true, bool isDashes=true) const
 
template<size_t SizeT>
constexpr int ToString (char(&output)[SizeT], bool isBrackets=true, bool isDashes=true) const
 
template<class StringType >
constexpr StringType ToString (bool isBrackets=true, bool isDashes=true) const
 The only requirements is that StringType can be constructed from char* and it can copied.
 
template<class StringType >
constexpr void ToString (StringType &result, bool isBrackets=true, bool isDashes=true) const
 For inplace version we require resize, data and size members.
 
constexpr FixedString ToFixedString (bool isBrackets=true, bool isDashes=true) const
 
constexpr bool operator== (const Uuid &rhs) const
 
constexpr bool operator!= (const Uuid &rhs) const
 
constexpr bool operator< (const Uuid &rhs) const
 
constexpr bool operator> (const Uuid &rhs) const
 
constexpr bool operator<= (const Uuid &rhs) const
 
constexpr bool operator>= (const Uuid &rhs) const
 
constexpr Uuidoperator+= (const Uuid &rhs)
 
constexpr iterator begin ()
 
constexpr iterator end ()
 
constexpr const_iterator begin () const
 
constexpr const_iterator end () const
 
constexpr size_t size () const
 
constexpr size_t GetHash () const
 

Static Public Member Functions

static constexpr Uuid CreateNull ()
 
static constexpr Uuid CreateInvalid ()
 
static Uuid Create ()
 Create a Uuid (VAR_RFC_4122,VER_RANDOM)
 
static constexpr Uuid CreateString (const char *string, size_t stringLength)
 
static constexpr Uuid CreateString (AZStd::string_view uuidString)
 
static constexpr Uuid CreateStringPermissive (const char *string, size_t stringLength, bool skipWarnings=true)
 
static constexpr Uuid CreateStringPermissive (AZStd::string_view uuidString, bool skipWarnings=true)
 
static Uuid CreateRandom ()
 
static constexpr Uuid CreateName (AZStd::string_view name)
 Create a UUID based on a string name (sha1)
 
static constexpr Uuid CreateData (const AZStd::byte *data, size_t dataSize)
 Create a UUID based on a byte stream (sha1)
 
template<class R >
static constexpr auto CreateData (R &&dataSpan) -> AZStd::enable_if_t< AZStd::convertible_to< AZStd::ranges::range_value_t< R >, AZStd::byte >||decltype(static_cast< AZStd::byte >(AZStd::declval< AZStd::ranges::range_value_t< R >>()), AZStd::true_type())::value, Uuid >
 

Static Public Attributes

static constexpr int ValidUuidStringLength = 32
 
static constexpr size_t MaxStringBuffer = 39
 Number of characters (data only, no extra formatting) in a valid UUID string.
 

Friends

constexpr friend Uuid operator+ (const Uuid &lhs, const Uuid &rhs)
 Adding two UUID generates SHA1 Uuid based on the data of both uuids.
 

Member Function Documentation

◆ CreateString()

constexpr Uuid AZ::Uuid::CreateString ( const char *  string,
size_t  stringLength 
)
staticconstexpr

This function accepts the following formats, if format is invalid it returns a NULL UUID. 0123456789abcdef0123456789abcdef 01234567-89ab-cdef-0123-456789abcdef {01234567-89ab-cdef-0123-456789abcdef} {0123456789abcdef0123456789abcdef}

Parameters
stringpointer to a string buffer
stringLengthlength of the string in the buffer

◆ GetHash()

constexpr size_t AZ::Uuid::GetHash ( ) const
constexpr

Returns the first 8 bytes of the Uuid interpreted as a little endian size_t value as the hash value

◆ ToString() [1/2]

constexpr int AZ::Uuid::ToString ( char *  output,
int  outputSize,
bool  isBrackets = true,
bool  isDashes = true 
) const
constexpr

Outputs to a string in one of the following formats 0123456789abcdef0123456789abcdef 01234567-89ab-cdef-0123-456789abcdef {01234567-89ab-cdef-0123-456789abcdef} {0123456789abcdef0123456789abcdef}

Returns
if positive number of characters written to the buffer (including terminate) if negative the the number of characters required for output (nothing is writen to the output), including terminating character.

◆ ToString() [2/2]

template<size_t SizeT>
constexpr int AZ::Uuid::ToString ( char(&)  output[SizeT],
bool  isBrackets = true,
bool  isDashes = true 
) const
constexpr

Outputs to a string in one of the following formats 0123456789abcdef0123456789abcdef 01234567-89ab-cdef-0123-456789abcdef {01234567-89ab-cdef-0123-456789abcdef} {0123456789abcdef0123456789abcdef}

Returns
if positive number of characters written to the buffer (including terminate) if negative the the number of characters required for output (nothing is writen to the output), including terminating character.

The documentation for this struct was generated from the following files: