DayZ Enforce
Script API
Static Private Member Functions | Static Private Attributes | List of all members
EnString Class Reference

#include <EnString.h>

Static Private Member Functions

static proto string  SubString (string str, int start, int len)
  Substring of 'str' from 'start' position 'len' number of characters. More...
 
static proto int  Replace (inout string str, string sample, string replace)
  Replace all occurrances of 'sample' in 'str' by 'replace'. More...
 
static proto int  ToLowerCase (out string str)
  Changes string to lowercase. Returns length. More...
 
static proto int  ToUpperCase (out string str)
  Changes string to uppercase. Returns length. More...
 
static proto int  Length (string str)
  Returns length of string. More...
 
static proto int  Contains (string str, string sample)
  Finds 'sample' in 'str'. Returns -1 when not found. More...
 
static proto int  ContainsFrom (string str, int start, string sample)
  Finds 'sample' in 'str' from 'start' position. Returns -1 when not found. More...
 
static proto string  Trim (string str)
  Returns trimmed string with removed leading and trailing whitespaces. More...
 
static proto int  TrimInPlace (string str)
  Removes leading and trailing whitespaces in string. Returns length. More...
 
static proto int  ParseStringEx (inout string input, string token)
  Parses one token from input string. Result is put into token string, and type of token is returned. Input string is left-truncated by the resulting token length. More...
 
static proto int  ParseString (string input, out string tokens[])
  Parses string into array of tokens returns number of tokens. More...
 
static void  Split (string param, string sample, out TStringArray output)
  Splits string 'param' into array of strings separated by 'sample'. More...
 

Static Private Attributes

static string  Empty
 

Member Function Documentation

static proto string EnString::SubString ( string  str,
int  start,
int  len 
)
staticprivate

Substring of 'str' from 'start' position 'len' number of characters.

Parameters
str Origin string
start Position in str
len Count of characters
Returns
string - Substring of str
string str = "Hello World";
string strSub = EnString.SubString(str, 2, 5);
Print(strSub);
>> strSub = llo W

Referenced by EN5C_SeedPackBase::EmptySeedPack(), ModuleConfigViewer::GetConfig(), ModuleConfigViewer::GetConfigRecursive(), InventoryMenu::RefreshPlayerStatus(), and DebugPrint::TrimDebugLog().

static proto int EnString::Replace ( inout string  str,
string  sample,
string  replace 
)
staticprivate

Replace all occurrances of 'sample' in 'str' by 'replace'.

Parameters
str Origin string
sample string to search in str
replace string which replace sample in str
Returns
int - number of occurrances of 'sample' in 'str'
string test = "If the length of the C string in source is less than num, only the content up to the terminating null-character is copied.";
Print(test);
int count = EnString.Replace(test, "the", "*");
Print(count);
Print(test);
>> string test = 'If the length of the C string in source is less than num, only the content up to the terminating null-character is copied.';
>> int count = 4
>> string test = 'If * length of * C string in source is less than num, only * content up to * terminating null-character is copied.'

Referenced by EN5C_PlantBase::GiveWater().

static proto int EnString::ToLowerCase ( out string  str )
staticprivate

Changes string to lowercase. Returns length.

Parameters
[out] str string to change
Returns
int - Length of changed string
string str = "Hello World";
int i = EnString.ToLowerCase(str);
Print(str);
Print(i);
>> str = hello world
>> i = 11

Referenced by ModuleConfigViewer::GetConfig(), ModuleConfigViewer::GetConfigRecursive(), and EN5C_PlantBase::GiveWater().

static proto int EnString::ToUpperCase ( out string  str )
staticprivate

Changes string to uppercase. Returns length.

Parameters
[out] str string to change
Returns
int - Length of changed string
string str = "Hello World";
int i = EnString.ToUpperCase(str);
Print(str);
Print(i);
>> str = HELLO WORLD
>> i = 11
static proto int EnString::Length ( string  str )
staticprivate

Returns length of string.

Parameters
strstr Origin string
Returns
int - Length of string str
int i = EnString.Length("Hello World");
Print(i);
>> i = 11

Referenced by EN5C_SeedPackBase::EmptySeedPack(), ModuleConfigViewer::GetConfig(), ModuleConfigViewer::GetConfigRecursive(), InventoryMenu::RefreshPlayerStatus(), DebugPrint::TrimDebugLog(), and ActionMenu::UpdateWidgets().

