Quick Links: |
#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) |
static bsls::Types::Uint64 | getLeastSignificantBits (const Guid &guid) |
static void | generate (unsigned char *result, bsl::size_t numGuids=1) |
This struct
provides a namespace for functions that create Universally Unique Identifiers per RFC 4122 (http://www.ietf.org/rfc/rfc4122.txt).
static void bdlb::GuidUtil::generate | ( | 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.
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
.
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.
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.
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.
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.
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.
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).
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.
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.
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.
static void bdlb::GuidUtil::guidToString | ( | bsl::string * | result, | |
const Guid & | guid | |||
) | [static] |
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
.
static bsl::string bdlb::GuidUtil::guidToString | ( | const Guid & | guid | ) | [static] |
Convert the specified guid
into a string suitable for guidFromString
, and return the string.
static int bdlb::GuidUtil::getVersion | ( | const bdlb::Guid & | guid | ) | [static] |
Return the version of the specified guid
object. The behavior is undefined unless the contents of the guid
object are compliant with RFC 4122.
static bsls::Types::Uint64 bdlb::GuidUtil::getMostSignificantBits | ( | const Guid & | guid | ) | [static] |
Return the most significant 8 bytes of the specified guid
.
static bsls::Types::Uint64 bdlb::GuidUtil::getLeastSignificantBits | ( | const Guid & | guid | ) | [static] |
Return the least significant 8 bytes of the specified guid
.
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.