#pragma once #include "ehs/EHS.h" #include "ehs/Serializer.h" #include "ehs/Str.h" namespace ehs { class DbVar; class DbVarTmpl { private: friend class DbTable; UInt_64 hashId; Str_8 id; Byte* def; UInt_64 size; public: ~DbVarTmpl(); DbVarTmpl(); template DbVarTmpl(Str_8 id, const T* const def, UInt_64 size) : hashId(id.Hash_64()), id((Str_8&&)id), def(new Byte[sizeof(T) * size]), size(sizeof(T) * size) { Util::Copy(this->def, def, this->size); } template DbVarTmpl(Str_8 id, const T* const def) : hashId(id.Hash_64()), id((Str_8&&)id), def(new Byte[sizeof(T)]), size(sizeof(T)) { Util::Copy(this->def, def, this->size); } DbVarTmpl(Str_8 id); DbVarTmpl(DbVarTmpl&& varTmpl) noexcept; DbVarTmpl(const DbVarTmpl& varTmpl); DbVarTmpl& operator=(DbVarTmpl&& varTmpl) noexcept; DbVarTmpl& operator=(const DbVarTmpl& varTmpl); operator Byte *() const; UInt_64 GetHashId() const; void SetId(Str_8 newId); Str_8 GetId() const; template T* GetDefaultArray() const { return (T*)def; } template T GetDefault() const { return *(T*)def; } UInt_64 GetSize() const; private: void Serialize(Serializer &data) const; void Deserialize(Serializer &data); }; }