#include <uuid.h>
Creates an uuid object. The object will be constructed with no valid uuid. After calling CreateId() a new id is generated.
Examples how to create ids:
from: http://www.ietf.org/rfc/rfc4122.txt
One of the main reasons for using UUIDs is that no centralized authority is required to administer them (although one format uses IEEE 802 node identifiers, others do not). As a result, generation on demand can be completely automated, and used for a variety of purposes. The UUID generation algorithm described here supports very high allocation rates of up to 10 million per second per machine if necessary, so that they could even be used as transaction IDs.
UUIDs are of a fixed size (128 bits) which is reasonably small compared to other alternatives. This lends itself well to sorting, ordering, and hashing of all sorts, storing in databases, simple allocation, and ease of programming in general.
Since UUIDs are unique and persistent, they make excellent Uniform Resource Names. The unique ability to generate a new UUID without a registration process allows for UUIDs to be one of the URNs with the lowest minting cost.
@MAXON_ANNOTATION{refclass=false}
Public Member Functions | |
MAXON_METHOD Bool | IsEmpty () const |
MAXON_FUNCTION Bool | IsPopulated () const |
MAXON_METHOD Result< void > | CreateId () |
MAXON_METHOD Result< void > | Set (const String &uuid) |
MAXON_METHOD Result< void > | Set (const UChar *uuid, Int uuidSize) |
MAXON_METHOD Result< void > | Get (UChar *uuid, Int uuidSize) const |
MAXON_METHOD String | ToString (const FormatStatement *formatStatement=nullptr) const |
MAXON_METHOD COMPARERESULT | Compare (const UuidInterface *uuid) const |
MAXON_METHOD HashInt | GetHashCode () const |
MAXON_METHOD UniqueHash | GetUniqueHashCode () const |
Static Public Member Functions | |
static MAXON_METHOD UuidInterface * | Alloc (MAXON_SOURCE_LOCATION_DECLARATION, const String &uuid) |
static MAXON_METHOD UuidInterface * | Alloc (MAXON_SOURCE_LOCATION_DECLARATION, const UChar *uuid, Int uuidSize) |
static MAXON_METHOD Result< void > | DescribeIO (const DataSerializeInterface &stream) |
static MAXON_METHOD Result< String > | CreateUuidString () |
static MAXON_METHOD Result< void > | CreateUuid (UChar(&uuid)[16]) |
Private Member Functions | |
MAXON_INTERFACE_NONVIRTUAL (UuidInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.interface.uuid") | |
|
private |
|
static |
[in] | allocLocation | Source location. |
[in] | uuid | String with a valid uuid. |
|
static |
[in] | allocLocation | Source location. |
[in] | uuid | Pointer to memory of a uuid in big endian format. |
[in] | uuidSize | Size of the memory block that receives the uuid. |
MAXON_METHOD Bool IsEmpty | ( | ) | const |
Returns whether the object is empty or not. A Uuid is empty if it hasn't been constructed yet, or if a copy operation on the object failed, or if it just contains 0-values.
MAXON_FUNCTION Bool IsPopulated | ( | ) | const |
Returns whether the object is populated or not. Always the opposite of IsEmpty().
MAXON_METHOD Result<void> CreateId | ( | ) |
Creates a new uuid.
MAXON_METHOD Result<void> Set | ( | const String & | uuid | ) |
Sets a given uuid string. The id must be of the format "00000000-0000-0000-0000-000000000000".
[in] | uuid | String with a valid uuid. |
MAXON_METHOD Result<void> Set | ( | const UChar * | uuid, |
Int | uuidSize | ||
) |
Sets a given memory block of a uuid. The id must be 16 bytes long. Please note that native window functions return little endian for the first 3 components which is different to this call.
[in] | uuid | Pointer to memory of a uuid in big endian format. |
[in] | uuidSize | Size of the memory block that keeps the uuid. |
MAXON_METHOD Result<void> Get | ( | UChar * | uuid, |
Int | uuidSize | ||
) | const |
Gets a given memory block of a uuid. The id must be 16 bytes long. Please note that native window functions return little endian for the first 3 components which is different to this call.
[in] | uuid | Pointer to memory of a uuid in big endian format. |
[in] | uuidSize | Size of the memory block that receives the uuid. |
MAXON_METHOD String ToString | ( | const FormatStatement * | formatStatement = nullptr | ) | const |
Converts the uuid into a string. The format will be "00000000-0000-0000-0000-000000000000" and the letters will be uppercase.
[in] | formatStatement | Format statement for string formating. |
MAXON_METHOD COMPARERESULT Compare | ( | const UuidInterface * | uuid | ) | const |
Compares the uuid against another uuid.
[in] | uuid | The uuid to compare with. |
MAXON_METHOD HashInt GetHashCode | ( | ) | const |
Returns the hash code of the uuid. The return value is 0 if the object IsEmpty().
MAXON_METHOD UniqueHash GetUniqueHashCode | ( | ) | const |
Returns the 128-bit hash value of this @CLASS. The implementation ensures uniform distribution, so for practical purposes you can safely assume that two objects are equal if their hash values are equal.
|
static |
Describes all elements of this class for I/O operations.
[in] | stream | The stream that is used to register the class members. |
|
static |
Creates a new uuid and returns the string of it.
|
static |
Creates a new uuid and writes it to the raw buffer.
[out] | uuid | The raw 128 bits of the uuid are written to this buffer. |