class StringUtility

Utility class for manipulating Strings.

Public

Methods

staticTrim

static String Trim(const String &str, bool left = true, bool right = true)

Removes any whitespace characters from beginning or end of the string.

staticTrim

static WString Trim(const WString &str, bool left = true, bool right = true)

Removes any whitespace characters from beginning or end of the string.

staticTrim

static StringView Trim(StringView str, bool left = true, bool right = true)

Removes any whitespace characters from beginning or end of the string view.

staticTrim

static String Trim(const String &str, const String &delims, bool left = true, bool right = true)

Removes specified characters from beginning or end of the string.

staticTrim

static WString Trim(const WString &str, const WString &delims, bool left = true, bool right = true)

Removes any whitespace characters from beginning or end of the string.

staticTrim

static StringView Trim(StringView str, StringView delims, bool left = true, bool right = true)

Removes specified characters from beginning or end of the string view.

staticSplit

static Vector<String> Split(const String &str, const String &delims = "\t\n ", unsigned int maxSplits = 0)

Returns a vector of strings containing all the substrings delimited by the provided delimiter characters.

str
The string to split.
delims
(optional) Delimiter characters to split the string by. They will not be included in resulting substrings.
maxSplits
(optional) The maximum number of splits to perform (0 for unlimited splits). If this parameters is > 0, the splitting process will stop after this many splits, left to right.

staticSplit

static Vector<WString> Split(const WString &str, const WString &delims = L"\t\n ", unsigned int maxSplits = 0)

Returns a vector of strings containing all the substrings delimited by the provided delimiter characters.

str
The string to split.
delims
(optional) Delimiter characters to split the string by. They will not be included in resulting substrings.
maxSplits
(optional) The maximum number of splits to perform (0 for unlimited splits). If this parameters is > 0, the splitting process will stop after this many splits, left to right.

staticTokenise

static Vector<String> Tokenise(const String &str, const String &delims = "\t\n ", const String &doubleDelims = "\"", unsigned int maxSplits = 0)

Returns a vector of strings containing all the substrings delimited by the provided delimiter characters, or the double delimiters used for including normal delimiter characters in the tokenized string.

str
The string to split.
delims
(optional) Delimiter characters to split the string by. They will not be included in resulting substrings.
doubleDelims
(optional) Delimiter character you may use to surround other normal delimiters, in order to include them in the tokensized string.
maxSplits
(optional) The maximum number of splits to perform (0 for unlimited splits). If this parameters is > 0, the splitting process will stop after this many splits, left to right.

staticTokenise

static Vector<WString> Tokenise(const WString &str, const WString &delims = L"\t\n ", const WString &doubleDelims = L"\"", unsigned int maxSplits = 0)

Returns a vector of strings containing all the substrings delimited by the provided delimiter characters, or the double delimiters used for including normal delimiter characters in the tokenized string.

str
The string to split.
delims
(optional) Delimiter characters to split the string by. They will not be included in resulting substrings.
doubleDelims
(optional) Delimiter character you may use to surround other normal delimiters, in order to include them in the tokensized string.
maxSplits
(optional) The maximum number of splits to perform (0 for unlimited splits). If this parameters is > 0, the splitting process will stop after this many splits, left to right.

staticHexToLiteral

static String HexToLiteral(const u32 *input, u32 count)

Converts one or multiple 32-bit numbers into a literal hexidecimal representation.

Each entry is separated with a desh.

staticHexToLiteral

static String HexToLiteral(const u64 *input, u32 count)

Converts one or multiple 64-bit numbers into a literal hexidecimal representation.

Each entry is separated with a desh.

staticToLowerCase

static void ToLowerCase(String &str)

Converts all the characters in the string to lower case.

Does not handle UTF8 encoded strings.

staticToLowerCase

static void ToLowerCase(WString &str)

Converts all the characters in the string to lower case.

Does not handle UTF8 encoded strings.

staticToUpperCase

static void ToUpperCase(String &str)

Converts all the characters in the string to upper case.

Does not handle UTF8 encoded strings.

staticToUpperCase

static void ToUpperCase(WString &str)

Converts all the characters in the string to upper case.

Does not handle UTF8 encoded strings.

staticStartsWith

static bool StartsWith(const String &str, const String &pattern, bool lowerCase = true)

Returns whether the string begins with the pattern passed in.

str
String to compare.
pattern
Pattern to compare with.
lowerCase
(optional) If true, the start of the string will be lower cased before comparison, and the pattern should also be in lower case.

staticStartsWith

static bool StartsWith(const WString &str, const WString &pattern, bool lowerCase = true)

staticEndsWith

static bool EndsWith(const String &str, const String &pattern, bool lowerCase = true)

Returns whether the string end with the pattern passed in.

str
String to compare.
pattern
Pattern to compare with.
lowerCase
(optional) If true, the start of the string will be lower cased before comparison, and the pattern should also be in lower case.

staticEndsWith

static bool EndsWith(const WString &str, const WString &pattern, bool lowerCase = true)

staticMatch

static bool Match(const String &str, const String &pattern, bool caseSensitive = true)

Returns true if the string matches the provided pattern.

Pattern may use a "*" wildcard for matching any characters.

str
The string to test.
pattern
Patterns to look for.
caseSensitive
(optional) Should the match be case sensitive or not.

staticMatch

static bool Match(const WString &str, const WString &pattern, bool caseSensitive = true)

staticReplaceAll

static const String ReplaceAll(const String &source, const String &replaceWhat, const String &replaceWithWhat)

Replace all instances of a substring with a another substring.

source
String to search.
replaceWhat
Substring to find and replace
replaceWithWhat
Substring to replace with (the new sub-string)

Returns: An updated string with the substrings replaced.

staticReplaceAll

static const WString ReplaceAll(const WString &source, const WString &replaceWhat, const WString &replaceWithWhat)

staticStripExtension

static String StripExtension(const String &input)

Removes the file extension from the provided string.

If string has multiple extensions, only the last extension will be removed.