Added filter function.

This commit is contained in:
Arron David Nelson 2024-04-10 22:28:45 -07:00
parent 3196c5021e
commit 2734cc00fb
2 changed files with 25 additions and 0 deletions

View File

@ -46,6 +46,10 @@ namespace ehs
DbObject *CreateObject();
DbObject *GetObject(UInt_64 variableHashId, const Str_8 &value) const;
DbObject *GetObject(const Str_8 &variable, const Str_8 &value) const;
DbObject *GetObject(UInt_64 id) const;
private:

View File

@ -119,6 +119,27 @@ namespace ehs
return obj;
}
DbObject* DbTable::GetObject(UInt_64 variableHashId, const Str_8& value) const
{
for (UInt_64 i = 0; i < objects.Size(); ++i)
{
objects[i].Load();
const DbVar * const var = objects[i].GetVariable(variableHashId);
if (var->GetValueStr() == value)
return &objects[i];
objects[i].Free();
}
return nullptr;
}
DbObject* DbTable::GetObject(const Str_8& variable, const Str_8& value) const
{
return GetObject(variable.Hash_64(), value);
}
DbObject* DbTable::GetObject(const UInt_64 id) const
{
for (UInt_64 i = 0; i < objects.Size(); ++i)