BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlb::Guid Class Reference

#include <bdlb_guid.h>

Public Types

enum  { k_GUID_NUM_BYTES = 16 }
 
enum  { k_GUID_NUM_32BITS = 4 }
 
enum  { k_GUID_NUM_CHARS = 36 }
 

Public Member Functions

 Guid ()
 
 ~Guid ()=default
 Destroy this object.
 
 Guid (const unsigned char(&buffer)[k_GUID_NUM_BYTES])
 
 Guid (unsigned long timeLow, unsigned short timeMid, unsigned short timeHiAndVersion, unsigned char clockSeqHiRes, unsigned char clockSeqLow, bsls::Types::Uint64 node)
 
 Guid (const Guid &original)=default
 
Guidoperator= (const Guid &rhs)=default
 
Guidoperator= (const unsigned char(&buffer)[k_GUID_NUM_BYTES])
 
Guidoperator= (const bsl::uint32_t(&buffer)[k_GUID_NUM_32BITS])
 
const unsigned char & operator[] (bsl::size_t offset) const
 
const unsigned char * begin () const
 
const unsigned char * data () const
 
const unsigned char * end () const
 
unsigned char clockSeqHi () const
 
unsigned char clockSeqHiRes () const
 
unsigned char clockSeqLow () const
 
bsls::Types::Uint64 node () const
 
unsigned short timeHi () const
 
unsigned short timeHiAndVersion () const
 
unsigned long timeLow () const
 
unsigned short timeMid () const
 
unsigned char variant () const
 
unsigned char version () const
 
void format (bsl::span< char, k_GUID_NUM_CHARS > buffer) const
 
