Database implementation mostly complete.

This commit is contained in:
2024-04-09 01:44:15 -07:00
parent beba947c69
commit d13fe81ac5
20 changed files with 768 additions and 106 deletions

View File

@@ -4,33 +4,55 @@
#include "ehs/Array.h"
#include "DbVarTmpl.h"
#include "DbObject.h"
#include "ehs/Serializer.h"
namespace ehs
{
class DbTable
{
private:
friend class Database;
friend class DbVar;
UInt_64 hashId;
Str_8 id;
Version version;
Array<DbVarTmpl> varTmpls;
Array<DbObject> objects;
public:
DbTable();
DbTable();
DbTable(Str_8 id);
DbTable(DbTable&& table) noexcept;
DbTable(const DbTable& table);
DbTable& operator=(DbTable&& table) noexcept;
DbTable& operator=(const DbTable& table);
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
Version GetVersion() const;
bool HasVariable(UInt_64 hashId) const;
bool CreateVariable(Str_8 id, DbType type);
bool HasVariable(const Str_8& id) const;
bool CreateVariable(Str_8 id, DbType type, UInt_64 size);
bool CreateVariable(Str_8 id, DbType type, const Byte* defaultValue);
void Save();
bool CreateVariable(Str_8 id, DbType type, UInt_64 size, const Byte* defaultValue);
DbObject *CreateObject();
private:
DbVarTmpl* GetVariableTemplate(UInt_64 hashId) const;
void Serialize(Serializer<UInt_64>& data) const;
void Deserialize(Serializer<UInt_64>& data);
};
}