1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-21 20:27:13 +01:00

Improved the entity searching algorithms by removing duplicate code.

This commit is contained in:
Sandu Liviu Catalin 2016-06-21 16:04:21 +03:00
parent 29af51c518
commit 284e1be3f7
2 changed files with 195 additions and 655 deletions

View File

@ -21,86 +21,58 @@ void Register(HSQUIRRELVM vm)
fns.Bind(_SC("Blip"), Table(vm) fns.Bind(_SC("Blip"), Table(vm)
.Func(_SC("WithID"), &Entity< CBlip >::FindByID) .Func(_SC("WithID"), &Entity< CBlip >::FindByID)
.Func(_SC("IfTagEquals"), &Entity< CBlip >::FirstWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CBlip >::FirstWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CBlip >::FirstWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CBlip >::FirstWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CBlip >::FirstWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CBlip >::FirstWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CBlip >::FirstWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CBlip >::FirstWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CBlip >::FirstWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CBlip >::FirstWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CBlip >::FirstWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CBlip >::FirstWhereTagNotContains)
); );
fns.Bind(_SC("Checkpoint"), Table(vm) fns.Bind(_SC("Checkpoint"), Table(vm)
.Func(_SC("WithID"), &Entity< CCheckpoint >::FindByID) .Func(_SC("WithID"), &Entity< CCheckpoint >::FindByID)
.Func(_SC("IfTagEquals"), &Entity< CCheckpoint >::FirstWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CCheckpoint >::FirstWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CCheckpoint >::FirstWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CCheckpoint >::FirstWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CCheckpoint >::FirstWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CCheckpoint >::FirstWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CCheckpoint >::FirstWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CCheckpoint >::FirstWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CCheckpoint >::FirstWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CCheckpoint >::FirstWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CCheckpoint >::FirstWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CCheckpoint >::FirstWhereTagNotContains)
); );
fns.Bind(_SC("Keybind"), Table(vm) fns.Bind(_SC("Keybind"), Table(vm)
.Func(_SC("WithID"), &Entity< CKeybind >::FindByID) .Func(_SC("WithID"), &Entity< CKeybind >::FindByID)
.Func(_SC("IfTagEquals"), &Entity< CKeybind >::FirstWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CKeybind >::FirstWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CKeybind >::FirstWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CKeybind >::FirstWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CKeybind >::FirstWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CKeybind >::FirstWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CKeybind >::FirstWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CKeybind >::FirstWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CKeybind >::FirstWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CKeybind >::FirstWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CKeybind >::FirstWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CKeybind >::FirstWhereTagNotContains)
); );
fns.Bind(_SC("Object"), Table(vm) fns.Bind(_SC("Object"), Table(vm)
.Func(_SC("WithID"), &Entity< CObject >::FindByID) .Func(_SC("WithID"), &Entity< CObject >::FindByID)
.Func(_SC("IfTagEquals"), &Entity< CObject >::FirstWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CObject >::FirstWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CObject >::FirstWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CObject >::FirstWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CObject >::FirstWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CObject >::FirstWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CObject >::FirstWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CObject >::FirstWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CObject >::FirstWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CObject >::FirstWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CObject >::FirstWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CObject >::FirstWhereTagNotContains)
); );
fns.Bind(_SC("Pickup"), Table(vm) fns.Bind(_SC("Pickup"), Table(vm)
.Func(_SC("WithID"), &Entity< CPickup >::FindByID) .Func(_SC("WithID"), &Entity< CPickup >::FindByID)
.Func(_SC("IfTagEquals"), &Entity< CPickup >::FirstWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CPickup >::FirstWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CPickup >::FirstWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CPickup >::FirstWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CPickup >::FirstWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CPickup >::FirstWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CPickup >::FirstWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CPickup >::FirstWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CPickup >::FirstWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CPickup >::FirstWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CPickup >::FirstWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CPickup >::FirstWhereTagNotContains)
); );
fns.Bind(_SC("Player"), Table(vm) fns.Bind(_SC("Player"), Table(vm)
.Func(_SC("WithID"), &Entity< CPlayer >::FindByID) .Func(_SC("WithID"), &Entity< CPlayer >::FindByID)
.Func(_SC("IfTagEquals"), &Entity< CPlayer >::FirstWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CPlayer >::FirstWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CPlayer >::FirstWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CPlayer >::FirstWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CPlayer >::FirstWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CPlayer >::FirstWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CPlayer >::FirstWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CPlayer >::FirstWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CPlayer >::FirstWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CPlayer >::FirstWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CPlayer >::FirstWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CPlayer >::FirstWhereTagNotContains)
); );
fns.Bind(_SC("Vehicle"), Table(vm) fns.Bind(_SC("Vehicle"), Table(vm)
.Func(_SC("WithID"), &Entity< CVehicle >::FindByID) .Func(_SC("WithID"), &Entity< CVehicle >::FindByID)
.Func(_SC("IfTagEquals"), &Entity< CVehicle >::FirstWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CVehicle >::FirstWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CVehicle >::FirstWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CVehicle >::FirstWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CVehicle >::FirstWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CVehicle >::FirstWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CVehicle >::FirstWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CVehicle >::FirstWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CVehicle >::FirstWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CVehicle >::FirstWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CVehicle >::FirstWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CVehicle >::FirstWhereTagNotContains)
); );
RootTable(vm).Bind(_SC("SqFind"), fns); RootTable(vm).Bind(_SC("SqFind"), fns);
@ -108,87 +80,59 @@ void Register(HSQUIRRELVM vm)
Table cns(vm); Table cns(vm);
cns.Bind(_SC("Blip"), Table(vm) cns.Bind(_SC("Blip"), Table(vm)
.Func(_SC("IfActive"), &Entity< CBlip >::AllActive) .Func(_SC("Active"), &Entity< CBlip >::AllActive)
.Func(_SC("IfTagEquals"), &Entity< CBlip >::AllWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CBlip >::AllWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CBlip >::AllWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CBlip >::AllWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CBlip >::AllWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CBlip >::AllWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CBlip >::AllWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CBlip >::AllWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CBlip >::AllWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CBlip >::AllWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CBlip >::AllWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CBlip >::AllWhereTagNotContains)
); );
cns.Bind(_SC("Checkpoint"), Table(vm) cns.Bind(_SC("Checkpoint"), Table(vm)
.Func(_SC("IfActive"), &Entity< CCheckpoint >::AllActive) .Func(_SC("Active"), &Entity< CCheckpoint >::AllActive)
.Func(_SC("IfTagEquals"), &Entity< CCheckpoint >::AllWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CCheckpoint >::AllWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CCheckpoint >::AllWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CCheckpoint >::AllWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CCheckpoint >::AllWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CCheckpoint >::AllWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CCheckpoint >::AllWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CCheckpoint >::AllWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CCheckpoint >::AllWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CCheckpoint >::AllWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CCheckpoint >::AllWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CCheckpoint >::AllWhereTagNotContains)
); );
cns.Bind(_SC("Keybind"), Table(vm) cns.Bind(_SC("Keybind"), Table(vm)
.Func(_SC("IfActive"), &Entity< CKeybind >::AllActive) .Func(_SC("Active"), &Entity< CKeybind >::AllActive)
.Func(_SC("IfTagEquals"), &Entity< CKeybind >::AllWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CKeybind >::AllWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CKeybind >::AllWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CKeybind >::AllWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CKeybind >::AllWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CKeybind >::AllWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CKeybind >::AllWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CKeybind >::AllWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CKeybind >::AllWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CKeybind >::AllWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CKeybind >::AllWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CKeybind >::AllWhereTagNotContains)
); );
cns.Bind(_SC("Object"), Table(vm) cns.Bind(_SC("Object"), Table(vm)
.Func(_SC("IfActive"), &Entity< CObject >::AllActive) .Func(_SC("Active"), &Entity< CObject >::AllActive)
.Func(_SC("IfTagEquals"), &Entity< CObject >::AllWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CObject >::AllWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CObject >::AllWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CObject >::AllWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CObject >::AllWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CObject >::AllWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CObject >::AllWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CObject >::AllWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CObject >::AllWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CObject >::AllWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CObject >::AllWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CObject >::AllWhereTagNotContains)
); );
cns.Bind(_SC("Pickup"), Table(vm) cns.Bind(_SC("Pickup"), Table(vm)
.Func(_SC("IfActive"), &Entity< CPickup >::AllActive) .Func(_SC("Active"), &Entity< CPickup >::AllActive)
.Func(_SC("IfTagEquals"), &Entity< CPickup >::AllWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CPickup >::AllWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CPickup >::AllWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CPickup >::AllWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CPickup >::AllWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CPickup >::AllWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CPickup >::AllWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CPickup >::AllWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CPickup >::AllWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CPickup >::AllWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CPickup >::AllWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CPickup >::AllWhereTagNotContains)
); );
cns.Bind(_SC("Player"), Table(vm) cns.Bind(_SC("Player"), Table(vm)
.Func(_SC("IfActive"), &Entity< CPlayer >::AllActive) .Func(_SC("Active"), &Entity< CPlayer >::AllActive)
.Func(_SC("IfTagEquals"), &Entity< CPlayer >::AllWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CPlayer >::AllWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CPlayer >::AllWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CPlayer >::AllWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CPlayer >::AllWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CPlayer >::AllWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CPlayer >::AllWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CPlayer >::AllWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CPlayer >::AllWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CPlayer >::AllWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CPlayer >::AllWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CPlayer >::AllWhereTagNotContains)
); );
cns.Bind(_SC("Vehicle"), Table(vm) cns.Bind(_SC("Vehicle"), Table(vm)
.Func(_SC("IfActive"), &Entity< CVehicle >::AllActive) .Func(_SC("Active"), &Entity< CVehicle >::AllActive)
.Func(_SC("IfTagEquals"), &Entity< CVehicle >::AllWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CVehicle >::AllWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CVehicle >::AllWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CVehicle >::AllWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CVehicle >::AllWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CVehicle >::AllWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CVehicle >::AllWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CVehicle >::AllWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CVehicle >::AllWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CVehicle >::AllWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CVehicle >::AllWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CVehicle >::AllWhereTagNotContains)
); );
RootTable(vm).Bind(_SC("SqCollect"), cns); RootTable(vm).Bind(_SC("SqCollect"), cns);
@ -196,87 +140,59 @@ void Register(HSQUIRRELVM vm)
Table ens(vm); Table ens(vm);
ens.Bind(_SC("Blip"), Table(vm) ens.Bind(_SC("Blip"), Table(vm)
.Func(_SC("IfActive"), &Entity< CBlip >::EachActive) .Func(_SC("Active"), &Entity< CBlip >::EachActive)
.Func(_SC("IfTagEquals"), &Entity< CBlip >::EachWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CBlip >::EachWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CBlip >::EachWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CBlip >::EachWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CBlip >::EachWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CBlip >::EachWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CBlip >::EachWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CBlip >::EachWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CBlip >::EachWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CBlip >::EachWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CBlip >::EachWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CBlip >::EachWhereTagNotContains)
); );
ens.Bind(_SC("Checkpoint"), Table(vm) ens.Bind(_SC("Checkpoint"), Table(vm)
.Func(_SC("IfActive"), &Entity< CCheckpoint >::EachActive) .Func(_SC("Active"), &Entity< CCheckpoint >::EachActive)
.Func(_SC("IfTagEquals"), &Entity< CCheckpoint >::EachWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CCheckpoint >::EachWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CCheckpoint >::EachWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CCheckpoint >::EachWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CCheckpoint >::EachWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CCheckpoint >::EachWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CCheckpoint >::EachWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CCheckpoint >::EachWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CCheckpoint >::EachWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CCheckpoint >::EachWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CCheckpoint >::EachWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CCheckpoint >::EachWhereTagNotContains)
); );
ens.Bind(_SC("Keybind"), Table(vm) ens.Bind(_SC("Keybind"), Table(vm)
.Func(_SC("IfActive"), &Entity< CKeybind >::EachActive) .Func(_SC("Active"), &Entity< CKeybind >::EachActive)
.Func(_SC("IfTagEquals"), &Entity< CKeybind >::EachWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CKeybind >::EachWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CKeybind >::EachWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CKeybind >::EachWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CKeybind >::EachWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CKeybind >::EachWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CKeybind >::EachWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CKeybind >::EachWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CKeybind >::EachWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CKeybind >::EachWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CKeybind >::EachWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CKeybind >::EachWhereTagNotContains)
); );
ens.Bind(_SC("Object"), Table(vm) ens.Bind(_SC("Object"), Table(vm)
.Func(_SC("IfActive"), &Entity< CObject >::EachActive) .Func(_SC("Active"), &Entity< CObject >::EachActive)
.Func(_SC("IfTagEquals"), &Entity< CObject >::EachWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CObject >::EachWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CObject >::EachWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CObject >::EachWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CObject >::EachWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CObject >::EachWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CObject >::EachWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CObject >::EachWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CObject >::EachWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CObject >::EachWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CObject >::EachWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CObject >::EachWhereTagNotContains)
); );
ens.Bind(_SC("Pickup"), Table(vm) ens.Bind(_SC("Pickup"), Table(vm)
.Func(_SC("IfActive"), &Entity< CPickup >::EachActive) .Func(_SC("Active"), &Entity< CPickup >::EachActive)
.Func(_SC("IfTagEquals"), &Entity< CPickup >::EachWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CPickup >::EachWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CPickup >::EachWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CPickup >::EachWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CPickup >::EachWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CPickup >::EachWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CPickup >::EachWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CPickup >::EachWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CPickup >::EachWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CPickup >::EachWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CPickup >::EachWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CPickup >::EachWhereTagNotContains)
); );
ens.Bind(_SC("Player"), Table(vm) ens.Bind(_SC("Player"), Table(vm)
.Func(_SC("IfActive"), &Entity< CPlayer >::EachActive) .Func(_SC("Active"), &Entity< CPlayer >::EachActive)
.Func(_SC("IfTagEquals"), &Entity< CPlayer >::EachWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CPlayer >::EachWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CPlayer >::EachWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CPlayer >::EachWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CPlayer >::EachWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CPlayer >::EachWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CPlayer >::EachWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CPlayer >::EachWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CPlayer >::EachWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CPlayer >::EachWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CPlayer >::EachWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CPlayer >::EachWhereTagNotContains)
); );
ens.Bind(_SC("Vehicle"), Table(vm) ens.Bind(_SC("Vehicle"), Table(vm)
.Func(_SC("IfActive"), &Entity< CVehicle >::EachActive) .Func(_SC("Active"), &Entity< CVehicle >::EachActive)
.Func(_SC("IfTagEquals"), &Entity< CVehicle >::EachWhereTagEquals) .Func(_SC("TagEquals"), &Entity< CVehicle >::EachWhereTagEquals)
.Func(_SC("IfTagNotEquals"), &Entity< CVehicle >::EachWhereTagNotEquals) .Func(_SC("TagBegins"), &Entity< CVehicle >::EachWhereTagBegins)
.Func(_SC("IfTagBegins"), &Entity< CVehicle >::EachWhereTagBegins) .Func(_SC("TagEnds"), &Entity< CVehicle >::EachWhereTagEnds)
.Func(_SC("IfTagNotBegins"), &Entity< CVehicle >::EachWhereTagNotBegins) .Func(_SC("TagContains"), &Entity< CVehicle >::EachWhereTagContains)
.Func(_SC("IfTagEnds"), &Entity< CVehicle >::EachWhereTagEnds)
.Func(_SC("IfTagNotEnds"), &Entity< CVehicle >::EachWhereTagNotEnds)
.Func(_SC("IfTagContains"), &Entity< CVehicle >::EachWhereTagContains)
.Func(_SC("IfTagNotContains"), &Entity< CVehicle >::EachWhereTagNotContains)
); );
RootTable(vm).Bind(_SC("SqForeach"), ens); RootTable(vm).Bind(_SC("SqForeach"), ens);