bsl::ostream & print (bsl::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Friends

bool operator== (const Guid &lhs, const Guid &rhs)
 
bool operator!= (const Guid &lhs, const Guid &rhs)
 

Detailed Description

This class implements a value-semantic Guid type. Each object represents an unconstrained Guid object, but its uniqueness is not guaranteed, and this component provides no ability to generate a GUID.

This class provides a constructor and several accessors with names and parameters phrased using RFC 4122 field names. These names are used (by RFC 4122 and this component) as designators for parts of the GUID even when those names do not accurately describe the parts (for example, time low names bytes 0-3 of the GUID regardless of whether the values of those bytes come from a clock or are generated randomly).

See bdlb_guid

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
k_GUID_NUM_BYTES 

◆ anonymous enum

anonymous enum
Enumerator
k_GUID_NUM_32BITS 

◆ anonymous enum

anonymous enum
Enumerator
k_GUID_NUM_CHARS 

Constructor & Destructor Documentation

◆ Guid() [1/4]

bdlb::Guid::Guid ( )
inline

Construct a zero-initialized guid object. Note that a zero- initialized guid object is not a GUID according to RFC 4122.

◆ ~Guid()

bdlb::Guid::~Guid ( )
default

◆ Guid() [2/4]

bdlb::Guid::Guid ( const unsigned char(&)  buffer[k_GUID_NUM_BYTES])
inlineexplicit

Construct a guid object with the internal buffer set equal to the specified buffer with the first byte representing the most significant byte. Note that this method does guarantee that the created guid object is a GUID.

◆ Guid() [3/4]

bdlb::Guid::Guid ( unsigned long  timeLow,
unsigned short  timeMid,
unsigned short  timeHiAndVersion,
unsigned char  clockSeqHiRes,
unsigned char  clockSeqLow,
bsls::Types::Uint64  node 
)
inline

Construct a guid object with an internal buffer composed from the specified timeLow, timeMid, timeHiAndVersion, clockSeqHiRes, clockSeqLow, and node as specified by RFC 4122. Note that only the least significant 48 bits of node are used in constructing the guid.

◆ Guid() [4/4]

bdlb::Guid::Guid ( const Guid original)
default

Construct a guid object having the same value as the specified 'original' object.

Member Function Documentation

◆ begin()

const unsigned char * bdlb::Guid::begin ( ) const
inline

◆ clockSeqHi()

unsigned char bdlb::Guid::clockSeqHi ( ) const
inline

Return the 5-bit value of the clk_seq_hi_res field of this guid as specified in RFC 4122, excluding the variant bits.

◆ clockSeqHiRes()

unsigned char bdlb::Guid::clockSeqHiRes ( ) const
inline

Return the 8-bit clk_seq_hi_res field of this guid as specified in RFC 4122.

◆ clockSeqLow()

unsigned char bdlb::Guid::clockSeqLow ( ) const
inline

Return the 8-bit clk_seq_low field of this guid as specified in RFC 4122.

◆ data()

const unsigned char * bdlb::Guid::data ( ) const
inline

Return a pointer offering unmodifiable access to the most significant byte of this guid object.

◆ end()

const unsigned char * bdlb::Guid::end ( ) const
inline

Return a pointer one past the end of the least significant byte of this guid object.

◆ format()

void bdlb::Guid::format ( bsl::span< char, k_GUID_NUM_CHARS buffer) const

Write the value of this object to the specified output buffer in a human-readable format. Note that this human-readable format is not fully specified, and can change without notice (as can k_GUID_NUM_CHARS). No trailing null terminator is written.

◆ node()

bsls::Types::Uint64 bdlb::Guid::node ( ) const
inline

Return the 48-bit node field of this guid as specified in RFC

◆ operator=() [1/3]

Guid & bdlb::Guid::operator= ( const bsl::uint32_t(&)  buffer[k_GUID_NUM_32BITS])
inline

Assign to the buffer of this guid the byte sequence in the specified buffer. Note that buffer is treated as purely a sequence of bytes, and no account is taken of endianness.

◆ operator=() [2/3]

Guid & bdlb::Guid::operator= ( const Guid rhs)
default

Assign to this guid object the value of the specified 'rhs' and return a reference to this modifiable object.

◆ operator=() [3/3]

Guid & bdlb::Guid::operator= ( const unsigned char(&)  buffer[k_GUID_NUM_BYTES])
inline

Assign to the buffer of this guid the byte sequence in the specified buffer.

◆ operator[]()

const unsigned char & bdlb::Guid::operator[] ( bsl::size_t  offset) const
inline

Return a reference offering unmodifiable access to the byte at the specified offset from the most significant byte of this guid object. The behavior is undefined unless 0 <= offset < k_GUID_NUM_BYTES.

◆ print()

bsl::ostream & bdlb::Guid::print ( bsl::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Write the value of this object to the specified output stream in a human-readable format, and return a reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). If stream is not valid on entry, this operation has no effect. Note that this human-readable format is not fully specified, and can change without notice.

◆ timeHi()

unsigned short bdlb::Guid::timeHi ( ) const
inline

Return the 12-bit value of the time_hi_and_version field of this guid as specified in RFC 4122, excluding the version bits.

◆ timeHiAndVersion()

unsigned short bdlb::Guid::timeHiAndVersion ( ) const
inline

Return the 16-bit time_hi_and_version field of this guid as specified in RFC 4122.

◆ timeLow()

unsigned long bdlb::Guid::timeLow ( ) const
inline

Return the 32-bit time_low field of this guid as specified in RFC

◆ timeMid()

unsigned short bdlb::Guid::timeMid ( ) const
inline

Return the 16-bit time_mid field of this guid as specified in RFC

◆ variant()

unsigned char bdlb::Guid::variant ( ) const
inline

Return the 3-bit variant portion of the clk_seq_hi_res field of this guid as specified in RFC 4122.

◆ version()

unsigned char bdlb::Guid::version ( ) const
inline

Return the four-bit version portion of the time_hi_and_version field of this guid as specified in RFC 4122.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const Guid lhs,
const Guid rhs 
)
friend

Return true if the specified lhs and specified rhs guid objects have different values, and false otherwise. Two guid objects have different value if any of corresponding byte in their internal buffers differ.

◆ operator==

bool operator== ( const Guid lhs,
const Guid rhs 
)
friend

Return true if the specified lhs and specified rhs guid objects have the same value, and false otherwise. Two guid objects have the same value if each corresponding byte in their internal buffers are equal.


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