AnCH Framework 0.1
Another C++ Hack Framework
 
Loading...
Searching...
No Matches
anch::UUID Class Reference

UUID generator and parser. More...

#include <uuid.hpp>

+ Collaboration diagram for anch::UUID:

Public Types

enum class  Version {
  MAC_ADDRESS = 1 , DCE_SECURITY , MD5_HASH , RANDOM ,
  SHA1_HASH
}
 

Public Member Functions

 UUID ()
 
 UUID (const UUID &uuid)
 
 UUID (const std::string &uuid)
 
 UUID (uint32_t lowTime, uint16_t midTime, uint16_t highTime, uint16_t clockSeqLow, uint16_t clockSeqHighRes, uint64_t node, UUID::Version version)
 
virtual ~UUID ()
 
std::string toString () const
 
 operator std::string () const
 
uint32_t getLowTime () const
 
uint16_t getMidTime () const
 
uint16_t getHighTime () const
 
uint16_t getClockSeqLow () const
 
uint16_t getClockSeqHighRes () const
 
uint64_t getNode () const
 
anch::UUID::Version getVersion () const
 

Static Public Member Functions

static void registerProvider (UUID::Version version, std::function< UUID(const std::string &)> provider)
 
static UUID generateUUID (anch::UUID::Version version, const std::string &data="")
 
static UUID random ()
 
static uint64_t getUtcTimestamp ()
 
static std::random_device & getRandomEngine ()
 
static std::uniform_int_distribution< uint16_t > & getDistSeq ()
 

Static Public Attributes

static const uint64_t TIME_LOW_MASK = 0x00000000FFFFFFFF
 
static const uint64_t TIME_MID_MASK = 0x000000000000FFFF
 
static const uint64_t TIME_HIGH_MASK = 0x0000000000000FFF
 
static const uint64_t VERSION_MASK = 0x000000000000F000
 
static const uint32_t SEQ_LOW_MASK = 0x00FF
 
static const uint32_t SEQ_HIGH_MASK = 0x3F00
 

Detailed Description

UUID generator and parser.

See RFC 4122 for more details (http://www.ietf.org/rfc/rfc4122.txt)

This class needs anch-crypto and anch-device libraries.

Since
0.1
Author
Vincent Lachenal

Member Enumeration Documentation

◆ Version

enum class anch::UUID::Version
strong

The UUID versions

Since
0.1
Author
Vincent Lachenal
Enumerator
MAC_ADDRESS 

MAC address based algorithm

DCE_SECURITY 

DCE security (Windows) base algorithm

MD5_HASH 

MD5 hash based algorithm

RANDOM 

Random based algorithm

SHA1_HASH 

SHA1 hash based algorithm

Constructor & Destructor Documentation

◆ UUID() [1/4]

anch::UUID::UUID ( )

UUID default constructor

◆ UUID() [2/4]

anch::UUID::UUID ( const UUID & uuid)

UUID copy constructor

Parameters
uuidThe UUID to copy
+ Here is the call graph for this function:

◆ UUID() [3/4]

anch::UUID::UUID ( const std::string & uuid)

UUID from std::string constructor

Parameters
uuidthe std::string to parse
Exceptions
std::out_of_rangeinvalid UUID length
std::invalid_argumentinvalid UUID subpart

◆ UUID() [4/4]

anch::UUID::UUID ( uint32_t lowTime,
uint16_t midTime,
uint16_t highTime,
uint16_t clockSeqLow,
uint16_t clockSeqHighRes,
uint64_t node,
UUID::Version version )

UUID constructor

Parameters
lowTimethe low time part
midTimethe mid time part
highTimethe high time part
clockSeqLowthe clock sequence low part
clockSeqHighResthe clock sequence high resolution part
nodethe node part
versionthe UUID version

◆ ~UUID()

virtual anch::UUID::~UUID ( )
virtual

UUID destructor

Member Function Documentation

◆ generateUUID()

static UUID anch::UUID::generateUUID ( anch::UUID::Version version,
const std::string & data = "" )
static

Generate a new UUID

Parameters
versionThe UUID algorithm version to use (default to MAC based algorithm)
dataThe data to process (used to SHA1 and MD5 algorithms)
Returns
the new UUID
Exceptions
std::runtime_errorno provider for specified UUID version
+ Here is the call graph for this function:

◆ getClockSeqHighRes()

uint16_t anch::UUID::getClockSeqHighRes ( ) const

The clock sequence high value and reserved value getter

Returns
The clock sequence high value and reserved value

◆ getClockSeqLow()

uint16_t anch::UUID::getClockSeqLow ( ) const

The clock sequence low value getter

Returns
The clock sequence low value

◆ getDistSeq()

static std::uniform_int_distribution< uint16_t > & anch::UUID::getDistSeq ( )
static

Distribution sequence getter

Returns
the distribution sequence

◆ getHighTime()

uint16_t anch::UUID::getHighTime ( ) const

The timestamp high value getter

Returns
The timestamp high value

◆ getLowTime()

uint32_t anch::UUID::getLowTime ( ) const

The timestamp low value getter

Returns
The timestamp low value

◆ getMidTime()

uint16_t anch::UUID::getMidTime ( ) const

The timestamp mid value getter

Returns
The timestamp mid value

◆ getNode()

uint64_t anch::UUID::getNode ( ) const

The node getter

Returns
The node

◆ getRandomEngine()

static std::random_device & anch::UUID::getRandomEngine ( )
static

Random engine getter

Returns
the random engine

◆ getUtcTimestamp()

static uint64_t anch::UUID::getUtcTimestamp ( )
static

Get UTC timestamp

Returns
The UTC timestamp

◆ getVersion()

anch::UUID::Version anch::UUID::getVersion ( ) const

Version getter

Returns
The version

◆ operator std::string()

anch::UUID::operator std::string ( ) const
explicit

Cast UUID to std::string

◆ random()

static UUID anch::UUID::random ( )
static

Generate a new UUID with version 4 (random) algorithm

Returns
the new UUID
+ Here is the call graph for this function:

◆ registerProvider()

static void anch::UUID::registerProvider ( UUID::Version version,
std::function< UUID(const std::string &)> provider )
static

Register UUID provider

Parameters
versionthe UUID version which can be handled by provider
providerthe provider

◆ toString()

std::string anch::UUID::toString ( ) const

Convert UUID to std::string

Returns
The string representation of UUID

Member Data Documentation

◆ SEQ_HIGH_MASK

const uint32_t anch::UUID::SEQ_HIGH_MASK = 0x3F00
static

Sequence high part time mask

◆ SEQ_LOW_MASK

const uint32_t anch::UUID::SEQ_LOW_MASK = 0x00FF
static

Sequence low part time mask

◆ TIME_HIGH_MASK

const uint64_t anch::UUID::TIME_HIGH_MASK = 0x0000000000000FFF
static

Time high part time mask

◆ TIME_LOW_MASK

const uint64_t anch::UUID::TIME_LOW_MASK = 0x00000000FFFFFFFF
static

Time low part time mask

◆ TIME_MID_MASK

const uint64_t anch::UUID::TIME_MID_MASK = 0x000000000000FFFF
static

Time middle part time mask

◆ VERSION_MASK

const uint64_t anch::UUID::VERSION_MASK = 0x000000000000F000
static

Time high part time mask


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