Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::core::StringLookupKey< MaxLen > Struct Template Reference

Fixed-limit string lookup key carrying a precomputed 32-bit hash. More...

#include <hashing_string.h>

Public Types

using LookupHash = core::direct_hash_key< uint32_t >
 Direct hash wrapper used by lookup containers.
 

Public Member Functions

 StringLookupKey ()
 Constructs an empty lookup key.
 
 StringLookupKey (const char *pStr, uint32_t len, uint32_t owned)
 Constructor calculating hash from the provided string pStr and len.
 
 StringLookupKey (const char *pStr, uint32_t len, uint32_t owned, LookupHash hash)
 Constructor just for setting values.
 
const char * str () const
 Returns the referenced string.
 
uint32_t len () const
 Returns the string length.
 
bool owned () const
 Reports whether Gaia-ECS manages the string lifetime.
 
uint32_t hash () const
 Returns the precomputed string hash.
 
bool operator== (const StringLookupKey &other) const
 Compares keys by hash, length, and string contents.
 
bool operator!= (const StringLookupKey &other) const
 Compares keys for inequality.
 

Static Public Attributes

static constexpr bool IsDirectHashKey = true
 Marker indicating that this key provides its hash directly.
 

Detailed Description

template<uint32_t MaxLen>
struct gaia::core::StringLookupKey< MaxLen >

Fixed-limit string lookup key carrying a precomputed 32-bit hash.

Template Parameters
MaxLenMaximum supported string length used by bounded comparisons.

Constructor & Destructor Documentation

◆ StringLookupKey() [1/2]

template<uint32_t MaxLen>
gaia::core::StringLookupKey< MaxLen >::StringLookupKey ( const char *  pStr,
uint32_t  len,
uint32_t  owned 
)
inlineexplicit

Constructor calculating hash from the provided string pStr and len.

Parameters
pStrPointer to the string
lenNumber of characters
ownedTrue if the string is owned
Warning
String has to be null-terminated and up to MaxLen characters long. Undefined behavior otherwise.

◆ StringLookupKey() [2/2]

template<uint32_t MaxLen>
gaia::core::StringLookupKey< MaxLen >::StringLookupKey ( const char *  pStr,
uint32_t  len,
uint32_t  owned,
LookupHash  hash 
)
inlineexplicit

Constructor just for setting values.

Parameters
pStrPointer to the string
lenNumber of characters
ownedTrue if the string is owned
hashString hash

Member Function Documentation

◆ hash()

template<uint32_t MaxLen>
uint32_t gaia::core::StringLookupKey< MaxLen >::hash ( ) const
inline

Returns the precomputed string hash.

Returns
The 32-bit hash value.

◆ len()

template<uint32_t MaxLen>
uint32_t gaia::core::StringLookupKey< MaxLen >::len ( ) const
inline

Returns the string length.

Returns
Number of characters in the string.

◆ operator!=()

template<uint32_t MaxLen>
bool gaia::core::StringLookupKey< MaxLen >::operator!= ( const StringLookupKey< MaxLen > &  other) const
inline

Compares keys for inequality.

Parameters
otherKey to compare with.
Returns
True when the keys identify different strings.

◆ operator==()

template<uint32_t MaxLen>
bool gaia::core::StringLookupKey< MaxLen >::operator== ( const StringLookupKey< MaxLen > &  other) const
inline

Compares keys by hash, length, and string contents.

Parameters
otherKey to compare with.
Returns
True when both keys identify equal strings.

◆ owned()

template<uint32_t MaxLen>
bool gaia::core::StringLookupKey< MaxLen >::owned ( ) const
inline

Reports whether Gaia-ECS manages the string lifetime.

Returns
True when the referenced string is owned by the framework.

◆ str()

template<uint32_t MaxLen>
const char * gaia::core::StringLookupKey< MaxLen >::str ( ) const
inline

Returns the referenced string.

Returns
Pointer to the string, or nullptr for an empty key.

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