GUID

Description

struct Tinman.Core.Util.GUID

Helper class for generating 128-bit globally unique identifiers (GUIDs).

GUIDs are usually given in the following form: {00000000-0000-0000-0000-000000000000}

Public / Constants

Zero


public static readonly attribute Zero → (GUID)

An all-zero GUID: {00000000-0000-0000-0000-000000000000}

Public / Constructors

Digest


[Pure]
public static method Digest → (1)

values in : IEnumerable<string>

The string list.

returns → GUID

The GUID.

Digests the given string values and returns a GUID as a result.

From

3 overloads


public static method From1 → (1)

guid in : string

[not-null]
The GUID string (see remarks).

returns → GUID

The GUID value.

Creates a new instance of GUID from the given GUID string.

GUID strings are required to match the following grammar:

guid      := '{' parts '}' | '"' parts '"' | '\'' parts '\'' | parts ;

parts     := hex-digit[8] '-' hex-digit[4] '-' hex-digit[4] '-' hex-digit[4] '-' hex-digit[12] ;

hex-digit := '0'..'9' | 'a'..'f' | 'A'..'F' ;
ValidatingException

If the given guid in string is malformed.


public static method From2 → (1)

buffer in : ByteBuffer

[not-null]
The byte buffer.

returns → GUID

The GUID value.

Creates a new instance of GUID from the next 16 bytes in the given buffer (see ByteOrder.BigEndian).


public static method From3 → (2)

bytes in : int8 [ ]

[not-null]
The byte array.

offset opt : int32 = 0

Offset into bytes in to first byte.

returns → GUID

The GUID value.

Creates a new instance of GUID from the bytes in the given array (see ByteOrder.BigEndian).

Generate


[ThreadSafe]
public static method Generate → ()

returns → GUID

The generated value. Will never be equal to Zero.

Generates a new GUID value.

This method uses a simple hashing algorithm for generating reasonable good GUID values. To do so, it digests the following information:

The following values are used to increase randomness:

  • An internal global counter, incremented by each call to Generate.

  • An internal global RandomNumber instance, yielding the random seed bits for the GUID value.

If higher quality GUID values are required, please resort to native OS functions, for example:

  • CoCreateGuid (WinAPI)

  • uuid_generate (Linux)

GUID


public constructor GUID → (2)

first in : int64

The first 64-bit part of the GUID.

second in : int64

The second 64-bit part of the GUID.

Creates a new instance of GUID.

{00000000-0000-0000-0000-000000000000}
 ........ .... .... .... ............
 \__/          \__/ \__/         \__/
  MSB           LSB  MSB          LSB
   \_____________/    \____________/
        first             second

Public / Methods

Process


public method Process → (1)

codec in : IBlockCodec

[not-null]
The block codec to use. The codec should have a block size of 16 bytes.

returns → GUID

The resulting GUID.

Processes this GUID with the given block codec.

To​Buffer

2 overloads


[OwnerReturn]
public method ToBuffer1 → ()

returns → ByteBuffer

The byte buffer that contains this GUID between its position and limit.

Converts this GUID into a sequence of bytes.


public method ToBuffer2 → (1)

buffer in : ByteBuffer

[not-null]
Output byte buffer.

Converts this GUID into a sequence of bytes (see ByteOrder.BigEndian).

The bytes of this GUID will be appended to the given byte buffer.

To​Bytes


public method ToBytes → (2)

bytes opt : int8 [ ] = null

Output byte array or null.

offset opt : int32 = 0

[>=0]
Offset into bytes opt to first byte to write.

returns → int8 [ ]

The byte array that contains this GUID, beginning at offset opt.

Converts this GUID into a sequence of bytes (see ByteOrder.BigEndian).

Public / Attributes

First


public readonly attribute First → (int64)

The first 64-bit part of the GUID.

Second


public readonly attribute Second → (int64)

The second 64-bit part of the GUID.

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializer<GUID>)

The serialization helper object for values of GUID.