2#include "gaia/config/config.h"
6#include "gaia/core/hashing_policy.h"
7#include "gaia/core/utility.h"
13 template <u
int32_t MaxLen>
28 static uint32_t
len(
const char* pStr) {
33 GAIA_ASSERT2(
false,
"Only null-terminated strings up to MaxLen characters are supported");
38 return {
static_cast<uint32_t
>(core::calculate_hash64(pStr,
len))};
55 m_pStr(pStr), m_len(
len), m_owned(
owned), m_hash(calc(pStr,
len)) {}
63 m_pStr(pStr), m_len(
len), m_owned(
owned), m_hash(
hash) {}
67 const char*
str()
const {
73 uint32_t
len()
const {
95 if GAIA_LIKELY (m_hash != other.m_hash)
99 if (m_len != other.m_len)
103 const auto l = m_len;
104 GAIA_ASSUME(l < MaxLen);
106 if (m_pStr[i] != other.m_pStr[i])
Fixed-limit string lookup key carrying a precomputed 32-bit hash.
Definition hashing_string.h:14
bool operator==(const StringLookupKey &other) const
Compares keys by hash, length, and string contents.
Definition hashing_string.h:92
bool owned() const
Reports whether Gaia-ECS manages the string lifetime.
Definition hashing_string.h:79
bool operator!=(const StringLookupKey &other) const
Compares keys for inequality.
Definition hashing_string.h:116
uint32_t hash() const
Returns the precomputed string hash.
Definition hashing_string.h:85
static constexpr bool IsDirectHashKey
Marker indicating that this key provides its hash directly.
Definition hashing_string.h:43
StringLookupKey(const char *pStr, uint32_t len, uint32_t owned)
Constructor calculating hash from the provided string pStr and len.
Definition hashing_string.h:54
uint32_t len() const
Returns the string length.
Definition hashing_string.h:73
core::direct_hash_key< uint32_t > LookupHash
Direct hash wrapper used by lookup containers.
Definition hashing_string.h:16
const char * str() const
Returns the referenced string.
Definition hashing_string.h:67
StringLookupKey(const char *pStr, uint32_t len, uint32_t owned, LookupHash hash)
Constructor just for setting values.
Definition hashing_string.h:62
StringLookupKey()
Constructs an empty lookup key.
Definition hashing_string.h:46
T hash
Precomputed hash value.
Definition hashing_policy.h:51