AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
AeonGUI::StringLiteral Class Reference

Compile-time string literal wrapper. More...

#include <aeongui/StringLiteral.hpp>

Public Member Functions

template<size_t aStringSize>
constexpr StringLiteral (const char(&aString)[aStringSize])
 Construct from a string literal.
constexpr StringLiteral () noexcept=default
 Default constructor.
constexpr StringLiteral (const StringLiteral &) noexcept=default
 Copy constructor.
constexpr StringLiteral (StringLiteral &&aString) noexcept=default
 Move constructor.
constexpr StringLiteraloperator= (const StringLiteral &) noexcept=default
 Copy assignment operator.
constexpr StringLiteraloperator= (StringLiteral &&) noexcept=default
 Move assignment operator.
constexpr const char * GetString () const
 Get the underlying C string.
constexpr size_t GetStringSize () const
 Get the string size including the null terminator.
constexpr bool operator== (const StringLiteral &b) const
 Compare with another StringLiteral for equality.
bool operator== (const char *b) const
 Compare with a C string for equality.
bool operator== (const std::string &b) const
 Compare with a std::string for equality.
 operator std::string () const
 Implicit conversion to std::string.

Detailed Description

Compile-time string literal wrapper.

Stores a pointer to a string literal and its size, enabling constexpr comparisons and use as hash-map keys without allocations.

Constructor & Destructor Documentation

◆ StringLiteral() [1/2]

template<size_t aStringSize>
AeonGUI::StringLiteral::StringLiteral ( const char(&) aString[aStringSize])
inlineconstexpr

Construct from a string literal.

Template Parameters
aStringSizeSize of the character array including null terminator.
Parameters
aStringThe string literal.

◆ StringLiteral() [2/2]

AeonGUI::StringLiteral::StringLiteral ( StringLiteral && aString)
constexprdefaultnoexcept

Move constructor.

Parameters
aStringThe string literal to move from.

Member Function Documentation

◆ GetString()

const char * AeonGUI::StringLiteral::GetString ( ) const
inlineconstexpr

Get the underlying C string.

Returns
Pointer to the null-terminated string.

◆ GetStringSize()

size_t AeonGUI::StringLiteral::GetStringSize ( ) const
inlineconstexpr

Get the string size including the null terminator.

Returns
Size in bytes.

◆ operator=() [1/2]

StringLiteral & AeonGUI::StringLiteral::operator= ( const StringLiteral & )
constexprdefaultnoexcept

Copy assignment operator.

Returns
Reference to this.

◆ operator=() [2/2]

StringLiteral & AeonGUI::StringLiteral::operator= ( StringLiteral && )
constexprdefaultnoexcept

Move assignment operator.

Returns
Reference to this.

◆ operator==() [1/3]

bool AeonGUI::StringLiteral::operator== ( const char * b) const
inline

Compare with a C string for equality.

Parameters
bNull-terminated C string.
Returns
true if equal.

◆ operator==() [2/3]

bool AeonGUI::StringLiteral::operator== ( const std::string & b) const
inline

Compare with a std::string for equality.

Parameters
bThe string to compare.
Returns
true if equal.

◆ operator==() [3/3]

bool AeonGUI::StringLiteral::operator== ( const StringLiteral & b) const
inlineconstexpr

Compare with another StringLiteral for equality.

Parameters
bThe other StringLiteral.
Returns
true if equal.

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