static proto int EnString::Contains ( string  str,
string  sample 
)
staticprivate

Finds 'sample' in 'str'. Returns -1 when not found.

Parameters
str string Origin string
sample string Finding string
Returns
int - Returns position where sample starts, or -1 when sample not found
Print( EnString.Contains( "Hello World", "H" ) );
Print( EnString.Contains( "Hello World", "W" ) );
Print( EnString.Contains( "Hello World", "Q" ) );
>> 0
>> 6
>> -1

Referenced by ActionEat::ApplyModifiers(), ModuleConfigViewer::GetConfig(), DebugPrint::IsDebugLog(), DebugPrint::IsStackTrace(), DebugPrint::TrimDebugLog(), and DebugPrint::TrimStackTrace().

static proto int EnString::ContainsFrom ( string  str,
int  start,
string  sample 
)
staticprivate

Finds 'sample' in 'str' from 'start' position. Returns -1 when not found.

Parameters
str string Origin string
start int Start from position
sample string Finding string expression
Returns
int - Length of string s
Print( EnString.ContainsFrom( "Hello World", 3, "H" ) );
Print( EnString.ContainsFrom( "Hello World", 3, "W" ) );
Print( EnString.ContainsFrom( "Hello World", 3, "Q" ) );
>> -1
>> 6
>> -1
static proto string EnString::Trim ( string  str )
staticprivate

Returns trimmed string with removed leading and trailing whitespaces.

Parameters
str string Origin string
Returns
string - Trimmed string
Print(" Hello World ");
Print( EnString.Trim(" Hello World ") );
>> ' Hello World '
>> 'Hello World'
static proto int EnString::TrimInPlace ( string  str )
staticprivate

Removes leading and trailing whitespaces in string. Returns length.

Parameters
str string Origin string
Returns
int - Count of chars
string str = " Hello World ";
int i = EnString.TrimInPlace(str);
Print(str);
Print(i);
>> str = 'Hello World'
>> i = 11
static proto int EnString::ParseStringEx ( inout string  input,
string  token 
)
staticprivate

Parses one token from input string. Result is put into token string, and type of token is returned. Input string is left-truncated by the resulting token length.

Parameters
[in,out] input string String for parse\ Output is without founded token
[out] token string Founded string token
Returns
int Type of token
Token types:
 0 - error, no token
 1 - defined token (special characters etc. . / * )
 2 - quoted string. Quotes are removed -> TODO
 3 - alphabetic string
 4 - number
 5 - end of line -> TODO
string input = "Hello*World";
string token1;
string token2;
int result1 = ParseStringEx(input, token1);
int result2 = ParseStringEx(input, token2);
Print( EnString.ParseStringEx( "Token1 = '" + token1 + "' Type = " + itoa(result1) ) );
Print( EnString.ParseStringEx( "Token2 = '" + token2 + "' Type = " + itoa(result2) ) );
Print( input );
>> 'Toke1 = 'Hello' Type = 3'
>> 'Toke1 = '*' Type = 1'
static proto int EnString::ParseString ( string  input,
out string  tokens[] 
)
staticprivate

Parses string into array of tokens returns number of tokens.

Parameters
input string String for parse
[out] tokens array[] Parsed string in array
Returns
int Number of tokens
string token[2];
int result = EnString.ParseString("Hello World", token);
for( int i = 0; i < 2; i++ )
{
Print(token[i]);
}
>> 'Hello'
>> 'World'
static void EnString::Split ( string  param,
string  sample,
out TStringArray  output 
)
staticprivate

Splits string 'param' into array of strings separated by 'sample'.

Parameters
param string String to split
sample string Strings separator
Returns
TStringArray Array with strings
autoptr TStringArray strs = new TStringArray;
EnString.Split( "The quick brown fox jumps over the lazy dog", " ", strs );
for ( int i = 0; i < strs.Count(); i++ )
{
Print( strs.Get(i) );
}
>> 'The'
>> 'quick'
>> 'brown'
>> 'fox'
>> 'jumps'
>> 'over'
>> 'the'
>> 'lazy'
>> 'dog'

References strlen(), strstroff(), and substr().

Referenced by ModuleConfigViewer::GetConfig(), FoodManager::GetNextFoodStageName(), and ModuleLifespan::UpdateLifespanLevelParam().

Member Data Documentation

string EnString::Empty
staticprivate

The documentation for this class was generated from the following file:
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)