DayZ 1.24
Loading...
Searching...
No Matches
Strings

Classes

class  string
 

Functions

proto native int string::ToInt ()
 Converts string to integer.
 
proto native int string::HexToInt ()
 Converts string to integer.
 
proto native float string::ToFloat ()
 Converts string to float.
 
proto vector string::ToVector ()
 Returns a vector from a string.
 
vector string::BeautifiedToVector ()
 Convert beautified string into a vector.
 
proto native int string::ToAscii ()
 Converts string's first character to ASCII code.
 
proto native string::ToType ()
 Returns internal type representation. Can be used in runtime, or cached in variables and used for faster inheritance checking.
 
static proto string string::ToString (void var, bool type=false, bool name=false, bool quotes=true)
 Return string representation of variable.
 
proto string string::Substring (int start, int len)
 Substring of 'str' from 'start' position 'len' number of characters.
 
string string::SubstringInverted (string string_to_split, int position_start, int position_end)
 Inverted SubString. This deletes everything in between position_start and position_end.
 
proto string string::SubstringUtf8 (int startChar, int len)
 Substring of 'str' from 'startChar' position 'len' number of characters for UTF8 strings with multibyte chars.
 
proto int string::Replace (string sample, string replace)
 Replace all occurrances of 'sample' in 'str' by 'replace'.
 
proto int string::ToLower ()
 Changes string to lowercase. Returns length.
 
proto int string::ToUpper ()
 Changes string to uppercase. Returns length.
 
proto native int string::Length ()
 Returns length of string.
 
proto native int string::LengthUtf8 ()
 Returns number of characters in UTF8 string.
 
proto native int string::Hash ()
 Returns hash of string.
 
proto native int string::IndexOf (string sample)
 Finds 'sample' in 'str'. Returns -1 when not found.
 
proto native int string::LastIndexOf (string sample)
 Finds last 'sample' in 'str'. Returns -1 when not found.
 
proto native int string::IndexOfFrom (int start, string sample)
 Finds 'sample' in 'str' from 'start' position. Returns -1 when not found.
 
bool string::Contains (string sample)
 Returns true if sample is substring of string.
 
proto string string::Trim ()
 Returns trimmed string with removed leading and trailing whitespaces.
 
proto int string::TrimInPlace ()
 Removes leading and trailing whitespaces in string. Returns length.
 
