Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_StringHelper Class Reference

Protected Member Functions

array< intIndicesOf (string input, string search)

Static Protected Member Functions

static bool ContainsDigit (string input)
static bool ContainsUppercase (string input)
static bool ContainsLowercase (string input)
static int CountOccurrences (string haystack, string needle, bool caseInsensitive=false)
static string Filter (string input, string characters, bool useCharactersAsBlacklist=false)
static bool IsFormat (SCR_EStringFormat format, string input)
static bool CheckCharacters (string input, bool allowLC, bool allowUC, bool allowDigits, bool allowUnderscore=false)
static string Ellipsis (string input, int maxLength)
static string Format (string input, notnull array< string > arguments)
static string FormatValueNameToUserFriendly (string valueName)
static string FormatResourceNameToUserFriendly (ResourceName resourceName)
static string FormatSnakeCaseToUserFriendly (string snakeCase)
static array< floatGetFloatsFromString (string input, string splitter=SPACE)
static array< intGetIntsFromString (string input, string splitter=SPACE)
static array< stringGetLines (string input, bool removeEmptyLines=false, bool trimLines=false)
static int IndexOf (string input, notnull array< string > samples)
static int IndexOfFrom (string input, int start, notnull array< string > samples)
static string InsertAt (string input, string insertion, int insertionIndex=0)
static bool IsEmptyOrWhiteSpace (string input)
static bool IsTranslationKey (string input)
static string Join (string separator, notnull array< string > pieces, bool joinEmptyEntries=true)
static string Join (string separator, notnull array< bool > pieces, bool numerical=false)
static string Join (string separator, notnull array< int > pieces)
static string Join (string separator, notnull array< float > pieces)
static int GetLevenshteinDistance (string word1, string word2, bool caseSensitive=true)
static float GetLevenshteinDistanceScore (string word1, string word2, bool caseSensitive=true)
static int GetDamerauLevenshteinDistance (string word1, string word2, bool caseSensitive=true)
static float GetDamerauLevenshteinDistanceScore (string word1, string word2, bool caseSensitive=true)
static string PadLeft (string input, int length, string padding=SPACE)
static string PadRight (string input, int length, string padding=SPACE)
static string ReplaceRecursive (string input, string sample, string replacement)
static string ReplaceMultiple (string input, notnull array< string > samples, string replacement)
static string ReplaceTimes (string input, string sample, string replacement, int howMany=1, int skip=0)
static string Reverse (string input)
static bool SimpleStarSearchMatches (string haystack, string needle, bool caseSensitive, bool strictMatch)
static string UCFirst (string input, bool lcRest=false)
static string UCFirstAll (string input, bool lcRest=false)
static bool ContainsAny (string input, notnull array< string > needles)
static bool ContainsEvery (string input, notnull array< string > needles)
static bool ContainsOnly (string input, string characters, bool useCharactersAsBlacklist=false)
static bool StartsWithAny (string input, notnull array< string > lineStarts)
static bool EndsWithAny (string input, notnull array< string > lineEnds)
static string TrimLeft (string input)
static string TrimRight (string input)

Static Protected Attributes

static const string TRANSLATION_KEY_CHARS = UNDERSCORE + DASH
static const int MIN_LC = 97
static const int MAX_LC = 122
static const int MIN_UC = 65
static const int MAX_UC = 90
static const int MIN_DIGIT = 48
static const int MAX_DIGIT = 57

Detailed Description

Definition at line 1 of file SCR_StringHelper.c.

Member Function Documentation

◆ CheckCharacters()

bool SCR_StringHelper::CheckCharacters ( string input,
bool allowLC,
bool allowUC,
bool allowDigits,
bool allowUnderscore = false )
inlinestaticprotected

Check if the provided string respects all the limitations

Parameters
[in]allowLCallow LowerCase characters (abc..xyz)
[in]allowUCallow UpperCase characters (ABC..XYZ)
[in]allowDigitsallow all numbers (012..789)
[in]allowUnderscoreallow underscore (_)
Returns
whether or not input respects allowed characters filters

Definition at line 178 of file SCR_StringHelper.c.

◆ ContainsAny()

