UuidInterface Class Reference

#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:

Uuid a; // creates an empty id. Uuid b( MAXON_SOURCE_LOCATION ); // creates a new unique id. Uuid c( "00000000-0000-0000-0000-000000000000" _s); // creates a new id with the given identifier. a.CreateId(); // creates a new unique id. a.Set( "00000000-0000-0000-0000-000000000000" _s); // sets the given identifier. String uuid = Uuid::CreateUuidString(); // creates a new id and returns it as a string.

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}

公共成员函数

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   比较 (const UuidInterface *uuid) const
MAXON_METHOD HashInt   GetHashCode () const

静态公共成员函数

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 ()

私有成员函数

  MAXON_INTERFACE_NONVIRTUAL ( UuidInterface , MAXON_REFERENCE_COPY_ON_WRITE , "net.maxon.interface.uuid")

成员函数文档编制

◆  MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( UuidInterface   ,
MAXON_REFERENCE_COPY_ON_WRITE   ,
"net.maxon.interface.uuid"   
)
private

◆  Alloc() [1/2]

static MAXON_METHOD UuidInterface * Alloc ( MAXON_SOURCE_LOCATION_DECLARATION   ,
const String uuid  
)
static
参数
[in] allocLocation Source location.
[in] uuid String with a valid uuid.

◆  Alloc() [2/2]

static MAXON_METHOD UuidInterface * Alloc ( MAXON_SOURCE_LOCATION_DECLARATION   ,
const UChar uuid ,
Int   uuidSize  
)
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.

◆  IsEmpty()

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.

◆  IsPopulated()

MAXON_FUNCTION Bool IsPopulated ( ) const

Returns whether the object is populated or not. Always the opposite of IsEmpty() .

◆  CreateId()

MAXON_METHOD Result <void> CreateId ( )

Creates a new uuid.

◆  Set() [1/2]

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.
返回
OK on success. Returns IllegalArgumentError if the id could not be parsed.

◆  Set() [2/2]

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.
返回
OK on success. Returns IllegalArgumentError if the id could not be parsed.

◆  Get()

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.
返回
OK on success.

◆  ToString()

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.
返回
String representation of the uuid.

◆  Compare()

MAXON_METHOD COMPARERESULT 比较 ( const UuidInterface uuid ) const

Compares the uuid against another uuid.

参数
[in] uuid The uuid to compare with.
返回
See COMPARERESULT.

◆  GetHashCode()

MAXON_METHOD HashInt GetHashCode ( ) const

Returns the hash code of the uuid. The return value is 0 if the object IsEmpty() .

◆  DescribeIO()

static MAXON_METHOD Result <void> DescribeIO ( const DataSerializeInterface stream )
static

Describes all elements of this class for I/O operations.

参数
[in] stream The stream that is used to register the class members.
返回
OK on success.

◆  CreateUuidString()

static MAXON_METHOD Result < String > CreateUuidString ( )
static

Creates a new uuid and returns the string of it.

MAXON_SOURCE_LOCATION
#define MAXON_SOURCE_LOCATION
定义: memoryallocationbase.h:66
String
定义: c4d_string.h:38