Health-GPS  1.2.2.0
Global Health Policy Simulation model (Health-GPS)
hgps::core::Identifier Struct Referencefinal

Entity unique identifier data type. More...

#include <identifier.h>

Public Member Functions

constexpr Identifier ()=default
 Initialises a new instance of the hgps::core::Identifier class. More...
 
 Identifier (const char *const value)
 Initialises a new instance of the hgps::core::Identifier class. More...
 
 Identifier (std::string value)
 Initialises a new instance of the hgps::core::Identifier class. More...
 
bool is_empty () const noexcept
 Checks whether this is an empty identifier. More...
 
std::size_t size () const noexcept
 Gets the side of the identifier. More...
 
const std::string & to_string () const noexcept
 Convert the identifier to a string representation. More...
 
std::size_t hash () const noexcept
 Gets the identifier hash code value. More...
 
bool equal (const std::string &other) const noexcept
 Determines whether a string representation and this instance have same value. More...
 
bool equal (const Identifier &other) const noexcept
 Determines whether two identifiers have the same value. More...
 
bool operator== (const Identifier &rhs) const noexcept
 Determines whether two identifiers have the same value. More...
 
std::strong_ordering operator<=> (const Identifier &rhs) const noexcept=default
 Compare two identifier. More...
 

Static Public Member Functions

static Identifier empty ()
 Represents the empty Identifier, read-only. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const Identifier &identifier)
 Output streams operator for Identifier type. More...
 

Detailed Description

Entity unique identifier data type.

Wrappers a string identifier to provide consistent comparison operation using hash code instead of strings.

Note
Identifies must not start with a numeric value, and contain only characters: _, alpha: a-z and digits: 0-9.

Constructor & Destructor Documentation

◆ Identifier() [1/3]

constexpr hgps::core::Identifier::Identifier ( )
constexprdefault

Initialises a new instance of the hgps::core::Identifier class.

Here is the caller graph for this function:

◆ Identifier() [2/3]

hgps::core::Identifier::Identifier ( const char *const  value)

Initialises a new instance of the hgps::core::Identifier class.

Parameters
valueThe characters array identifier
Exceptions
std::invalid_argumentfor value starting with a number or containing invalid characters.

◆ Identifier() [3/3]

hgps::core::Identifier::Identifier ( std::string  value)

Initialises a new instance of the hgps::core::Identifier class.

Parameters
valueThe string identifier
Exceptions
std::invalid_argumentfor value starting with a number or containing invalid characters.

Member Function Documentation

◆ empty()

Identifier hgps::core::Identifier::empty ( )
static

Represents the empty Identifier, read-only.

Returns
The empty identifier
Here is the call graph for this function:

◆ equal() [1/2]

bool hgps::core::Identifier::equal ( const Identifier other) const
noexcept

Determines whether two identifiers have the same value.

Parameters
otherThe Identifier to compare to this instance.
Returns
true if the identifiers value are the same; otherwise, false.

◆ equal() [2/2]

bool hgps::core::Identifier::equal ( const std::string &  other) const
noexcept

Determines whether a string representation and this instance have same value.

Parameters
otherThe string representation to compare to this instance.
Returns
true if the values are the same; otherwise, false.
Here is the call graph for this function:

◆ hash()

std::size_t hgps::core::Identifier::hash ( ) const
noexcept

Gets the identifier hash code value.

Returns
The hash code value

◆ is_empty()

bool hgps::core::Identifier::is_empty ( ) const
noexcept

Checks whether this is an empty identifier.

Returns
true if the identifier is empty; otherwise, false.
Here is the caller graph for this function:

◆ operator<=>()

std::strong_ordering hgps::core::Identifier::operator<=> ( const Identifier rhs) const
defaultnoexcept

Compare two identifier.

Parameters
rhsThe Identifier to compare to this instance.
Returns
The comparison result

◆ operator==()

bool hgps::core::Identifier::operator== ( const Identifier rhs) const
noexcept

Determines whether two identifiers have the same value.

Parameters
rhsThe Identifier to compare to this instance.
Returns
true if the identifiers value are the same; otherwise, false.

◆ size()

std::size_t hgps::core::Identifier::size ( ) const
noexcept

Gets the side of the identifier.

Returns
The identifier size

◆ to_string()

const std::string & hgps::core::Identifier::to_string ( ) const
noexcept

Convert the identifier to a string representation.

Returns
The equivalent string representation
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const Identifier identifier 
)
friend

Output streams operator for Identifier type.

Parameters
streamThe stream to output
identifierThe Identifier instance
Returns
The output stream

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