Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section describes functions that facilitate creation and use of  immutable universally unique identifiers (UUID).

...

For information about the uuid type inin Image Added, see Data Types(3.0).

uuidCreateFromHexString

This function takes a string representation of a UUID and converts it to the uuid type.

...

Info
titleExample - uuidCreateFromHexString

The following example converts a string to a UUID:

Code Block
languagetext
themeEclipse
uuid getUuid (string s) {
 uuid u = uuidCreateFromHexString(s);
 if(u==null) {
  //Incorrect UUID format
 } 
 return u;
} 


uuidCreateRandom

This function generates a random UUID.

...

ParameterDescription

Returns

A version 4 UUID (randomly generated UUID)


Info
titleExample - uuidCreateRandom

The following example creates a random UUID:

Code Block
languagetext
themeEclipse
uuid getUuid() {
    return uuidCreateRandom();   
}


uuidGetVersion

This function returns the version of a UUID. The version number describes the type of the UUID, e g time-based, DCE security, name-based, and randomly generated UUID. For instance, a UUID generated by the function uuidCreateRandom is 4 (randomly generated UUID).

Code Block
int uuidGetVersion ( uuid aUuid )

...

Info
titleExample - uuidGetVersion

The following example retrieves the version from a UUID:

Code Block
languagetext
themeEclipse
uuid getUuid (string s) {
    uuid u = uuidCreateFromHexString(s);
    if(u==null) {
        debug("Incorrect UUID format");
    } else if (uuidGetVersion(u)<0) {
        debug("Invalid UUID");
    }
    return u;
}


uuidString

This function converts a UUID to a string. 

...

Info
titleExample - uuidString

The result of the following two examples are identical:

Code Block
languagetext
themeEclipse
uuid aUuid = uuidCreateRandom();
string s = (string) aUuid;


Code Block
languagetext
themeEclipse
uuid aUuid = uuidCreateRandom();
string s = uuidString(aUuid);


Scroll pagebreak