bool SCR_StringHelper::ContainsAny ( string input,
notnull array< string > needles )
inlinestaticprotected

Check if input contains any needles

Parameters
[in]input
[in]needles
Returns

Definition at line 1240 of file SCR_StringHelper.c.

◆ ContainsDigit()

bool SCR_StringHelper::ContainsDigit ( string input)
inlinestaticprotected

Check if the provided input contains any digit

Parameters
[in]input
Returns
true if input contains any digit, false otherwise

Definition at line 48 of file SCR_StringHelper.c.

◆ ContainsEvery()

bool SCR_StringHelper::ContainsEvery ( string input,
notnull array< string > needles )
inlinestaticprotected

Check if input contains every needles

Parameters
[in]input
[in]needles
Returns

Definition at line 1259 of file SCR_StringHelper.c.

◆ ContainsLowercase()

bool SCR_StringHelper::ContainsLowercase ( string input)
inlinestaticprotected

Check if the provided input contains any lowercase character (a-z)

Parameters
[in]input
Returns
true if input contains any lowercase character, false otherwise

Definition at line 80 of file SCR_StringHelper.c.

◆ ContainsOnly()

bool SCR_StringHelper::ContainsOnly ( string input,
string characters,
bool useCharactersAsBlacklist = false )
inlinestaticprotected
Parameters
[in]inputthe input string
[in]charactersthe characters that must compose input or that must not be present depending on useCharactersAsBlacklist
[in]useCharactersAsBlacklistfalse for characters to be a whitelist, true for a blacklist
Returns
true if no forbidden characters were found or if characters is empty, false otherwise or if input is empty

Definition at line 1278 of file SCR_StringHelper.c.

◆ ContainsUppercase()

bool SCR_StringHelper::ContainsUppercase ( string input)
inlinestaticprotected

Check if the provided input contains any uppercase character (A-Z)

Parameters
[in]input
Returns
true if input contains any uppercase character, false otherwise

Definition at line 64 of file SCR_StringHelper.c.

◆ CountOccurrences()

int SCR_StringHelper::CountOccurrences ( string haystack,
string needle,
bool caseInsensitive = false )
inlinestaticprotected

Gets the amount of times a needle is found in the haystack. e.g looking for "AA" in "AAAAA" will find it twice.

Parameters
[in]haystackthe string in which to search
[in]needlethe string to find
[in]caseInsensitiveif set to true, the search will be case-insensitive (e.g "A" will match "a" and vice-versa)
Returns
the amount of needle occurrences in haystack, 0 if haystack or needle is empty

Definition at line 99 of file SCR_StringHelper.c.

◆ Ellipsis()

string SCR_StringHelper::Ellipsis ( string input,
int maxLength )
inlinestaticprotected

To be used for debug texts only, NOT in-game texts as this does not support UTF-8!

Parameters
[in]input
[in]maxLength
Returns

Definition at line 229 of file SCR_StringHelper.c.

◆ EndsWithAny()

bool SCR_StringHelper::EndsWithAny ( string input,
notnull array< string > lineEnds )
inlinestaticprotected

Find out if a string's ending matches one of the provided endings

Parameters
[in]inputthe string to check
[in]lineEndsthe endings to parse
Returns
whether or not the input ends with one of the provided line endings

Definition at line 1340 of file SCR_StringHelper.c.

◆ Filter()

string SCR_StringHelper::Filter ( string input,
string characters,
bool useCharactersAsBlacklist = false )
inlinestaticprotected
Parameters
[in]inputthe input string
[in]charactersthe characters to either respect or remove depending on useCharactersAsBlacklist
[in]useCharactersAsBlacklistfalse for characters to be a whitelist, true for a blacklist
Returns
the resulting string

Definition at line 136 of file SCR_StringHelper.c.

◆ Format()

string SCR_StringHelper::Format ( string input,
notnull array< string > arguments )
inlinestaticprotected

format with string arguments in the form of an array

Parameters
[in]formatwith %1, %2 etc
[in]argumentsarray
Returns
string.Format'ted string (with max 9 arguments)

Definition at line 246 of file SCR_StringHelper.c.