View File

@ -31,16 +31,16 @@ void Collect(Iterator first, Iterator last, Inspector inspect, Collector collect
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag matches the specified one. * Collect all elements within the specified range where the string matches or not the specified one.
*/ */
template < typename Iterator, typename Inspector, typename Retriever, typename Collector > template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagEquals(Iterator first, Iterator last, void EachEquals(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect, Inspector inspect, Retriever retrieve, Collector collect,
CSStr str) CSStr str, bool neg)
{ {
for (; first != last; ++first) for (; first != last; ++first)
{ {
if (inspect(*first) && retrieve(*first).compare(str) == 0) if (inspect(*first) && (retrieve(*first).compare(str) == 0) == neg)
{ {
collect(*first); collect(*first);
} }
@ -48,54 +48,13 @@ void CollectIfTagEquals(Iterator first, Iterator last,
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag does not match the specified one. * Collect all elements within the specified range where the string begins or not with the specified
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagNotEquals(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect,
CSStr str)
{
for (; first != last; ++first)
{
if (inspect(*first) && retrieve(*first).compare(str) != 0)
{
collect(*first);
}
}
}
/* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag begins with the specified string.
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagBegins(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect,
CSStr str, std::size_t len)
{
for (; first != last; ++first)
{
if (!inspect(*first))
{
continue;
}
// Retrieve the tag
const String & tag = retrieve(*first);
// Compare the tag
if (tag.size() > len && tag.compare(0, len, str) == 0)
{
collect(*first);
}
}
}
/* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag does not begin with the specified
* string. * string.
*/ */
template < typename Iterator, typename Inspector, typename Retriever, typename Collector > template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagNotBegins(Iterator first, Iterator last, void EachBegins(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect, Inspector inspect, Retriever retrieve, Collector collect,
CSStr str, std::size_t len) CSStr str, std::size_t len, bool neg)
{ {
for (; first != last; ++first) for (; first != last; ++first)
{ {
@ -106,7 +65,7 @@ void CollectIfTagNotBegins(Iterator first, Iterator last,
// Retrieve the tag // Retrieve the tag
const String & tag = retrieve(*first); const String & tag = retrieve(*first);
// Compare the tag // Compare the tag
if (tag.size() > len && tag.compare(0, len, str) != 0) if (tag.size() > len && (tag.compare(0, len, str) == 0) == neg)
{ {
collect(*first); collect(*first);
} }
@ -114,37 +73,13 @@ void CollectIfTagNotBegins(Iterator first, Iterator last,
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag ends with the specified string. * Collect all elements within the specified range where the string ends or not with the specified
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagEnds(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect,
CSStr str, std::size_t len)
{
for (; first != last; ++first)
{
if (!inspect(*first))
{
continue;
}
// Retrieve the tag
const String & tag = retrieve(*first);
// Compare the tag
if (tag.size() > len && tag.compare(tag.size() - len, len, str) == 0)
{
collect(*first);
}
}
}
/* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag does not end with the specified
* string. * string.
*/ */
template < typename Iterator, typename Inspector, typename Retriever, typename Collector > template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagNotEnds(Iterator first, Iterator last, void EachEnds(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect, Inspector inspect, Retriever retrieve, Collector collect,
CSStr str, std::size_t len) CSStr str, std::size_t len, bool neg)
{ {
for (; first != last; ++first) for (; first != last; ++first)
{ {
@ -155,7 +90,7 @@ void CollectIfTagNotEnds(Iterator first, Iterator last,
// Retrieve the tag // Retrieve the tag
const String & tag = retrieve(*first); const String & tag = retrieve(*first);
// Compare the tag // Compare the tag
if (tag.size() > len && tag.compare(tag.size() - len, len, str) != 0) if (tag.size() > len && (tag.compare(tag.size() - len, len, str) == 0) == neg)
{ {
collect(*first); collect(*first);
} }
@ -163,34 +98,17 @@ void CollectIfTagNotEnds(Iterator first, Iterator last,
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag contains the specified string. * Collect all elements within the specified range where the string contains or not the specified
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagContains(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect,
CSStr str)
{
for (; first != last; ++first)
{
if (inspect(*first) && retrieve(*first).find(str) != String::npos)
{
collect(*first);
}
}
}
/* ------------------------------------------------------------------------------------------------
* Collect all elements within the specified range where the tag does not contain the specified
* string. * string.
*/ */
template < typename Iterator, typename Inspector, typename Retriever, typename Collector > template < typename Iterator, typename Inspector, typename Retriever, typename Collector >
void CollectIfTagNotContains(Iterator first, Iterator last, void EachContains(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Collector collect, Inspector inspect, Retriever retrieve, Collector collect,
CSStr str) CSStr str, bool neg)
{ {
for (; first != last; ++first) for (; first != last; ++first)
{ {
if (inspect(*first) && retrieve(*first).find(str) == String::npos) if (inspect(*first) && (retrieve(*first).find(str) != String::npos) == neg)
{ {
collect(*first); collect(*first);
} }
@ -198,130 +116,31 @@ void CollectIfTagNotContains(Iterator first, Iterator last,
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag matches the specified one. * Find the first element within the specified range where the string matches or not the specified one.
*/ */
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver > template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagEquals(Iterator first, Iterator last, void FirstEquals(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive, Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str) CSStr str, bool neg)
{ {
for (; first != last; ++first) for (; first != last; ++first)
{ {
if (inspect(*first) && retrieve(*first).compare(str) == 0) if (inspect(*first) && (retrieve(*first).compare(str) == 0) == neg)
{ {
receive(*first); receive(*first);
return true; break;
} }
} }
return false;
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag does not match the specified one. * Find the first element within the specified range where the string begins or not with the specified
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagNotEquals(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str)
{
for (; first != last; ++first)
{
if (inspect(*first) && retrieve(*first).compare(str) != 0)
{
receive(*first);
return true;
}
}
return false;
}
/* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag begins with the specified string.
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagBegins(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str, std::size_t len)
{
for (; first != last; ++first)
{
if (!inspect(*first))
{
continue;
}
// Retrieve the tag
const String & tag = retrieve(*first);
// Compare the tag
if (tag.size() > len && tag.compare(0, len, str) == 0)
{
receive(*first);
return true;
}
}
return false;
}
/* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag does not begin with the
* specified string.
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagNotBegins(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str, std::size_t len)
{
for (; first != last; ++first)
{
if (!inspect(*first))
{
continue;
}
// Retrieve the tag
const String & tag = retrieve(*first);
// Compare the tag
if (tag.size() > len && tag.compare(0, len, str) != 0)
{
receive(*first);
return true;
}
}
return false;
}
/* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag ends with the specified string.
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagEnds(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str, std::size_t len)
{
for (; first != last; ++first)
{
if (!inspect(*first))
{
continue;
}
// Retrieve the tag
const String & tag = retrieve(*first);
// Compare the tag
if (tag.size() > len && tag.compare(tag.size() - len, len, str) == 0)
{
receive(*first);
return true;
}
}
return false;
}
/* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag does not end with the specified
* string. * string.
*/ */
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver > template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagNotEnds(Iterator first, Iterator last, void FirstBegins(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive, Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str, std::size_t len) CSStr str, std::size_t len, bool neg)
{ {
for (; first != last; ++first) for (; first != last; ++first)
{ {
@ -332,52 +151,57 @@ bool FindIfTagNotEnds(Iterator first, Iterator last,
// Retrieve the tag // Retrieve the tag
const String & tag = retrieve(*first); const String & tag = retrieve(*first);
// Compare the tag // Compare the tag
if (tag.size() > len && tag.compare(tag.size() - len, len, str) != 0) if (tag.size() > len && (tag.compare(0, len, str) == 0) == neg)
{ {
receive(*first); receive(*first);
return true; break;
} }
} }
return false;
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag contains the specified string. * Find the first element within the specified range where the string ends or not with the specified
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagContains(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str)
{
for (; first != last; ++first)
{
if (inspect(*first) && retrieve(*first).find(str) != String::npos)
{
receive(*first);
return true;
}
}
return false;
}
/* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the tag does not contain the specified
* string. * string.
*/ */
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver > template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
bool FindIfTagNotContains(Iterator first, Iterator last, void FirstEnds(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive, Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str) CSStr str, std::size_t len, bool neg)
{ {
for (; first != last; ++first) for (; first != last; ++first)
{ {
if (inspect(*first) && retrieve(*first).find(str) == String::npos) if (!inspect(*first))
{
continue;
}
// Retrieve the tag
const String & tag = retrieve(*first);
// Compare the tag
if (tag.size() > len && (tag.compare(tag.size() - len, len, str) == 0) == neg)
{ {
receive(*first); receive(*first);
return true; break;
}
}
}
/* ------------------------------------------------------------------------------------------------
* Find the first element within the specified range where the string contains or not the specified
* string.
*/
template < typename Iterator, typename Inspector, typename Retriever, typename Receiver >
void FirstContains(Iterator first, Iterator last,
Inspector inspect, Retriever retrieve, Receiver receive,
CSStr str, bool neg)
{
for (; first != last; ++first)
{
if (inspect(*first) && (retrieve(*first).find(str) != String::npos) == neg)
{
receive(*first);
break;
} }
} }
return false;
} }
/* ------------------------------------------------------------------------------------------------ /* ------------------------------------------------------------------------------------------------
@ -835,9 +659,9 @@ public:
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the tag matches the specified one. * Collect all entities of this type where the string match or not the specified one.
*/ */
static inline Array AllWhereTagEquals(CSStr tag) static inline Array AllWhereTagEquals(bool neg, CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size // Remember the current stack size
@ -845,16 +669,15 @@ public:
// Allocate an empty array on the stack // Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0); sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagEquals(Inst::CBegin(), Inst::CEnd(), EachEquals(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), AppendElem(), tag, neg);
ValidInst(), InstTag(), AppendElem(), tag);
// Return the array at the top of the stack // Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value; return Var< Array >(DefaultVM::Get(), -1).value;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the tag does not match the specified one. * Collect all entities of this type where the string begins or not with the specified string.
*/ */
static inline Array AllWhereTagNotEquals(CSStr tag) static inline Array AllWhereTagBegins(bool neg, CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size // Remember the current stack size
@ -862,16 +685,15 @@ public:
// Allocate an empty array on the stack // Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0); sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagNotEquals(Inst::CBegin(), Inst::CEnd(), EachBegins(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), AppendElem(), tag, strlen(tag), neg);
ValidInst(), InstTag(), AppendElem(), tag);
// Return the array at the top of the stack // Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value; return Var< Array >(DefaultVM::Get(), -1).value;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the tag begins with the specified string. * Collect all entities of this type where the string ends or not with the specified string.
*/ */
static inline Array AllWhereTagBegins(CSStr tag) static inline Array AllWhereTagEnds(bool neg, CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size // Remember the current stack size
@ -879,16 +701,15 @@ public:
// Allocate an empty array on the stack // Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0); sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagBegins(Inst::CBegin(), Inst::CEnd(), EachEnds(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), AppendElem(), tag, strlen(tag), neg);
ValidInst(), InstTag(), AppendElem(), tag, std::strlen(tag));
// Return the array at the top of the stack // Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value; return Var< Array >(DefaultVM::Get(), -1).value;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the does not begin with the specified string. * Collect all entities of this type where the string contains or not the specified string.
*/ */
static inline Array AllWhereTagNotBegins(CSStr tag) static inline Array AllWhereTagContains(bool neg, CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size // Remember the current stack size
@ -896,198 +717,65 @@ public:
// Allocate an empty array on the stack // Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0); sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagNotBegins(Inst::CBegin(), Inst::CEnd(), EachContains(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), AppendElem(), tag, neg);
ValidInst(), InstTag(), AppendElem(), tag, std::strlen(tag));
// Return the array at the top of the stack // Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value; return Var< Array >(DefaultVM::Get(), -1).value;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the tag ends with the specified string. * Retrieve the first entity of this type where the tag matches or not the specified one.
*/ */
static inline Array AllWhereTagEnds(CSStr tag) static inline Object FirstWhereTagEquals(bool neg, CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size
const StackGuard sg;
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
CollectIfTagEnds(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), AppendElem(), tag, std::strlen(tag));
// Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value;
}
/* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the tag does not end with the specified string.
*/
static inline Array AllWhereTagNotEnds(CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size
const StackGuard sg;
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
CollectIfTagNotEnds(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), AppendElem(), tag, std::strlen(tag));
// Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value;
}
/* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the tag contains the specified string.
*/
static inline Array AllWhereTagContains(CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size
const StackGuard sg;
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
CollectIfTagContains(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), AppendElem(), tag);
// Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value;
}
/* --------------------------------------------------------------------------------------------
* Collect all entities of this type where the tag does not contain the specified string.
*/
static inline Array AllWhereTagNotContains(CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Remember the current stack size
const StackGuard sg;
// Allocate an empty array on the stack
sq_newarray(DefaultVM::Get(), 0);
// Process each entity in the pool
CollectIfTagNotContains(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), AppendElem(), tag);
// Return the array at the top of the stack
return Var< Array >(DefaultVM::Get(), -1).value;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the tag matches the specified one.
*/
static inline Object FirstWhereTagEquals(CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver // Create a new element receiver
RecvElem recv; RecvElem recv;
// Process each entity in the pool // Process each entity in the pool
FindIfTagEquals(Inst::CBegin(), Inst::CEnd(), FirstEquals(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), recv, tag, neg);
ValidInst(), InstTag(), recv, tag);
// Return the received element, if any // Return the received element, if any
return recv; return recv.mObj;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the tag does not match the specified one. * Retrieve the first entity of this type where the tag begins or not with the specified string.
*/ */
static inline Object FirstWhereTagNotEquals(CSStr tag) static inline Object FirstWhereTagBegins(bool neg, CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver // Create a new element receiver
RecvElem recv; RecvElem recv;
// Process each entity in the pool // Process each entity in the pool
FindIfTagNotEquals(Inst::CBegin(), Inst::CEnd(), FirstBegins(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), recv, tag, strlen(tag), neg);
ValidInst(), InstTag(), recv, tag);
// Return the received element, if any // Return the received element, if any
return recv; return recv.mObj;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the tag begins with the specified string. * Retrieve the first entity of this type where the tag ends or not with the specified string.
*/ */
static inline Object FirstWhereTagBegins(CSStr tag) static inline Object FirstWhereTagEnds(bool neg, CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver // Create a new element receiver
RecvElem recv; RecvElem recv;
// Process each entity in the pool // Process each entity in the pool
CollectIfTagBegins(Inst::CBegin(), Inst::CEnd(), FirstEnds(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), recv, tag, strlen(tag), neg);
ValidInst(), InstTag(), recv, tag, std::strlen(tag));
// Return the received element, if any // Return the received element, if any
return recv; return recv.mObj;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the does not begin with the specified string. * Retrieve the first entity of this type where the tag contains or not the specified string.
*/ */
static inline Object FirstWhereTagNotBegins(CSStr tag) static inline Object FirstWhereTagContains(bool neg, CSStr tag)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver // Create a new element receiver
RecvElem recv; RecvElem recv;
// Process each entity in the pool // Process each entity in the pool
FindIfTagNotBegins(Inst::CBegin(), Inst::CEnd(), FirstContains(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), recv, tag, neg);
ValidInst(), InstTag(), recv, tag, std::strlen(tag));
// Return the received element, if any // Return the received element, if any
return recv; return recv.mObj;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the tag ends with the specified string.
*/
static inline Object FirstWhereTagEnds(CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver
RecvElem recv;
// Process each entity in the pool
FindIfTagEnds(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), recv, tag, std::strlen(tag));
// Return the received element, if any
return recv;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the tag does not end with the specified string.
*/
static inline Object FirstWhereTagNotEnds(CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver
RecvElem recv;
// Process each entity in the pool
FindIfTagNotEnds(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), recv, tag, std::strlen(tag));
// Return the received element, if any
return recv;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the tag contains the specified string.
*/
static inline Object FirstWhereTagContains(CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver
RecvElem recv;
// Process each entity in the pool
FindIfTagContains(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), recv, tag);
// Return the received element, if any
return recv;
}
/* --------------------------------------------------------------------------------------------
* Retrieve the first entity of this type where the tag does not contain the specified string.
*/
static inline Object FirstWhereTagNotContains(CSStr tag)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element receiver
RecvElem recv;
// Process each entity in the pool
FindIfTagNotContains(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), recv, tag);
// Return the received element, if any
return recv;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -1104,121 +792,57 @@ public:
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Process all entities of this type where the tag matches the specified one. * Process all entities of this type where the string matches or not the specified one.
*/ */
static inline Uint32 EachWhereTagEquals(CSStr tag, Object & env, Function & func) static inline Uint32 EachWhereTagEquals(bool neg, CSStr tag, Object & env, Function & func)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder // Create a new element forwarder
ForwardElem fwd(env, func); ForwardElem fwd(env, func);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagEquals(Inst::CBegin(), Inst::CEnd(), EachEquals(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), fwd, tag, neg);
ValidInst(), InstTag(), fwd, tag);
// Return the forward count // Return the forward count
return fwd.mCount; return fwd.mCount;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Process all entities of this type where the tag does not match the specified one. * Process all entities of this type where the string begins with the specified string.
*/ */
static inline Uint32 EachWhereTagNotEquals(CSStr tag, Object & env, Function & func) static inline Uint32 EachWhereTagBegins(bool neg, CSStr tag, Object & env, Function & func)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder // Create a new element forwarder
ForwardElem fwd(env, func); ForwardElem fwd(env, func);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagNotEquals(Inst::CBegin(), Inst::CEnd(), EachBegins(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), fwd, tag, strlen(tag), neg);
ValidInst(), InstTag(), fwd, tag);
// Return the forward count // Return the forward count
return fwd.mCount; return fwd.mCount;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Process all entities of this type where the tag begins with the specified string. * Process all entities of this type where the string ends or not with the specified string.
*/ */
static inline Uint32 EachWhereTagBegins(CSStr tag, Object & env, Function & func) static inline Uint32 EachWhereTagEnds(bool neg, CSStr tag, Object & env, Function & func)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder // Create a new element forwarder
ForwardElem fwd(env, func); ForwardElem fwd(env, func);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagBegins(Inst::CBegin(), Inst::CEnd(), EachEnds(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), fwd, tag, strlen(tag), neg);
ValidInst(), InstTag(), fwd, tag, std::strlen(tag));
// Return the forward count // Return the forward count
return fwd.mCount; return fwd.mCount;
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Process all entities of this type where the does not begin with the specified string. * Process all entities of this type where the string contains the specified string.
*/ */
static inline Uint32 EachWhereTagNotBegins(CSStr tag, Object & env, Function & func) static inline Uint32 EachWhereTagContains(bool neg, CSStr tag, Object & env, Function & func)
{ {
SQMOD_VALID_TAG_STR(tag) SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder // Create a new element forwarder
ForwardElem fwd(env, func); ForwardElem fwd(env, func);
// Process each entity in the pool // Process each entity in the pool
CollectIfTagNotBegins(Inst::CBegin(), Inst::CEnd(), EachContains(Inst::CBegin(), Inst::CEnd(), ValidInst(), InstTag(), fwd, tag, neg);
ValidInst(), InstTag(), fwd, tag, std::strlen(tag));
// Return the forward count
return fwd.mCount;
}
/* --------------------------------------------------------------------------------------------
* Process all entities of this type where the tag ends with the specified string.
*/
static inline Uint32 EachWhereTagEnds(CSStr tag, Object & env, Function & func)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder
ForwardElem fwd(env, func);
// Process each entity in the pool
CollectIfTagEnds(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), fwd, tag, std::strlen(tag));
// Return the forward count
return fwd.mCount;
}
/* --------------------------------------------------------------------------------------------
* Process all entities of this type where the tag does not end with the specified string.
*/
static inline Uint32 EachWhereTagNotEnds(CSStr tag, Object & env, Function & func)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder
ForwardElem fwd(env, func);
// Process each entity in the pool
CollectIfTagNotEnds(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), fwd, tag, std::strlen(tag));
// Return the forward count
return fwd.mCount;
}
/* --------------------------------------------------------------------------------------------
* Process all entities of this type where the tag contains the specified string.
*/
static inline Uint32 EachWhereTagContains(CSStr tag, Object & env, Function & func)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder
ForwardElem fwd(env, func);
// Process each entity in the pool
CollectIfTagContains(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), fwd, tag);
// Return the forward count
return fwd.mCount;
}
/* --------------------------------------------------------------------------------------------
* Process all entities of this type where the tag does not contain the specified string.
*/
static inline Uint32 EachWhereTagNotContains(CSStr tag, Object & env, Function & func)
{
SQMOD_VALID_TAG_STR(tag)
// Create a new element forwarder
ForwardElem fwd(env, func);
// Process each entity in the pool
CollectIfTagNotContains(Inst::CBegin(), Inst::CEnd(),
ValidInst(), InstTag(), fwd, tag);
// Return the forward count // Return the forward count
return fwd.mCount; return fwd.mCount;
} }