1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2026-07-02 14:47:11 +02:00

Add iteration.

This commit is contained in:
Sandu Liviu Catalin
2021-02-05 15:42:27 +02:00
parent bd1504bd24
commit 479272d59f
6 changed files with 125 additions and 0 deletions
+13
View File
@@ -342,6 +342,18 @@ bool PvUnit::Can(SQInteger id) const
return false;
}
// ------------------------------------------------------------------------------------------------
void PvUnit::EachEntryID(Object & ctx, Function & func)
{
// In order to be safe from modifications while iterating, create a copy
PvStatusList list(mPrivileges);
// Iterate entries and forward the ID to the callback
for (const auto & e : list)
{
func(ctx, e.first);
}
}
// ================================================================================================
LightObj SqPvUnit::GetClass() const
{
@@ -429,6 +441,7 @@ void Register_Privilege_Unit(HSQUIRRELVM vm, Table & ns)
.Func(_SC("Modify"), &SqPvUnit::ModifyPrivilegeWithID)
.FmtFunc(_SC("ModifyWithTag"), &SqPvUnit::ModifyPrivilegeWithTag)
.Func(_SC("RemoveAll"), &SqPvUnit::RemoveAllPrivileges)
.Func(_SC("EachEntryID"), &SqPvUnit::EachEntryID)
);
}