Added IndexOf() and LastIndexOf() functions to ZScript string type

https://forum.zdoom.org/viewtopic.php?t=57313
This commit is contained in:
alexey.lysiuk 2017-07-22 10:54:32 +03:00
parent ebd20daed8
commit c56cd245ac
2 changed files with 17 additions and 0 deletions

View file

@ -1252,3 +1252,18 @@ DEFINE_ACTION_FUNCTION(FStringStruct, Filter)
ACTION_RETURN_STRING(strbin1(*self)); ACTION_RETURN_STRING(strbin1(*self));
} }
DEFINE_ACTION_FUNCTION(FStringStruct, IndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
PARAM_INT_DEF(startIndex);
ACTION_RETURN_INT(self->IndexOf(substr, startIndex));
}
DEFINE_ACTION_FUNCTION(FStringStruct, LastIndexOf)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(substr);
ACTION_RETURN_INT(self->LastIndexOf(substr));
}

View file

@ -656,6 +656,8 @@ struct StringStruct native
native String CharAt(int pos) const; native String CharAt(int pos) const;
native int CharCodeAt(int pos) const; native int CharCodeAt(int pos) const;
native String Filter(); native String Filter();
native int IndexOf(String substr, int startIndex = 0) const;
native int LastIndexOf(String substr) const;
} }
class SectorEffect : Thinker native class SectorEffect : Thinker native