pstore2
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
pstore::uuid Class Reference

The uuid class is used to represent Universally Unique Identifiers (UUID) as defined by RFC 4122. More...

#include <uuid.hpp>

Public Types

enum  variant_type { ncs, rfc_4122, microsoft, future }
 
enum  version_type {
  time_based = 1, dce_security = 2, name_based_md5 = 3, random_number_based = 4,
  name_based_sha1 = 5, unknown
}
 
using container_type = std::array< std::uint8_t, elements >
 
using value_type = container_type::value_type
 
using size_type = container_type::size_type
 
using difference_type = container_type::difference_type
 
using reference = container_type::reference
 
using const_reference = container_type::const_reference
 
using iterator = container_type::iterator
 
using const_iterator = container_type::const_iterator
 

Public Member Functions

 uuid (std::string const &s)
 Converts a string following the convention defined by RFC4122 to a UUID. More...
 
constexpr uuid (container_type const &c)
 A constructor used to construct a specific UUID from its binary value.
 
iterator begin () noexcept
 
const_iterator begin () const noexcept
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
container_type const & array () const noexcept
 
auto variant () const noexcept -> variant_type
 
auto version () const noexcept -> version_type
 
bool is_null () const noexcept
 
std::string str () const
 Yields a string representation of the UUID following the convention defined by RFC4122.
 

Static Public Member Functions

static maybe< uuidfrom_string (std::string const &s)
 Converts a string to a UUID following the convention defined by RFC4122. More...
 

Static Public Attributes

static constexpr auto elements = std::size_t{16}
 
static constexpr auto string_length = elements * 2 + 4
 RFC4122 defines the UUID string representation which includes 16 two-digit hex numbers and 4 hyphens. More...
 

Friends

bool operator== (uuid const &lhs, uuid const &rhs) noexcept
 
bool operator!= (uuid const &lhs, uuid const &rhs) noexcept
 
bool operator< (uuid const &lhs, uuid const &rhs) noexcept
 
bool operator<= (uuid const &lhs, uuid const &rhs) noexcept
 
bool operator> (uuid const &lhs, uuid const &rhs) noexcept
 
bool operator>= (uuid const &lhs, uuid const &rhs) noexcept
 

Detailed Description

The uuid class is used to represent Universally Unique Identifiers (UUID) as defined by RFC 4122.

Specifically, it will generate version 4 (random) UUIDs but can be used to record all versions and variants.

Constructor & Destructor Documentation

◆ uuid()

pstore::uuid::uuid ( std::string const &  s)
explicit

Converts a string following the convention defined by RFC4122 to a UUID.

If the string is not valid an error is raised.

Member Function Documentation

◆ from_string()

maybe< uuid > pstore::uuid::from_string ( std::string const &  s)
static

Converts a string to a UUID following the convention defined by RFC4122.

If the string is not valid, returns nothing<uuid>.

Parameters
sA string to be converted to a UUID.
Returns
just<uuid>() if the string s was valid according to the description in RFC4122. If the string was invalid, nothing<uuid>.

◆ variant()

auto pstore::uuid::variant ( ) const -> variant_type
noexcept

OCLINT (PH - bitwise operator is just fine)

OCLINT (PH - bitwise operator is just fine)

OCLINT (PH - bitwise operator is just fine)

OCLINT (PH - bitwise operator is just fine)

Member Data Documentation

◆ string_length

constexpr auto pstore::uuid::string_length = elements * 2 + 4
static

RFC4122 defines the UUID string representation which includes 16 two-digit hex numbers and 4 hyphens.


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