mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Exposed string split functionality to ZScript
https://forum.zdoom.org/viewtopic.php?t=58114
This commit is contained in:
parent
3b3f2e20cc
commit
c4865d2bb6
2 changed files with 17 additions and 0 deletions
|
@ -1293,3 +1293,13 @@ DEFINE_ACTION_FUNCTION(FStringStruct, ToDouble)
|
|||
PARAM_SELF_STRUCT_PROLOGUE(FString);
|
||||
ACTION_RETURN_FLOAT(self->ToDouble());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(FStringStruct, Split)
|
||||
{
|
||||
PARAM_SELF_STRUCT_PROLOGUE(FString);
|
||||
PARAM_POINTER(tokens, TArray<FString>);
|
||||
PARAM_STRING(delimiter);
|
||||
PARAM_INT_DEF(keepEmpty);
|
||||
self->Split(*tokens, delimiter, static_cast<FString::EmptyTokenType>(keepEmpty));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -659,6 +659,12 @@ enum EPickStart
|
|||
PPS_NOBLOCKINGCHECK = 2,
|
||||
}
|
||||
|
||||
enum EmptyTokenType
|
||||
{
|
||||
TOK_SKIPEMPTY = 0,
|
||||
TOK_KEEPEMPTY = 1,
|
||||
}
|
||||
|
||||
// Although String is a builtin type, this is a convenient way to attach methods to it.
|
||||
struct StringStruct native
|
||||
{
|
||||
|
@ -678,6 +684,7 @@ struct StringStruct native
|
|||
native void ToLower();
|
||||
native int ToInt(int base = 0) const;
|
||||
native double ToDouble() const;
|
||||
native void Split(out Array<String> tokens, String delimiter, EmptyTokenType keepEmpty = TOK_KEEPEMPTY) const;
|
||||
}
|
||||
|
||||
class SectorEffect : Thinker native
|
||||
|
|
Loading…
Reference in a new issue