feat(hash): add hash templates

This commit is contained in:
fallenoak 2020-11-15 13:20:10 -06:00
parent 399e3f02d6
commit ac1be572c4
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
7 changed files with 374 additions and 0 deletions

42
storm/hash/Hashkey.cpp Normal file
View file

@ -0,0 +1,42 @@
#include "storm/hash/Hashkey.hpp"
#include "storm/Memory.hpp"
#include "storm/String.hpp"
bool HASHKEY_NONE::operator==(const HASHKEY_NONE& key) {
return true;
}
bool HASHKEY_PTR::operator==(const HASHKEY_PTR& key) {
return this->m_key == key.m_key;
}
HASHKEY_STR::~HASHKEY_STR() {
if (this->m_str) {
SMemFree(this->m_str, __FILE__, __LINE__, 0x0);
}
}
HASHKEY_STR& HASHKEY_STR::operator=(const char* str) {
if (this->m_str != str) {
if (this->m_str) {
SMemFree(this->m_str, __FILE__, __LINE__, 0x0);
}
this->m_str = SStrDupA(str, __FILE__, __LINE__);
}
return *this;
}
bool HASHKEY_STR::operator==(const char* str) {
return SStrCmp(this->m_str, str, STORM_MAX_STR) == 0;
}
HASHKEY_STRI& HASHKEY_STRI::operator=(const char* str) {
static_cast<HASHKEY_STR&>(*this) = str;
return *this;
}
bool HASHKEY_STRI::operator==(const char* str) {
return SStrCmpI(this->m_str, str, STORM_MAX_STR) == 0;
}