BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlb::GuidUtil Struct Reference

#include <bdlb_guidutil.h>

Static Public Member Functions

static void generate (Guid *result, bsl::size_t numGuids=1)
 
static Guid generate ()
 
static void generateNonSecure (Guid *result, bsl::size_t numGuids=1)
 
static Guid generateNonSecure ()
 
static Guid generateFromName (const Guid &namespaceId, const bsl::string_view &name)
 
static Guid dnsNamespace ()
 
static Guid urlNamespace ()
 
static Guid oidNamespace ()
 
static Guid x500Namespace ()
 
static int guidFromString (Guid *result, const bsl::string_view &guidString)
 
static Guid guidFromString (const bsl::string_view &guidString)
 
static void guidToString (bsl::string *result, const Guid &guid)
 
static void guidToString (std::string *result, const Guid &guid)
 
static bsl::string guidToString (const Guid &guid)
 
static int getVersion (const bdlb::Guid &guid)
 
static bsls::Types::Uint64 getMostSignificantBits (const Guid &guid)
 Return the most significant 8 bytes of the specified guid.
 
static bsls::Types::Uint64 getLeastSignificantBits (const Guid &guid)
 Return the least significant 8 bytes of the specified guid.
 
static void generate (unsigned char *result, bsl::size_t numGuids=1)
 

Detailed Description

This struct provides a namespace for functions that create Universally Unique Identifiers per RFC 4122 (http://www.ietf.org/rfc/rfc4122.txt).

Member Function Documentation

◆ dnsNamespace()

static Guid bdlb::GuidUtil::dnsNamespace ( )
static

Return the pre-defined namespace ID for the DNS namespace from Appendix C of RFC 4122, for use with the generateFromName method when the name string is a fully-qualified domain name.

◆ generate() [1/3]

static Guid bdlb::GuidUtil::generate ( )
static

Generate and return a single GUID meeting the RFC 4122 version 4 specification, consisting of 122 randomly generated bits, two "variant" bits set to 10, and four "version" bits set to 0100.

◆ generate() [2/3]

void bdlb::GuidUtil::generate ( Guid result,
bsl::size_t  numGuids = 1 
)
inlinestatic

Generate a sequence of GUIDs meeting the RFC 4122 version 4 specification, and load the resulting GUIDs into the array referred to by the specified result. Optionally specify numGuids, indicating the number of GUIDs to load into the result array. If numGuids is not supplied, a default of 1 is used. An RFC 4122 version 4 GUID consists of 122 randomly generated bits, two "variant" bits set to 10, and four "version" bits set to 0100. The behavior is undefined unless result refers to a contiguous sequence of at least numGuids Guid objects.

◆ generate() [3/3]

static void bdlb::GuidUtil::generate ( unsigned char *  result,
bsl::size_t  numGuids = 1 
)
static
Deprecated:
Use generate(Guid *, size_t) instead.

Generate a sequence of GUIDs meeting the RFC 4122 version 4 specification, and load the bytes of the resulting GUIDs into the array referred to by the specified result. Optionally specify numGuids, indicating the number of GUIDs to load into the result array. If numGuids is not supplied, a default of 1 is used. An RFC 4122 version 4 GUID consists of 122 randomly generated bits, two "variant" bits set to 10, and four "version" bits set to 0100. The behavior is undefined unless result refers to a contiguous sequence of at least 16 * numGuids bytes.

◆ generateFromName()

static Guid bdlb::GuidUtil::generateFromName ( const Guid namespaceId,
const bsl::string_view name 
)
static

Generate and return a single GUID meeting the RFC 4122 version 5 specification from the specified namespaceId and name. namespaceId may (but need not) be one of the pre-defined namespace IDs. Note that this method is a pure function of its arguments.

◆ generateNonSecure() [1/2]

static Guid bdlb::GuidUtil::generateNonSecure ( )
static

Generate and return a single GUID meeting the RFC 4122 version 4 specification, consisting of 122 randomly generated bits, two "variant" bits set to 10, and four "version" bits set to 0100. Note that this function generates high quality, albeit not cryptographically secure, random numbers for GUIDs.

◆ generateNonSecure() [2/2]

static void bdlb::GuidUtil::generateNonSecure ( Guid result,
bsl::size_t  numGuids = 1 
)
static

Generate a sequence of GUIDs meeting the RFC 4122 version 4 specification, and load the resulting GUIDs into the array referred to by the specified result. Optionally specify numGuids, indicating the number of GUIDs to load into the result array. If numGuids is not supplied, a default of 1 is used. An RFC 4122 version 4 GUID consists of 122 randomly generated bits, two "variant" bits set to 10, and four "version" bits set to 0100. The behavior is undefined unless result refers to a contiguous sequence of at least numGuids Guid objects. Note that this function generates high quality, albeit not cryptographically secure, random numbers for GUIDs.

◆ getLeastSignificantBits()

static bsls::Types::Uint64 bdlb::GuidUtil::getLeastSignificantBits ( const Guid guid)
static

◆ getMostSignificantBits()

static bsls::Types::Uint64 bdlb::GuidUtil::getMostSignificantBits ( const Guid guid)
static

◆ getVersion()

int bdlb::GuidUtil::getVersion ( const bdlb::Guid guid)
inlinestatic

Return the version of the specified guid object. The behavior is undefined unless the contents of the guid object are compliant with RFC 4122.

◆ guidFromString() [1/2]

static Guid bdlb::GuidUtil::guidFromString ( const bsl::string_view guidString)
static

Parse the specified guidString (in {GUID String Format}) and return the converted GUID, or a default-constructed Guid if the string is improperly formatted.

◆ guidFromString() [2/2]

static int bdlb::GuidUtil::guidFromString ( Guid result,
const bsl::string_view guidString 
)
static

Parse the specified guidString (in {GUID String Format}) and load its value into the specified result. Return 0 if result successfully loaded, and a non-zero value otherwise.

◆ guidToString() [1/3]

static void bdlb::GuidUtil::guidToString ( bsl::string result,
const Guid guid 
)
static

◆ guidToString() [2/3]

static bsl::string bdlb::GuidUtil::guidToString ( const Guid guid)
static

Convert the specified guid into a string suitable for guidFromString, and return the string.

◆ guidToString() [3/3]

static void bdlb::GuidUtil::guidToString ( std::string *  result,
const Guid guid 
)
static

Serialize the specified guid into the specified result. The result string will be in a format suitable for guidFromString.

◆ oidNamespace()

static Guid bdlb::GuidUtil::oidNamespace ( )
static

Return the pre-defined namespace ID for the OID namespace from Appendix C of RFC 4122, for use with the generateFromName method when the name string is an ISO Object ID (OID).

◆ urlNamespace()

static Guid bdlb::GuidUtil::urlNamespace ( )
static

Return the pre-defined namespace ID for the URL namespace from Appendix C of RFC 4122, for use with the generateFromName method when the name string is a URL.

◆ x500Namespace()

static Guid bdlb::GuidUtil::x500Namespace ( )
static

Return the pre-defined namespace ID for the X500 namespace from Appendix C of RFC 4122, for use with the generateFromName method when the name string is an X.500 Distinguished Name.


The documentation for this struct was generated from the following file: