DayZ 1.24
Loading...
Searching...
No Matches
EnString.c
Go to the documentation of this file.
1
5class string
6{
7 static const string Empty;
8
20 proto native int ToInt();
21
33 proto native int HexToInt();
34
46 proto native float ToFloat();
47
60
61
68 {
69 string copy = value;
70 copy.Replace("<", "");
71 copy.Replace(">", "");
72 copy.Replace(",", " ");
73 return copy.ToVector();
74 }
86 proto native int ToAscii();
87
95 proto native typename ToType();
96
98 static proto string ToString(void var, bool type = false, bool name = false, bool quotes = true);
99
113 proto string Substring(int start, int len);
114
116 string SubstringInverted(string string_to_split, int position_start, int position_end)
117 {
118 string first_half = string_to_split.Substring(0, position_start);
119 string second_half = string_to_split.Substring(position_end, string_to_split.Length() - position_end);
120 string result = first_half + second_half;
121 return result;
122 }
123
137 proto string SubstringUtf8(int startChar, int len);
138
156 proto int Replace(string sample, string replace);
157
171 proto int ToLower();
172
186 proto int ToUpper();
187
199 proto native int Length();
200
212 proto native int LengthUtf8();
213
223 proto native int Hash();
224
240 proto native int IndexOf(string sample);
241
253 proto native int LastIndexOf(string sample);
254
271 proto native int IndexOfFrom(int start, string sample);
272
286 bool Contains(string sample)
287 {
288 return value.IndexOf(sample) != -1;
289 }
290
304 proto string Trim();
305
319 proto int TrimInPlace();
320
349 proto int ParseStringEx(out string token);
350
369 proto int ParseString(out string tokens[]);
370
396 void Split(string sample, out array<string> output)
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
414 txt_len = nxt_sep_pos - sep_pos;
415 if (txt_len > 0)
416 {
417 text = value.Substring(sep_pos, txt_len);
418 output.Insert(text);
419 }
420 }
421 }
422
423 // !Joins array of strings into a single string, separated by 'separator'. Inverse of Split
424 static string Join(string separator, notnull TStringArray tokens)
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 }
435
448 proto string Get(int index);
449
473 proto void Set(int index, string input);
474
475#ifdef DIAG_DEVELOPER
487 void OldSet(int n, string _value)
488 {
489 string pre = value.Substring(0, n);
490 n += 1;
491 int length = value.Length() - n;
492 string post = value.Substring(n, length);
493 value = pre + _value + post;
494 }
495#endif
496
511 proto void Insert(int index, string input);
512
526 static proto 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);
527};
528
529//@}
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native int Length()
Returns length of string.
proto int Replace(string sample, string replace)
Replace all occurrances of 'sample' in 'str' by 'replace'.
proto vector ToVector()
Returns a vector from a string.
proto native int LengthUtf8()
Returns number of characters in UTF8 string.
proto string Trim()
Returns trimmed string with removed leading and trailing whitespaces.
proto string Get(int index)
Gets n-th character from string.
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.
vector BeautifiedToVector()
Convert beautified string into a vector.
Definition EnString.c:67
proto int ParseString(out string tokens[])
Parses string into array of tokens returns number of tokens.
proto int ToUpper()
Changes string to uppercase. Returns length.
proto native int ToInt()
Converts string to integer.
proto void Insert(int index, string input)
Inserts a string into the n-th index, increasing the string length by the size of the input.
proto native int ToAscii()
Converts string's first character to ASCII code.
proto native int HexToInt()
Converts string to integer.
proto native int LastIndexOf(string sample)
Finds last 'sample' in 'str'. Returns -1 when not found.
bool Contains(string sample)
Returns true if sample is substring of string.
Definition EnString.c:286
proto native float ToFloat()
Converts string to float.
proto native int Hash()
Returns hash of string.
void Split(string sample, out array< string > output)
Splits string into array of strings separated by 'sample'.
Definition EnString.c:396
proto native ToType()
Returns internal type representation. Can be used in runtime, or cached in variables and used for fas...
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
static const string Empty
Definition EnString.c:7
proto int ParseStringEx(out string token)
Parses one token from input string. Result is put into token string, and type of token is returned....
proto native int IndexOfFrom(int start, string sample)
Finds 'sample' in 'str' from 'start' position. Returns -1 when not found.
proto int TrimInPlace()
Removes leading and trailing whitespaces in string. Returns length.
string SubstringInverted(string string_to_split, int position_start, int position_end)
Inverted SubString. This deletes everything in between position_start and position_end.
Definition EnString.c:116
static string Join(string separator, notnull TStringArray tokens)
Definition EnString.c:424
proto native int IndexOf(string sample)
Finds 'sample' in 'str'. Returns -1 when not found.
static proto 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.
proto void Set(int index, string input)
Sets the n-th character in string with the input, replacing previous value.
proto int ToLower()
Changes string to lowercase. Returns length.
proto string SubstringUtf8(int startChar, int len)
Substring of 'str' from 'startChar' position 'len' number of characters for UTF8 strings with multiby...