◆ FormatResourceNameToUserFriendly()

string SCR_StringHelper::FormatResourceNameToUserFriendly ( ResourceName resourceName)
inlinestaticprotected

Turns "{GUID012345678910}Prefabs/Characters/Factions/Faction/Character_FactionName_NLAW.et" into "Character FactionName NLAW"

Parameters
[in]resourceName
Returns
space-separated words without resourceName extension

Definition at line 395 of file SCR_StringHelper.c.

◆ FormatSnakeCaseToUserFriendly()

string SCR_StringHelper::FormatSnakeCaseToUserFriendly ( string snakeCase)
inlinestaticprotected

Turns "THIS_IS_AN_ENUM" or "tHIs_is_aN_enUM" into "This Is An Enum"

Parameters
[in]snakeCaseany string with words separated by underscores
Returns
firstchar-uppercased space-separated words

Definition at line 406 of file SCR_StringHelper.c.

◆ FormatValueNameToUserFriendly()

string SCR_StringHelper::FormatValueNameToUserFriendly ( string valueName)
inlinestaticprotected

Turns e.g m_bIsValid to "Is Valid", m_bUsesAMagazine to "Uses A Magazine", m_bExportToPDFDocument to "Export To PDF Document"

Parameters
[in]valueName
Returns
space-separated words without resourceName extension

Definition at line 275 of file SCR_StringHelper.c.

◆ GetDamerauLevenshteinDistance()

int SCR_StringHelper::GetDamerauLevenshteinDistance ( string word1,
string word2,
bool caseSensitive = true )
inlinestaticprotected

Calculate the Damerau-Levenshtein Optimal string Alignment (OSA) distance between two words (https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance)

Note
not to be confused with Levenshtein distance (see LevenshteinDistance)
Parameters
[in]word1
[in]word2
[in]caseSensitive
Returns

Definition at line 836 of file SCR_StringHelper.c.

◆ GetDamerauLevenshteinDistanceScore()

float SCR_StringHelper::GetDamerauLevenshteinDistanceScore ( string word1,
string word2,
bool caseSensitive = true )
inlinestaticprotected
See also
DamerauLevenshteinDistance
Returns
a 0..1 matching score - 0 being the farthest, 1 being identical

Definition at line 905 of file SCR_StringHelper.c.

◆ GetFloatsFromString()

array< float > SCR_StringHelper::GetFloatsFromString ( string input,
string splitter = SPACE )
inlinestaticprotected

Gets float values array from a string (e.g { 0.3, 5.0, 7.9 } from "0.3 5.0 abc 7.9")

Parameters
[in]input
[in]splitterspace by default, can be a comma from e.g IEntitySource values
Returns

Definition at line 423 of file SCR_StringHelper.c.

◆ GetIntsFromString()

array< int > SCR_StringHelper::GetIntsFromString ( string input,
string splitter = SPACE )
inlinestaticprotected

Gets int values array from a string (e.g { 3, 5, 7 } from "3 5 abc 7")

Parameters
[in]input
[in]splitterspace by default, can be a comma from e.g IEntitySource values
Returns

Definition at line 444 of file SCR_StringHelper.c.

◆ GetLevenshteinDistance()

int SCR_StringHelper::GetLevenshteinDistance ( string word1,
string word2,
bool caseSensitive = true )
inlinestaticprotected

Calculate the Levenshtein distance between two words (https://en.wikipedia.org/wiki/Levenshtein_distance)

Note
not to be confused with Damerau-Levenshtein/OSA distance (see DamerauLevenshteinDistance)
Parameters
[in]word1
[in]word2
[in]caseSensitive
Returns
number of operations to go from one word to the other (always in 0..inf range)

Definition at line 733 of file SCR_StringHelper.c.

◆ GetLevenshteinDistanceScore()

float SCR_StringHelper::GetLevenshteinDistanceScore ( string word1,
string word2,
bool caseSensitive = true )
inlinestaticprotected
See also
LevenshteinDistance
Returns
a 0..1 matching score - 0 being the farthest, 1 being the identical

Definition at line 814 of file SCR_StringHelper.c.

◆ GetLines()

array< string > SCR_StringHelper::GetLines ( string input,
bool removeEmptyLines = false,
bool trimLines = false )
inlinestaticprotected

Obtain an array of lines from a multiline string - split is done on the \n character

Parameters
[in]input
[in]removeEmptyLinesif true, remove empty lines (including trimmed ones)
[in]trimLinesif true, trim lines
Returns
array of lines, with or without empty/whitespace lines - can remove an empty array if removeEmptyLines is enabled

Definition at line 466 of file SCR_StringHelper.c.

◆ IndexOf()

int SCR_StringHelper::IndexOf ( string input,
notnull array< string > samples )
inlinestaticprotected

Finds the first occurrence of the provided samples

See also
string.IndexOf
Parameters
[in]input
[in]samples
Returns

Definition at line 501 of file SCR_StringHelper.c.

◆ IndexOfFrom()

int SCR_StringHelper::IndexOfFrom ( string input,
int start,
notnull array< string > samples )
inlinestaticprotected

Finds the first occurrence of the provided samples from a position

See also
string.IndexOfFrom
Parameters
[in]input
[in]start
[in]samples
Returns

Definition at line 527 of file SCR_StringHelper.c.

◆ IndicesOf()

array< int > SCR_StringHelper::IndicesOf ( string input,
string search )
inlineprotected
Parameters
[in]input
[in]search
Returns
an array of indices - never returns null

Definition at line 551 of file SCR_StringHelper.c.

◆ InsertAt()

string SCR_StringHelper::InsertAt ( string input,
string insertion,
int insertionIndex = 0 )
inlinestaticprotected

Insert a string into another string

Parameters
[in]inputthe text in which to insert
[in]insertionthe text to insert
[in]insertionIndexdefault 0
Returns
input with insertion inserted at insertionIndex

Definition at line 580 of file SCR_StringHelper.c.

◆ IsEmptyOrWhiteSpace()

bool SCR_StringHelper::IsEmptyOrWhiteSpace ( string input)
inlinestaticprotected
Parameters
[in]input
Returns
true if input is empty or only made of spaces or tabs

Definition at line 594 of file SCR_StringHelper.c.

◆ IsFormat()

bool SCR_StringHelper::IsFormat ( SCR_EStringFormat format,
string input )
inlinestaticprotected
Parameters
[in]format
[in]inputmust be ASCII

Definition at line 155 of file SCR_StringHelper.c.

◆ IsTranslationKey()

bool SCR_StringHelper::IsTranslationKey ( string input)
inlinestaticprotected

Returns if the provided string is in the translation key format (e.g #AR-Translation_Value_3) - the pound sign (#) must be present!

Parameters
[in]input
Returns
true if input is in the translation key format

Definition at line 603 of file SCR_StringHelper.c.

◆ Join() [1/4]

string SCR_StringHelper::Join ( string separator,
notnull array< bool > pieces,
bool numerical = false )
inlinestaticprotected

Joins bools together as string

Parameters
[in]separatorusually "," for an int array
[in]piecesthe pieces to be joined
[in]numericalwhether or not true is stringified as 1 and false as 0, or written full text ("true" and "false")
Returns
the pieces joined with separator, or empty string if pieces is empty

Definition at line 665 of file SCR_StringHelper.c.

◆ Join() [2/4]

string SCR_StringHelper::Join ( string separator,
notnull array< float > pieces )
inlinestaticprotected

Joins floats together as string

Parameters
[in]separatorusually "," for a float array
[in]piecesthe pieces to be joined
Returns
the pieces joined with separator, or empty string if pieces is empty

Definition at line 709 of file SCR_StringHelper.c.

◆ Join() [3/4]

string SCR_StringHelper::Join ( string separator,
notnull array< int > pieces )
inlinestaticprotected

Joins ints together as string

Parameters
[in]separatorusually "," for an int array
[in]piecesthe pieces to be joined
Returns
the pieces joined with separator, or empty string if pieces is empty

Definition at line 687 of file SCR_StringHelper.c.

◆ Join() [4/4]

string SCR_StringHelper::Join ( string separator,
notnull array< string > pieces,
bool joinEmptyEntries = true )
inlinestaticprotected

Joins strings together (reverse operation of string.Split)

Parameters
[in]separatorusually ", " for a string array
[in]piecesthe pieces to be joined
[in]joinEmptyEntriesif set to false, will ignore empty pieces (to e.g avoid ", , " occurrences)
Returns
the string pieces joined with separator, or empty string if pieces is empty

Definition at line 641 of file SCR_StringHelper.c.

◆ PadLeft()

string SCR_StringHelper::PadLeft ( string input,
int length,
string padding = SPACE )
inlinestaticprotected

Pads the provided string's left end (start) with the provided padding (cut to the exact length) Will not do anything if input is already longer than length or if padding is empty If input is longer, it will not be cut

Parameters
[in]input
[in]length
[in]padding
Returns
the padded string

Definition at line 928 of file SCR_StringHelper.c.

◆ PadRight()

string SCR_StringHelper::PadRight ( string input,
int length,
string padding = SPACE )
inlinestaticprotected

Pads the provided string's right end (end) with the provided padding (cut to the exact length) Will not do anything if input is already longer than length or if padding is empty If input is longer, it will not be cut

Parameters
[in]input
[in]length
[in]padding
Returns
the padded string

Definition at line 956 of file SCR_StringHelper.c.

◆ ReplaceMultiple()

string SCR_StringHelper::ReplaceMultiple ( string input,
notnull array< string > samples,
string replacement )
inlinestaticprotected

Replaces multiple entries by the same replacement

Parameters
[in]input
[in]samples
[in]replacement
Returns

Definition at line 1007 of file SCR_StringHelper.c.

◆ ReplaceRecursive()

string SCR_StringHelper::ReplaceRecursive ( string input,
string sample,
string replacement )
inlinestaticprotected

Replace until there is no trace of search

string input = "AAAAAABAAA";
input.Replace("AA", "A"); // input is now "AAABAA"
SCR_StringHelper.ReplaceRecursive("AAAAAABAAA", "AA", "A"); // returns "ABA"
SCR_StringHelper.ReplaceRecursive("AAAAAABAAA", "AA", "AAX"); // returns "AAAAAABAAA"
static string ReplaceRecursive(string input, string sample, string replacement)
Parameters
[in]inputthe input in which to search and replace
[in]whatto replace - an empty sample will do nothing
[in]replacementCANNOT contain sample for an obvious reason
Returns
the modified input, or the original one on wrong arguments

Definition at line 988 of file SCR_StringHelper.c.

◆ ReplaceTimes()

string SCR_StringHelper::ReplaceTimes ( string input,
string sample,
string replacement,
int howMany = 1,
int skip = 0 )
inlinestaticprotected

Replace X times a string from within a string from left to right the next occurrence is searched after the previous replacement, there is no overlap

SCR_StringHelper.ReplaceTimes("Hello Hallo Yellow", "llo", "ya"); // returns "Heya Hallo Yellow"
SCR_StringHelper.ReplaceTimes("Hello Hallo Yellow", "llo", "ya", 2); // returns "Heya Haya Yellow"
SCR_StringHelper.ReplaceTimes("Hello Hallo Yellow", "llo", "ya", 4); // returns "Heya Haya Yeyaw"
SCR_StringHelper.ReplaceTimes("A A A", "A", "BA", 2); // returns "BA BA A"
SCR_StringHelper.ReplaceTimes("A A A", "A", "B", 1, 1); // returns "A B A"
static string ReplaceTimes(string input, string sample, string replacement, int howMany=1, int skip=0)
Parameters
[in]inputthe input in which to search and replace
[in]samplewhat to replace - an empty sample will do nothing
[in]replacementthe replacement string
[in]howManytimes the string must be replaced
[in]skipfirst occurrences -not- to be replaced
Returns
input with 'sample' replaced by 'replacement' 'howMany' times after skipping 'skip' occurrences

Definition at line 1042 of file SCR_StringHelper.c.

◆ Reverse()

string SCR_StringHelper::Reverse ( string input)
inlinestaticprotected

Returns the provided input string reversed

SCR_StringHelper.Reverse("ABC123"); // returns "321CBA"
static string Reverse(string input)
Parameters
[in]input
Returns
reversed input

Definition at line 1085 of file SCR_StringHelper.c.

◆ SimpleStarSearchMatches()

bool SCR_StringHelper::SimpleStarSearchMatches ( string haystack,
string needle,
bool caseSensitive,
bool strictMatch )
inlinestaticprotected

Search a string with star-keywords - only supports begin* / end / *contains search format

Parameters
[in]haystack
[in]needlethe star-based search:
  • word = exact search
  • word* = starting with
  • word = starting with
  • *word = containing
[in]caseSensitivewhether or not the search is case-sensitive
[in]strictMatchstar is a REQUIREMENT and not a POSSIBILITY:
  • true: word = NEEDS a before/after (e.g matches with XwordX, does not match with Xword, wordX and word)
  • false: word = CAN have a before/after (e.g matches with XwordX, Xword, wordX and word)
Returns
true if matches

Definition at line 1109 of file SCR_StringHelper.c.

◆ StartsWithAny()

bool SCR_StringHelper::StartsWithAny ( string input,
notnull array< string > lineStarts )
inlinestaticprotected

Find out if a string's beginning matches one of the provided beginnings

Parameters
[in]inputthe string to check
[in]lineStartsthe beginnings to parse
Returns
whether or not the input begins with one of the provided line beginnings

Definition at line 1321 of file SCR_StringHelper.c.

◆ TrimLeft()

string SCR_StringHelper::TrimLeft ( string input)
inlinestaticprotected

Remove spaces, tabs and line returns on the left end of the provided string Vertical tabs and other characters are ignored and considered as normal characters (for now?)

Parameters
[in]input
Returns
the trimmed input

Definition at line 1360 of file SCR_StringHelper.c.

◆ TrimRight()

string SCR_StringHelper::TrimRight ( string input)
inlinestaticprotected

Remove spaces, tabs and line returns on the right end of the provided string Vertical tabs and other characters are ignored and considered as normal characters (for now?)

Parameters
[in]input
Returns
the trimmed input

Definition at line 1382 of file SCR_StringHelper.c.

◆ UCFirst()

string SCR_StringHelper::UCFirst ( string input,
bool lcRest = false )
inlinestaticprotected

Sets the first found a-zA-Z0-9 character to uppercase, e.g:

  • "hello" becomes "Hello"
  • " hello " becomes " Hello "
  • "Hello" remains "Hello"
  • "1hello" remains "1hello"
    Parameters
    [in]input
    [in]lcRest
    Returns

Definition at line 1170 of file SCR_StringHelper.c.

◆ UCFirstAll()

string SCR_StringHelper::UCFirstAll ( string input,
bool lcRest = false )
inlinestaticprotected
Parameters
[in]input
[in]lcRest
Returns

Definition at line 1205 of file SCR_StringHelper.c.

Member Data Documentation

◆ MAX_DIGIT

const int SCR_StringHelper::MAX_DIGIT = 57
staticprotected

Definition at line 42 of file SCR_StringHelper.c.

◆ MAX_LC

const int SCR_StringHelper::MAX_LC = 122
staticprotected

Definition at line 36 of file SCR_StringHelper.c.

◆ MAX_UC

const int SCR_StringHelper::MAX_UC = 90
staticprotected

Definition at line 39 of file SCR_StringHelper.c.

◆ MIN_DIGIT

const int SCR_StringHelper::MIN_DIGIT = 48
staticprotected

Definition at line 41 of file SCR_StringHelper.c.

◆ MIN_LC

const int SCR_StringHelper::MIN_LC = 97
staticprotected

Definition at line 35 of file SCR_StringHelper.c.

◆ MIN_UC

const int SCR_StringHelper::MIN_UC = 65
staticprotected

Definition at line 38 of file SCR_StringHelper.c.

◆ TRANSLATION_KEY_CHARS

const string SCR_StringHelper::TRANSLATION_KEY_CHARS = UNDERSCORE + DASH
staticprotected

Definition at line 33 of file SCR_StringHelper.c.


The documentation for this class was generated from the following file: