#include "Type.h" namespace ehs { Type::Type() : size(0), id(nullptr), hashId(0) { } Type::Type(const Char_8* const id) : size(CalcSize(id)), id(id), hashId(GenHash(id, size)) { } bool Type::operator==(const Type& type) const { return hashId == type.hashId; } bool Type::operator!=(const Type& type) const { return hashId != type.hashId; } bool Type::operator==(const UInt_64 inHashId) const { return hashId == inHashId; } bool Type::operator!=(const UInt_64 inHashId) const { return hashId != inHashId; } bool Type::operator==(const Char_8* const inStr) const { if (size != CalcSize(inStr)) return false; return Util::IsEqual(id, inStr, size); } bool Type::operator!=(const Char_8* const inStr) const { if (size != CalcSize(inStr)) return true; return !Util::IsEqual(id, inStr, size); } UInt_64 Type::GetSize() const { return size; } const Char_8* Type::GetId() const { return id; } UInt_64 Type::GetHashId() const { return hashId; } bool Type::IsValid() const { return size; } UInt_64 Type::CalcSize(const Char_8* const id) { UInt_64 result = 0; while (id[result]) result++; return result; } UInt_64 Type::GenHash(const Char_8* const id, const UInt_64 size) { if (!size) return 0; const Byte* const bytes = (Byte*)id; UInt_64 hash = 14695981039346656037ull; for (UInt_64 i = 0; i < size; ++i) hash = (hash ^ bytes[i]) * 1099511628211; return hash; } }