Detailed Description
The PGuid class represents a Globally Unique Identifier (GUID); PGuid instances are immutable (thread-safe).
A GUID is a 16-byte (128-bit) number generated by some algorithm that is meant to guarantee that the GUID will be unique in the distributed computing environment where it is used.
#include <PGuid.h>
Constructor & Destructor Documentation
◆ PGuid() [1/6]
PGuid::PGuid | ( | ) |
Constructs the null GUID "{00000000-0000-0000-0000-000000000000}".
- See also
- IsNull()
◆ PGuid() [2/6]
PGuid::PGuid | ( | const PGuid & | other | ) |
Constructs a shared copy of other.
◆ PGuid() [3/6]
|
explicit |
Constructs a GUID object from the string text, which must be formatted as five hex fields separated by '-': "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" or xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" where 'x' is a hex digit (letters can be lowercase or uppercase).
The curly braces shown here are optional, but it is normal to include them. If the conversion fails, an invalid GUID is created.
Note: trailing characters are ignored.
◆ PGuid() [4/6]
|
explicit |
Constructs a GUID object from the string text, which must be formatted as five hex fields separated by '-': "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" where 'x' is a hex digit (letters can be lowercase or uppercase).
The curly braces shown here are optional, but it is normal to include them. If the conversion fails, an invalid GUID is created.
Note: trailing characters are ignored.
◆ PGuid() [5/6]
PGuid::PGuid | ( | const papillon::uint8 | buffer[16] | ) |
Constructs a GUID from the binary representation of the GUID (a raw buffer of 16-bytes), as specified by RFC 4122.
◆ PGuid() [6/6]
PGuid::PGuid | ( | papillon::uint64 | storeId, |
papillon::uint64 | objectId | ||
) |
Constructs a GUID from a store id (64-bits) and an object id (64-bits).
◆ ~PGuid()
|
virtual |
Destroys this object.
Member Function Documentation
◆ CreateEntityId()
|
static |
Returns a new Global Unique Identifier (GUID) attached to the specified store and with an object id part set randomly.
◆ CreateFrom2Ids()
Creates a GUID from two other GUIDs.
◆ CreateFromMD5()
Creates a GUID from an MD5 string.
This is a direct loss-less conversion since the MD5 string is also 128 bits just like the GUID. Returns a null GUID if the string passed in is not a valid 32 character hex string.
◆ CreateUniqueId()
|
static |
Returns a new Global Unique Identifier (GUID); thread-safe.
This function can be used safely by multiple threads at the same time, i.e. several different threads will get different random ids.
◆ GetObjectId()
papillon::uint64 PGuid::GetObjectId | ( | ) | const |
Returns the object id from this guid (the last 8-bytes of this 128-bits id reinterpreted as an uint64).
◆ GetStoreId()
papillon::uint64 PGuid::GetStoreId | ( | ) | const |
Returns the store id from this guid (the first 8-bytes of this 128-bits id reinterpreted as an uint64).
◆ Invalid()
|
inlinestatic |
Returns the constant holding the invalid GUID (i.e.
{deaddead-dead-dead-dead-deaddeaddead}).
- See also
- IsValid()
- IsInvalid()
◆ IsInvalid()
bool PGuid::IsInvalid | ( | ) | const |
Returns true if this is the invalid GUID {deaddead-dead-dead-dead-deaddeaddead}; otherwise returns false.
◆ IsNull()
bool PGuid::IsNull | ( | ) | const |
Returns true if this is the null GUID {00000000-0000-0000-0000-000000000000}; otherwise returns false.
◆ IsNullObjectId()
bool PGuid::IsNullObjectId | ( | ) | const |
Returns true if the object id is null (0), false otherwise.
◆ IsNullStoreId()
bool PGuid::IsNullStoreId | ( | ) | const |
Returns true if the store id is null (0), false otherwise.
◆ IsUndefined()
bool PGuid::IsUndefined | ( | ) | const |
Returns true if this is the undefined GUID {ffffffff-ffff-ffff-ffff-ffffffffffff}; otherwise returns false.
◆ IsUndefinedObjectId()
bool PGuid::IsUndefinedObjectId | ( | ) | const |
Returns true if the object id is undefined (see UndefinedPartId()), false otherwise.
◆ IsUndefinedStoreId()
bool PGuid::IsUndefinedStoreId | ( | ) | const |
Returns true if the store id is undefined (see UndefinedPartId()), false otherwise.
◆ IsValid()
bool PGuid::IsValid | ( | ) | const |
Returns true if this is a valid GUID, i.e.
any guid different from {deaddead-dead-dead-dead-deaddeaddead}; otherwise returns false.
◆ Null()
|
inlinestatic |
◆ operator!=()
bool PGuid::operator!= | ( | const PGuid & | other | ) | const |
Returns true if this GUID is different from other; otherwise returns false.
◆ operator<()
bool PGuid::operator< | ( | const PGuid & | other | ) | const |
Compares this GUID with another one (order relation to be able to sort GUID).
◆ operator=()
◆ operator==()
bool PGuid::operator== | ( | const PGuid & | other | ) | const |
Returns true if this GUID is equal to other; otherwise returns false.
◆ ToByteArray()
PByteArray PGuid::ToByteArray | ( | ) | const |
Returns a byte-array representation (16 bytes) of this id.
◆ ToStringUnderscores()
PString PGuid::ToStringUnderscores | ( | ) | const |
Returns a string representation of this GUID using underscores as separators: "00000000_0000_0000_0000_000000000000".
◆ Undefined()
|
inlinestatic |
Returns the constant holding the undefined GUID (i.e.
{ffffffff-ffff-ffff-ffff-ffffffffffff}).
- See also
- IsUndefined()
◆ UndefinedPartId()
|
inlinestatic |
Returns the constant holding the undefined 64-bit id, which can be Store id or Object id.