EtcPal  0.4.1
ETC Platform Abstraction Layer (EtcPal)
View other versions:
Uuid Class Reference

Overview

A wrapper class for the EtcPal UUID type.

Provides C++ syntactic sugar for working with UUIDs. UUIDs are considered immutable after they are created, so there is no non-const access to the underlying data as of now.

Public Member Functions

 Uuid ()=default
 Constructs a null UUID by default.
 
 Uuid (const uint8_t *data) noexcept
 Construct a UUID from raw data. More...
 
constexpr Uuid (const EtcPalUuid &c_uuid) noexcept
 Construct a UUID copied from an instance of the C EtcPalUuid type.
 
Uuidoperator= (const EtcPalUuid &c_uuid) noexcept
 Assign an instance of the C EtcPalUuid type to an instance of this class.
 
constexpr const EtcPalUuidget () const noexcept
 Get a reference to the underlying C type.
 
const uint8_t * data () const noexcept
 Get the raw data of a UUID. More...
 
std::string ToString () const
 Convert the UUID to a string representation formatted per RFC 4122.
 
bool IsNull () const noexcept
 Check if a UUID is null (all 0's).
 
UuidVersion version () const noexcept
 Get the version type of a UUID. More...
 
UUID field accessors
uint32_t time_low () const noexcept
 Get the time_low portion of a UUID.
 
uint16_t time_mid () const noexcept
 Get the time_mid portion of a UUID.
 
uint16_t time_hi_and_version () const noexcept
 Get the time_hi_and_version portion of a UUID.
 
std::array< uint8_t, 8 > clock_seq_and_node () const noexcept
 Get the remaining portion of a UUID, including clock_seq_hi_and_res, clock_seq_low, and node.
 

Static Public Member Functions

static Uuid FromString (const char *uuid_str) noexcept
 Create a UUID from a string representation. More...
 
static Uuid FromString (const std::string &uuid_str) noexcept
 Create a UUID from a string representation. More...
 
static Uuid V1 () noexcept
 Generate and return a Version 1 UUID. More...
 
static Uuid V3 (const Uuid &ns, const void *name, size_t name_len) noexcept
 Generate and return a Version 3 UUID. More...
 
static Uuid V3 (const Uuid &ns, const char *name) noexcept
 Generate and return a Version 3 UUID. More...
 
static Uuid V3 (const Uuid &ns, const std::string &name) noexcept
 Generate and return a Version 3 UUID. More...
 
static Uuid V4 () noexcept
 Generate and return a Version 4 UUID. More...
 
static Uuid V5 (const Uuid &ns, const void *name, size_t name_len) noexcept
 Generate and return a Version 5 UUID. More...
 
static Uuid V5 (const Uuid &ns, const char *name) noexcept
 Generate and return a Version 5 UUID. More...
 
static Uuid V5 (const Uuid &ns, const std::string &name) noexcept
 Generate and return a Version 5 UUID. More...
 
static Uuid OsPreferred () noexcept
 Generate and return a UUID of the version preferred by the underlying OS. More...
 
static Uuid Device (const std::string &device_str, const uint8_t *mac_addr, uint32_t uuid_num) noexcept
 Generate and return a Device UUID. More...
 
static Uuid Device (const std::string &device_str, const std::array< uint8_t, 6 > &mac_addr, uint32_t uuid_num) noexcept
 Generate and return a Device UUID. More...
 

Constructor & Destructor Documentation

◆ Uuid()

Uuid ( const uint8_t *  data)
inlinenoexcept

Construct a UUID from raw data.

Parameters
dataThe raw data array, must be at least ETCPAL_UUID_BYTES in length.

Member Function Documentation

◆ data()

const uint8_t * data ( ) const
inlinenoexcept

Get the raw data of a UUID.

Returns
A pointer to an array of length ETCPAL_UUID_BYTES containing the UUID's data.

◆ Device() [1/2]

Uuid Device ( const std::string &  device_str,
const std::array< uint8_t, 6 > &  mac_addr,
uint32_t  uuid_num 
)
inlinestaticnoexcept

Generate and return a Device UUID.

See etcpal_generate_device_uuid() for more information.

◆ Device() [2/2]

Uuid Device ( const std::string &  device_str,
const uint8_t *  mac_addr,
uint32_t  uuid_num 
)
inlinestaticnoexcept

Generate and return a Device UUID.

See etcpal_generate_device_uuid() for more information.

◆ FromString() [1/2]

Uuid FromString ( const char *  uuid_str)
inlinestaticnoexcept

Create a UUID from a string representation.

Returns
A valid UUID on successful parse, or a null UUID on failure.

◆ FromString() [2/2]

Uuid FromString ( const std::string &  uuid_str)
inlinestaticnoexcept

Create a UUID from a string representation.

Returns
A valid UUID on successful parse, or a null UUID on failure.

◆ OsPreferred()

Uuid OsPreferred ( )
inlinestaticnoexcept

Generate and return a UUID of the version preferred by the underlying OS.

If not implemented, returns a null UUID. See etcpal_generate_os_preferred_uuid() for more information.

◆ V1()

Uuid V1 ( )
inlinestaticnoexcept

Generate and return a Version 1 UUID.

If not implemented, returns a null UUID. See etcpal_generate_v1_uuid() for more information.

◆ V3() [1/3]

Uuid V3 ( const Uuid ns,
const char *  name 
)
inlinestaticnoexcept

Generate and return a Version 3 UUID.

Parameters
nsUUID to use as a namespace.
nameA null-terminated C string representing the name to convert into a UUID.

See etcpal_generate_v3_uuid() for more information.

◆ V3() [2/3]

Uuid V3 ( const Uuid ns,
const std::string &  name 
)
inlinestaticnoexcept

Generate and return a Version 3 UUID.

Parameters
nsUUID to use as a namespace.
nameA string representing the name to convert into a UUID.

See etcpal_generate_v3_uuid() for more information.

◆ V3() [3/3]

Uuid V3 ( const Uuid ns,
const void *  name,
size_t  name_len 
)
inlinestaticnoexcept

Generate and return a Version 3 UUID.

See etcpal_generate_v3_uuid() for more information.

◆ V4()

Uuid V4 ( )
inlinestaticnoexcept

Generate and return a Version 4 UUID.

If not implemented, returns a null UUID. See etcpal_generate_v4_uuid() for more information.

◆ V5() [1/3]

Uuid V5 ( const Uuid ns,
const char *  name 
)
inlinestaticnoexcept

Generate and return a Version 5 UUID.

Parameters
nsUUID to use as a namespace.
nameA null-terminated C string representing the name to convert into a UUID.

See etcpal_generate_v5_uuid() for more information.

◆ V5() [2/3]

Uuid V5 ( const Uuid ns,
const std::string &  name 
)
inlinestaticnoexcept

Generate and return a Version 5 UUID.

Parameters
nsUUID to use as a namespace.
nameA string representing the name to convert into a UUID.

See etcpal_generate_v5_uuid() for more information.

◆ V5() [3/3]

Uuid V5 ( const Uuid ns,
const void *  name,
size_t  name_len 
)
inlinestaticnoexcept

Generate and return a Version 5 UUID.

See etcpal_generate_v5_uuid() for more information.

◆ version()

UuidVersion version ( ) const
inlinenoexcept

Get the version type of a UUID.

Returns
The UUID's version, or UuidVersion::Unknown if the version field is invalid.

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