proto int string::ParseStringEx (out 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.
 
proto int string::ParseString (out string tokens[])
 Parses string into array of tokens returns number of tokens.
 
void string::Split (string sample, out array< string > output)
 Splits string into array of strings separated by 'sample'.
 
static string string::Join (string separator, notnull TStringArray tokens)
 
proto string string::Get (int index)
 Gets n-th character from string.
 
proto void string::Set (int index, string input)
 Sets the n-th character in string with the input, replacing previous value.
 
proto void string::Insert (int index, string input)
 Inserts a string into the n-th index, increasing the string length by the size of the input.
 
static proto string string::Format (string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
 Gets n-th character from string.
 

Variables

static const string string::Empty
 

Detailed Description

Function Documentation

◆ BeautifiedToVector()

vector string::BeautifiedToVector ( )
inlineprivate

Convert beautified string into a vector.

Parameters
vecbeautified string
Returns
vector resulting vector

Definition at line 67 of file EnString.c.

68 {
69 string copy = value;
70 copy.Replace("<", "");
71 copy.Replace(">", "");
72 copy.Replace(",", " ");
73 return copy.ToVector();
74 }

References string::Replace(), and string::ToVector().

Referenced by ScriptConsoleGeneralTab::OnClick().

◆ Contains()

bool string::Contains ( string sample)
inlineprivate

Returns true if sample is substring of string.

Parameters
samplestring Finding string expression
Returns
bool true if sample is substring of string
string str = "Hello World";
Print( str.IndexOfFrom( 3, "Hello" ) );
Print( str.IndexOfFrom( 3, "Mexico" ) );
>> true
>> false
proto void Print(void var)
Prints content of variable to console/log.

Definition at line 286 of file EnString.c.

287 {
288 return value.IndexOf(sample) != -1;
289 }

Referenced by BaseBuildingBase::CheckLevelVerticalDistance(), AttachmentsOutOfReach::CreateAttachmentPosition(), CreateMission(), ItemBase::ToggleAnimation(), and ObjectSpawnerHandler::ValidatePath().

◆ Format()

static proto string string::Format ( string fmt,
void param1 = NULL,
void param2 = NULL,
void param3 = NULL,
void param4 = NULL,
void param5 = NULL,
void param6 = NULL,
void param7 = NULL,
void param8 = NULL,
void param9 = NULL )
staticprivate

◆ Get()

proto string string::Get ( int index)
private

Gets n-th character from string.

Parameters
indexcharacter index
Returns
string character on index-th position in string
Warning
VME When index less than 0 or greater than string length
string str = "Hello World";
Print( str[4] ); // Print( str.Get(4) );
>> 'o'

Referenced by FireworksLauncherClientEvent::FireworksLauncherClientEvent(), ScriptedWidgetEventHandler::Highlight(), and ScriptedWidgetEventHandler::Select().

◆ Hash()

proto native int string::Hash ( )
private

Returns hash of string.

Returns
int - Hash of string
string str = "Hello World";
int hash = str.Hash();

Referenced by Capture(), DayZPlayer::OnStepEvent(), and ArrowManagerPlayer::Save().

◆ HexToInt()

proto native int string::HexToInt ( )
private

Converts string to integer.

Returns
int - Converted string.
string str = "0xFF";
int i = str.HexToInt();
>> i = 255

◆ IndexOf()

proto native int string::IndexOf ( string sample)
private

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

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

Referenced by PluginBase::GetPlayerPrefix().

◆ IndexOfFrom()

proto native int string::IndexOfFrom ( int start,
string sample )
private

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

Parameters
startint Start from position
samplestring Finding string expression
Returns
int - Length of string s
string str = "Hello World";
Print( str.IndexOfFrom( 3, "H" ) );
Print( str.IndexOfFrom( 3, "W" ) );
Print( str.IndexOfFrom( 3, "Q" ) );
>> -1
>> 6
>> -1

Referenced by ActionUnmountBarbedWire::ActionCondition(), and CGame::SetMissionPath().

◆ Insert()

proto void string::Insert ( int index,
string input )
private

Inserts a string into the n-th index, increasing the string length by the size of the input.

Parameters
indexindex to insert at
inputstring value to insert with
Warning
VME When index less than 0 or greater than string length
VME When string is empty
string str = "Hello World";
str.Insert(6, "Test ");
>> 'Hello Test World'

Referenced by HFSMBase< Class FSMStateBase, Class FSMEventBase, Class FSMActionBase, Class FSMGuardBase >::GetHierarchyPath(), ScriptedWidgetEventHandler::LoadEntries(), and string::Split().

◆ Join()

static string string::Join ( string separator,
notnull TStringArray tokens )
inlinestaticprivate

Definition at line 424 of file EnString.c.

425 {
426 string output;
427 foreach (int i, string s: tokens)
428 {
429 if (i != 0)
430 output += separator;
431 output += s;
432 }
433 return output;
434 }

◆ LastIndexOf()

proto native int string::LastIndexOf ( string sample)
private

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

Parameters
samplestring Finding string
Returns
int - Returns position where sample starts, or -1 when sample not found
string str = "Hello World";
Print( str.IndexOf( "l" ) );
>> 9

◆ Length()

◆ LengthUtf8()

proto native int string::LengthUtf8 ( )
private

Returns number of characters in UTF8 string.

Returns
int - Number of characters in UTF8 string
string str = "こんにちは世界";
int i = str.LengthUtf8();
>> i = 7

◆ ParseString()

proto int string::ParseString ( out string tokens[])
private

Parses string into array of tokens returns number of tokens.

Parameters
[out]tokensarray[] Parsed string in array
Returns
int Number of tokens
string token[2];
string str = "Hello World";
int result = str.ParseString(token);
for (int i = 0; i < 2; i++)
{
}
>> 'Hello'
>> 'World'

◆ ParseStringEx()

proto int string::ParseStringEx ( out string token)
private

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
[out]tokenstring 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 = input.ParseStringEx(token1);
int result2 = input.ParseStringEx(token2);
Print( "Token1 = '" + token1 + "' Type = " + result1.ToString() ) );
Print( "Token2 = '" + token2 + "' Type = " + result2.ToString() ) );
>> 'Toke1 = 'Hello' Type = 3'
>> 'Toke1 = '*' Type = 1'

◆ Replace()

proto int string::Replace ( string sample,
string replace )
private

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

Parameters
samplestring to search in str
replacestring 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.";
int count = test.Replace("the", "*");
>> 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 string::BeautifiedToVector(), and ResavePlugin::RunCommandline().

◆ Set()

proto void string::Set ( int index,
string input )
private

Sets the n-th character in string with the input, replacing previous value.

Parameters
indexindex to be replaced
inputsingle non-terminated character value to replace with
Warning
VME When index less than 0 or greater than string length
(Diag) VME When string is empty or greater than length of 1 (Retail) Calls 'string.Insert' except it replaces only the initial character
string str = "Hello World";
str[4] = "O";
>> 'HellO World'
string str = "Hello World";
str[6] = "Test ";
>> 'Hello Test orld'

◆ Split()

void string::Split ( string sample,
out array< string > output )
inlineprivate

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

