LibrePCB Developers Documentation
Uuid Class Referencefinal

The Uuid class is a replacement for QUuid to get UUID strings without {} braces. More...

#include <uuid.h>

+ Collaboration diagram for Uuid:

Public Member Functions

 Uuid ()=delete
 Default constructor (disabled to avoid creating invalid UUIDs) More...
 
 Uuid (const Uuid &other) noexcept
 Copy constructor. More...
 
 ~Uuid () noexcept=default
 Destructor. More...
 
QString toStr () const noexcept
 Get the UUID as a string (without braces) More...
 
Uuidoperator= (const Uuid &rhs) noexcept
 Operator overloadings. More...
 
bool operator== (const Uuid &rhs) const noexcept
 
bool operator!= (const Uuid &rhs) const noexcept
 
bool operator< (const Uuid &rhs) const noexcept
 
bool operator> (const Uuid &rhs) const noexcept
 
bool operator<= (const Uuid &rhs) const noexcept
 
bool operator>= (const Uuid &rhs) const noexcept
 

Static Public Member Functions

static bool isValid (const QString &str) noexcept
 Check if a string is a valid UUID. More...
 
static Uuid createRandom () noexcept
 Create a new random UUID. More...
 
static Uuid fromString (const QString &str)
 Create Uuid from a string. More...
 
static tl::optional< UuidtryFromString (const QString &str) noexcept
 Try creating a Uuid from a string, returning empty optional if invalid. More...
 

Private Member Functions

 Uuid (const QString &str) noexcept
 Constructor which creates a Uuid object from a string. More...
 

Private Attributes

QString mUuid
 Guaranteed to always contain a valid UUID. More...
 

Detailed Description

The Uuid class is a replacement for QUuid to get UUID strings without {} braces.

This class implements an RFC4122 compliant UUID of type "DCE" in Version 4 (random UUID). Other types and/or versions of UUIDs are considered as invalid. The characters in a UUID are always lowercase.

A valid UUID looks like this: "d79d354b-62bd-4866-996a-78941c575e78"

Note
This class guarantees that only Uuid objects representing a valid UUID can be created (in opposite to QUuid which allows "Null UUIDs")! If you need a nullable UUID, use tl::optional<librepcb::Uuid> instead.
See also
https://de.wikipedia.org/wiki/Universally_Unique_Identifier
https://tools.ietf.org/html/rfc4122

Constructor & Destructor Documentation

◆ Uuid() [1/3]

Uuid ( )
delete

Default constructor (disabled to avoid creating invalid UUIDs)

+ Here is the caller graph for this function:

◆ Uuid() [2/3]

Uuid ( const Uuid other)
inlinenoexcept

Copy constructor.

Parameters
otherAnother librepcb::Uuid object

◆ ~Uuid()

~Uuid ( )
defaultnoexcept

Destructor.

◆ Uuid() [3/3]

Uuid ( const QString &  str)
inlineexplicitprivatenoexcept

Constructor which creates a Uuid object from a string.

Parameters
strThe uuid as a string (lowercase and without braces)

Member Function Documentation

◆ toStr()

QString toStr ( ) const
inlinenoexcept

Get the UUID as a string (without braces)

Returns
The UUID as a string
+ Here is the caller graph for this function:

◆ operator=()

Uuid & operator= ( const Uuid rhs)
inlinenoexcept

Operator overloadings.

Parameters
rhsThe other object to compare
Returns
Result of comparing the UUIDs as strings

◆ operator==()

bool operator== ( const Uuid rhs) const
inlinenoexcept

◆ operator!=()

bool operator!= ( const Uuid rhs) const
inlinenoexcept

◆ operator<()

bool operator< ( const Uuid rhs) const
inlinenoexcept

◆ operator>()

bool operator> ( const Uuid rhs) const
inlinenoexcept

◆ operator<=()

bool operator<= ( const Uuid rhs) const
inlinenoexcept

◆ operator>=()

bool operator>= ( const Uuid rhs) const
inlinenoexcept

◆ isValid()

bool isValid ( const QString &  str)
staticnoexcept

Check if a string is a valid UUID.

Parameters
strThe string to check
Return values
trueIf str is a valid UUID
falseIf str is not a valid UUID
+ Here is the caller graph for this function:

◆ createRandom()

Uuid createRandom ( )
staticnoexcept

Create a new random UUID.

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

◆ fromString()

Uuid fromString ( const QString &  str)
static

Create Uuid from a string.

Parameters
strInput string
Returns
The created Uuid object
Exceptions
Exceptionif the string does not contain a valid UUID
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tryFromString()

tl::optional< Uuid > tryFromString ( const QString &  str)
staticnoexcept

Try creating a Uuid from a string, returning empty optional if invalid.

Parameters
strInput string
Return values
UuidThe created Uuid object if str was valid
tl::nulloptIf str was not a valid UUID
+ Here is the caller graph for this function:

Member Data Documentation

◆ mUuid

QString mUuid
private

Guaranteed to always contain a valid UUID.


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