feat(hash): add HASHKEY_CONSTSTR and HASHKEY_CONSTSTRI

This commit is contained in:
Adam Heinermann 2025-10-16 14:39:21 -07:00 committed by fallenoak
parent 5190c49019
commit 8c2439277c
4 changed files with 234 additions and 20 deletions

View file

@ -90,3 +90,54 @@ bool HASHKEY_STRI::operator==(const char* str) const {
bool HASHKEY_STRI::operator==(const HASHKEY_STRI& key) const {
return this->operator==(key.m_str);
}
HASHKEY_CONSTSTR::HASHKEY_CONSTSTR() {
this->m_str = nullptr;
}
HASHKEY_CONSTSTR::HASHKEY_CONSTSTR(const char* str) {
this->m_str = str;
}
HASHKEY_CONSTSTR::~HASHKEY_CONSTSTR() {
}
HASHKEY_CONSTSTR& HASHKEY_CONSTSTR::operator=(const char* str) {
this->m_str = str;
return *this;
}
HASHKEY_CONSTSTR& HASHKEY_CONSTSTR::operator=(const HASHKEY_CONSTSTR& key) {
this->operator=(key.m_str);
return *this;
}
bool HASHKEY_CONSTSTR::operator==(const char* str) const {
return this->m_str == str || SStrCmp(this->m_str, str) == 0;
}
bool HASHKEY_CONSTSTR::operator==(const HASHKEY_CONSTSTR& key) const {
return this->operator==(key.m_str);
}
const char* HASHKEY_CONSTSTR::GetString() const {
return this->m_str;
}
HASHKEY_CONSTSTRI& HASHKEY_CONSTSTRI::operator=(const char* str) {
static_cast<HASHKEY_CONSTSTR&>(*this) = str;
return *this;
}
HASHKEY_CONSTSTRI& HASHKEY_CONSTSTRI::operator=(const HASHKEY_CONSTSTRI& key) {
static_cast<HASHKEY_CONSTSTR&>(*this) = key.m_str;
return *this;
}
bool HASHKEY_CONSTSTRI::operator==(const char* str) const {
return this->m_str == str || SStrCmpI(this->m_str, str) == 0;
}
bool HASHKEY_CONSTSTRI::operator==(const HASHKEY_CONSTSTRI& key) const {
return this->operator==(key.m_str);
}

View file

@ -49,4 +49,32 @@ class HASHKEY_STRI : public HASHKEY_STR {
bool operator==(const HASHKEY_STRI& key) const;
};
class HASHKEY_CONSTSTR {
public:
// Member functions
HASHKEY_CONSTSTR();
HASHKEY_CONSTSTR(const char* str);
~HASHKEY_CONSTSTR();
HASHKEY_CONSTSTR& operator=(const char* str);
HASHKEY_CONSTSTR& operator=(const HASHKEY_CONSTSTR& key);
bool operator==(const char* str) const;
bool operator==(const HASHKEY_CONSTSTR& key) const;
const char* GetString() const;
protected:
// Member variables
const char* m_str;
};
class HASHKEY_CONSTSTRI : public HASHKEY_CONSTSTR {
public:
// Member functions
HASHKEY_CONSTSTRI() : HASHKEY_CONSTSTR() {};
HASHKEY_CONSTSTRI(const char* str) : HASHKEY_CONSTSTR(str) {};
HASHKEY_CONSTSTRI& operator=(const char* str);
HASHKEY_CONSTSTRI& operator=(const HASHKEY_CONSTSTRI& key);
bool operator==(const char* str) const;
bool operator==(const HASHKEY_CONSTSTRI& key) const;
};
#endif