Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Lightweight::SqlGuid Struct Reference

#include <SqlGuid.hpp>

Public Member Functions

constexpr std::weak_ordering operator<=> (SqlGuid const &other) const noexcept=default
 Three-way comparison operator.
 
constexpr bool operator== (SqlGuid const &other) const noexcept
 Equality comparison operator.
 
constexpr bool operator!= (SqlGuid const &other) const noexcept
 Inequality comparison operator.
 
constexpr operator bool () const noexcept
 Tests if the GUID is non-empty.
 
constexpr bool operator! () const noexcept
 Tests if the GUID is empty.
 

Static Public Member Functions

static SqlGuid Create () noexcept
 Creates a new non-empty GUID.
 
static std::optional< SqlGuid > TryParse (std::string_view const &text) noexcept
 
static SqlGuid constexpr UnsafeParse (std::string_view const &text) noexcept
 

Public Attributes

uint8_t data [16] {}
 The raw GUID data bytes.
 

Detailed Description

Represents a GUID (Globally Unique Identifier).

Definition at line 24 of file SqlGuid.hpp.

Member Function Documentation

◆ TryParse()

static std::optional< SqlGuid > Lightweight::SqlGuid::TryParse ( std::string_view const &  text)
staticnoexcept

Parses a GUID from its 36-character xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx text form.

Any hex value is accepted, whatever its version and variant nibbles, as SQL Server's uniqueidentifier does. data[i] receives the i-th hex pair of the text, left to right.

Parameters
textThe GUID text, upper or lower case.
Returns
The parsed GUID, or std::nullopt if text is not a well-formed GUID.

◆ UnsafeParse()

constexpr SqlGuid Lightweight::SqlGuid::UnsafeParse ( std::string_view const &  text)
staticconstexprnoexcept

Parses a GUID from a string. Use with caution and always prefer TryParse at all cost.

Accepts the same texts as TryParse(); for any other text it returns an unspecified sentinel.

Parameters
textThe GUID text.
Returns
The parsed GUID.

Definition at line 115 of file SqlGuid.hpp.

References data.

◆ operator==()

constexpr bool Lightweight::SqlGuid::operator== ( SqlGuid const &  other) const
inlineconstexprnoexcept

Equality comparison operator.

Definition at line 52 of file SqlGuid.hpp.

◆ operator!=()

constexpr bool Lightweight::SqlGuid::operator!= ( SqlGuid const &  other) const
inlineconstexprnoexcept

Inequality comparison operator.

Definition at line 58 of file SqlGuid.hpp.

◆ operator bool()

constexpr Lightweight::SqlGuid::operator bool ( ) const
inlineexplicitconstexprnoexcept

Tests if the GUID is non-empty.

Definition at line 64 of file SqlGuid.hpp.

◆ operator!()

constexpr bool Lightweight::SqlGuid::operator! ( ) const
inlineconstexprnoexcept

Tests if the GUID is empty.

Definition at line 70 of file SqlGuid.hpp.

Member Data Documentation

◆ data

uint8_t Lightweight::SqlGuid::data[16] {}

The raw GUID data bytes.

Definition at line 27 of file SqlGuid.hpp.

Referenced by UnsafeParse().


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