Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
AeonGames::StringId Class Reference

CRC-based compile-time string identifier. More...

#include <aeongames/StringId.hpp>

Collaboration diagram for AeonGames::StringId:
Collaboration graph

Public Member Functions

template<uint32_t aStringSize>
constexpr StringId (const char(&aString)[aStringSize])
 Construct a StringId from a string literal.
constexpr StringId (const StringId &) noexcept=default
 Copy constructor.
constexpr StringId (StringId &&aString) noexcept=default
 Move constructor.
constexpr StringIdoperator= (const StringId &) noexcept=default
 Copy assignment operator.
constexpr StringIdoperator= (StringId &&) noexcept=default
 Move assignment operator.
constexpr uint32_t GetId () const
 Get the CRC32 identifier.
constexpr const char * GetString () const
 Get the underlying string pointer.
constexpr uint32_t GetStringSize () const
 Get the size of the string including null terminator.
constexpr bool operator== (const StringId &b) const
 Compare two StringId objects for equality.
constexpr bool operator== (uint32_t b) const
 Compare StringId with a raw uint32_t hash.
constexpr operator uint32_t () const
 Convert to uint32_t.
 operator std::string () const
 Convert to std::string.

Detailed Description

CRC-based compile-time string identifier.

Wraps a string literal and its CRC32 hash, enabling efficient compile-time string comparisons and hashing.

Definition at line 30 of file StringId.hpp.

Constructor & Destructor Documentation

◆ StringId()

template<uint32_t aStringSize>
AeonGames::StringId::StringId ( const char(&) aString[aStringSize])
inlineconstexpr

Construct a StringId from a string literal.

Template Parameters
aStringSizeSize of the string literal including null terminator.
Parameters
aStringThe string literal to wrap.

Definition at line 38 of file StringId.hpp.

Member Function Documentation

◆ GetId()

uint32_t AeonGames::StringId::GetId ( ) const
inlineconstexpr

Get the CRC32 identifier.

Returns
The CRC32 hash of the string.

Definition at line 52 of file StringId.hpp.

◆ GetString()

const char * AeonGames::StringId::GetString ( ) const
inlineconstexpr

Get the underlying string pointer.

Returns
Pointer to the string literal.

Definition at line 57 of file StringId.hpp.

◆ GetStringSize()

uint32_t AeonGames::StringId::GetStringSize ( ) const
inlineconstexpr

Get the size of the string including null terminator.

Returns
String size.

Definition at line 62 of file StringId.hpp.

◆ operator std::string()

AeonGames::StringId::operator std::string ( ) const
inline

Convert to std::string.

Returns
A string copy of the wrapped literal.

Definition at line 82 of file StringId.hpp.

◆ operator uint32_t()

AeonGames::StringId::operator uint32_t ( ) const
inlineconstexpr

Convert to uint32_t.

Returns
The CRC32 hash value.

Definition at line 77 of file StringId.hpp.

◆ operator==() [1/2]

bool AeonGames::StringId::operator== ( const StringId & b) const
inlineconstexpr

Compare two StringId objects for equality.

Parameters
bThe other StringId.
Returns
True if IDs match.

Definition at line 67 of file StringId.hpp.

◆ operator==() [2/2]

bool AeonGames::StringId::operator== ( uint32_t b) const
inlineconstexpr

Compare StringId with a raw uint32_t hash.

Parameters
bThe hash value to compare.
Returns
True if IDs match.

Definition at line 72 of file StringId.hpp.


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