Parameters
samplestring Strings separator
Returns
TStringArray Array with strings
string example = "The quick brown fox jumps over the lazy dog";
example.Split(" ", strs);
for (int i = 0; i < strs.Count(); i++)
{
Print(strs.Get(i));
}
>> 'The'
>> 'quick'
>> 'brown'
>> 'fox'
>> 'jumps'
>> 'over'
>> 'the'
>> 'lazy'
>> 'dog'
array< string > TStringArray
Definition EnScript.c:666

Definition at line 396 of file EnString.c.

397 {
398 int txt_len = 0;
399 int sep_pos = -1;
400 int nxt_sep_pos = 0;
401 string text = "";
402
403 bool line_end = false;
404 while (line_end == false)
405 {
406 sep_pos = sep_pos + txt_len + 1;
407 nxt_sep_pos = value.IndexOfFrom(sep_pos, sample);
408 if (nxt_sep_pos == -1)
409 {
410 nxt_sep_pos = value.Length();
411 line_end = true;
412 }
413
415 if (txt_len > 0)
416 {
417 text = value.Substring(sep_pos, txt_len);
418 output.Insert(text);
419 }
420 }
421 }

References string::Insert(), and string::Substring().

Referenced by ScriptConsoleConfigTab::OnClick(), and ParseData().

◆ Substring()

proto string string::Substring ( int start,
int len )
private

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

Parameters
startPosition in str
lenCount of characters
Returns
string - Substring of str
string str = "Hello World";
string strSub = str.Substring(2, 5);
>> strSub = llo W

Referenced by ActionUnmountBarbedWire::ActionCondition(), PluginBase::GetPlayerPrefix(), CGame::SetMissionPath(), string::Split(), and string::SubstringInverted().

◆ SubstringInverted()

string string::SubstringInverted ( string string_to_split,
int position_start,
int position_end )
inlineprivate

Inverted SubString. This deletes everything in between position_start and position_end.

Definition at line 116 of file EnString.c.

117 {
118 string first_half = string_to_split.Substring(0, position_start);
120 string result = first_half + second_half;
121 return result;
122 }

References string::Length(), and string::Substring().

◆ SubstringUtf8()

proto string string::SubstringUtf8 ( int startChar,
int len )
private

Substring of 'str' from 'startChar' position 'len' number of characters for UTF8 strings with multibyte chars.

Parameters
startCharPosition in str.
lenCount of characters
Returns
string - Substring of str with startChar character and len characters
string str = "こんにちは世界";
string strSub = str.SubstringUtf8(2, 4);

◆ ToAscii()

proto native int string::ToAscii ( )
private

Converts string's first character to ASCII code.

Parameters
strString for convert to ASCII code
Returns
ascii code int.
int ascii = "M".ToAscii();
>> ascii = 77

◆ ToFloat()

proto native float string::ToFloat ( )
private

Converts string to float.

Returns
float - Converted string in float.
string str = "56.6";
float f = str.ToFloat();
>> f = 56.6

◆ ToInt()

proto native int string::ToInt ( )
private

Converts string to integer.

Returns
int - Converted string.
string str = "56";
int i = str.ToInt();
>> i = 56

◆ ToLower()

proto int string::ToLower ( )
private

Changes string to lowercase. Returns length.

Returns
int - Length of changed string
string str = "Hello World";
int i = str.ToLower();
>> i = 11

Referenced by AttachmentsOutOfReach::CreateAttachmentPosition().

◆ ToString()

static proto string string::ToString ( void var,
bool type = false,
bool name = false,
bool quotes = true )
staticprivate

Return string representation of variable.

Referenced by PrintElements(), and ToStringLen().

◆ ToType()

proto native string::ToType ( )
private

Returns internal type representation. Can be used in runtime, or cached in variables and used for faster inheritance checking.

Returns
typename Type of class
???

Referenced by CreateParticle(), ImpactMaterials::EvaluateImpactEffect(), PluginBase::GetModuleType(), EffectArea::GetRequesterIndex(), and ImpactMaterials::RegisterSurface().

◆ ToUpper()

proto int string::ToUpper ( )
private

Changes string to uppercase. Returns length.

Returns
int - Length of changed string
string str = "Hello World";
int i = str.ToUpper();
>> i = 11
@ WORLD
4_World
Definition EnProfiler.c:30

◆ ToVector()

proto vector string::ToVector ( )
private

Returns a vector from a string.

Returns
vector Converted s as vector
string str = "1 0 1";
vector v = str.ToVector();
>> v = <1,0,1>

Referenced by string::BeautifiedToVector().

◆ Trim()

proto string string::Trim ( )
private

Returns trimmed string with removed leading and trailing whitespaces.

Returns
string - Trimmed string
string str = " Hello World "
Print( str.Trim() );
>> ' Hello World '
>> 'Hello World'

◆ TrimInPlace()

proto int string::TrimInPlace ( )
private

Removes leading and trailing whitespaces in string. Returns length.

Returns
int - Count of chars
string str = " Hello World ";
int i = str.TrimInPlace();
>> str = 'Hello World'
>> i = 11

Variable Documentation

◆ Empty