Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Friends

bdlb::Guid Class Reference

#include <bdlb_guid.h>

List of all members.

Public Types

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

Public Member Functions

 Guid ()
 ~Guid ()
 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)
Guidoperator= (const Guid &rhs)
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
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 Component bdlb_guid


Member Enumeration Documentation

anonymous enum

number of bytes in a guid

Enumerator:
k_GUID_NUM_BYTES 
anonymous enum

number of 32-bits in a guid

Enumerator:
k_GUID_NUM_32BITS 

Constructor & Destructor Documentation

bdlb::Guid::Guid (  ) 

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

bdlb::Guid::~Guid (  ) 

Destroy this object

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

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.

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

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.

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

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


Member Function Documentation

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

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

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

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

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

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.

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.


Friends And Related Function Documentation

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.

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.


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