Gorgon Game Engine
SGuid Class Reference

This class represents a short globally unique identifier. More...

Classes

struct  CreateNewTag
 Tag to create a new GUID.
 

Public Member Functions

 SGuid ()
 Constructor for an empty guid. More...
 
 SGuid (const Byte data[8])
 Creates a new GUID from the given data. More...
 
 SGuid (const CreateNewTag &)
 Constructor to create a new guid. More...
 
 SGuid (std::istream &in)
 Reads a new GUID from the given stream. More...
 
 SGuid (unsigned long long data)
 Creates a new GUID from the given data. More...
 
 SGuid (unsigned serial, unsigned random, unsigned time)
 Creates a new GUID from the given data. More...
 
bool IsEmpty () const
 Returns whether this GUID is empty. More...
 
void Load (std::istream &Data)
 Loads the GUID from a given stream. More...
 
void LoadLong (std::istream &file)
 Loads a full length 16bit GUID from the given file. Used for back compatibility. More...
 
void New ()
 Generates a new GUID and assign that GUID to this one. More...
 
 operator bool () const
 Checks if the GUID is set. More...
 
 operator std::string () const
 Converts the GUID to a string. More...
 
bool operator!= (const SGuid &right) const
 Compares two GUIDs. More...
 
bool operator< (const SGuid &g) const
 Compares two GUIDs. More...
 
bool operator== (const SGuid &right) const
 Compares two GUIDs. More...
 
void Save (std::ostream &file) const
 Saves this GUID to file. More...
 
void Set (unsigned serial, unsigned random, unsigned time)
 Sets the GUID to the given components. More...
 

Public Attributes

union {
   Byte   Bytes [8]
 Allows byte-by-byte addressing of the guid. More...
 
   uint64_t   Integer
 Single integer value representing this guid. More...
 
}; 
 

Static Public Attributes

static const struct Gorgon::SGuid::CreateNewTag CreateNew
 
static const SGuid Empty
 Value for empty GUID. More...
 

Detailed Description

This class represents a short globally unique identifier.

Unlike full guids, this is not guranteed to be really unique. However, its almost impossible to find a duplicate. This object is 8 bytes long.

Constructor & Destructor Documentation

◆ SGuid() [1/6]

SGuid ( )

Constructor for an empty guid.

◆ SGuid() [2/6]

SGuid ( const CreateNewTag &  )
explicit

Constructor to create a new guid.

Use Gorgon::SGuid guid{Gorgon::SGuid::CreateNew} to create a new guid

References SGuid::New().

◆ SGuid() [3/6]

SGuid ( const Byte  data[8])

Creates a new GUID from the given data.

References SGuid::Bytes, and SGuid::Integer.

◆ SGuid() [4/6]

SGuid ( unsigned long long  data)

Creates a new GUID from the given data.

References SGuid::Integer.

◆ SGuid() [5/6]

SGuid ( unsigned  serial,
unsigned  random,
unsigned  time 
)

Creates a new GUID from the given data.

References SGuid::Set().

◆ SGuid() [6/6]

SGuid ( std::istream &  in)
explicit

Reads a new GUID from the given stream.

References SGuid::Load().

Member Function Documentation

◆ IsEmpty()

bool IsEmpty ( ) const

Returns whether this GUID is empty.

References SGuid::Integer.

◆ Load()

void Load ( std::istream &  Data)

Loads the GUID from a given stream.

References SGuid::Bytes, and Gorgon::Resource::GID::Data.

◆ LoadLong()

void LoadLong ( std::istream &  file)

Loads a full length 16bit GUID from the given file. Used for back compatibility.

References SGuid::Bytes.

◆ New()

void New ( )

Generates a new GUID and assign that GUID to this one.

References SGuid::Set().

◆ operator bool()

operator bool ( ) const

Checks if the GUID is set.

References SGuid::IsEmpty().

◆ operator std::string()

operator std::string ( ) const

Converts the GUID to a string.

References SGuid::Bytes.

◆ operator!=()

bool operator!= ( const SGuid right) const

Compares two GUIDs.

References SGuid::Integer.

◆ operator<()

bool operator< ( const SGuid g) const

Compares two GUIDs.

References SGuid::Integer.

◆ operator==()

bool operator== ( const SGuid right) const

Compares two GUIDs.

References SGuid::Integer.

◆ Save()

void Save ( std::ostream &  file) const

Saves this GUID to file.

References SGuid::Bytes.

◆ Set()

void Set ( unsigned  serial,
unsigned  random,
unsigned  time 
)

Sets the GUID to the given components.

References SGuid::Bytes.

Member Data Documentation

◆ @1

union { ... }

◆ Bytes

Byte Bytes[8]

Allows byte-by-byte addressing of the guid.

◆ CreateNew

const SGuid::CreateNewTag CreateNew
static

◆ Empty

const SGuid Empty
static

Value for empty GUID.

◆ Integer

uint64_t Integer

Single integer value representing this guid.


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