Expose StripLeft and StripLeftRight to ZScript

This commit is contained in:
Ricardo Luís Vaz Silva 2022-12-18 21:19:36 -03:00 committed by Christoph Oelckers
parent 3ffbda5526
commit 43880bbbe1
2 changed files with 30 additions and 0 deletions

View File

@ -578,6 +578,34 @@ DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripRight, StringStripRight)
return 0;
}
static void StringStripLeft(FString* self, const FString& junk)
{
if (junk.IsNotEmpty()) self->StripLeft(junk);
else self->StripLeft();
}
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripLeft, StringStripLeft)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(junk);
StringStripLeft(self, junk);
return 0;
}
static void StringStripLeftRight(FString* self, const FString& junk)
{
if (junk.IsNotEmpty()) self->StripLeftRight(junk);
else self->StripLeftRight();
}
DEFINE_ACTION_FUNCTION_NATIVE(FStringStruct, StripLeftRight, StringStripLeftRight)
{
PARAM_SELF_STRUCT_PROLOGUE(FString);
PARAM_STRING(junk);
StringStripLeftRight(self, junk);
return 0;
}
static void StringSplit(FString* self, TArray<FString>* tokens, const FString& delimiter, int keepEmpty)
{
self->Split(*tokens, delimiter, static_cast<FString::EmptyTokenType>(keepEmpty));

View File

@ -881,7 +881,9 @@ struct StringStruct native
native int CodePointCount() const;
native int, int GetNextCodePoint(int position) const;
native void Substitute(String str, String replace);
native void StripLeft(String junk = "");
native void StripRight(String junk = "");
native void StripLeftRight(String junk = "");
}
struct Translation version("2.4")