StringTemplate< INTERFACETYPE, REFTYPE, CHARTYPE > Class Template Reference

#include <string.h>

Detailed Description

template<typename INTERFACETYPE, typename REFTYPE, typename CHARTYPE>
class maxon::StringTemplate< INTERFACETYPE, REFTYPE, CHARTYPE >

Base template for String and CString.

Template Parameters
INTERFACETYPEEither String or CString.
REFTYPEReference of the interface (String or CString).
CHARTYPEData type to store characters, either Utf32Char (String) or Char (CString).

Classes

class  CharPtr
 

Public Types

using Super = StringTemplate
 

Public Member Functions

MAXON_METHOD Int GetLength () const
 
MAXON_METHOD Result< void > Init (Int count=0, CHARTYPE fillChar=0)
 
MAXON_METHOD Result< void > Shrink ()
 
MAXON_METHOD Result< void > Append (const INTERFACETYPE *str)
 
MAXON_METHOD Result< void > Append (const CHARTYPE *str, Int len)
 
MAXON_FUNCTION Result< void > AppendChar (CHARTYPE v)
 
MAXON_METHOD Int FindIndex (const INTERFACETYPE *str, StringPosition start=0) const
 
MAXON_METHOD Int FindLastIndex (const INTERFACETYPE *str, StringPosition start=StringEnd()) const
 
MAXON_METHOD Int FindIndex (CHARTYPE ch, StringPosition start=0) const
 
MAXON_METHOD Int FindLastIndex (CHARTYPE ch, StringPosition start=StringEnd()) const
 
MAXON_METHOD Int FindUpperIndex (const INTERFACETYPE *str, StringPosition start=0) const
 
MAXON_METHOD Int FindLastUpperIndex (const INTERFACETYPE *str, StringPosition start=StringEnd()) const
 
MAXON_METHOD Result< void > Erase (StringPosition position, StringCount count)
 
MAXON_METHOD Result< void > Insert (StringPosition position, const INTERFACETYPE *str, StringPosition strStart=0, StringCount strCount=StringEnd())
 
MAXON_METHOD Result< void > Insert (StringPosition position, CHARTYPE ch)
 
MAXON_METHOD INTERFACETYPE * GetPart (StringPosition start, StringCount count) const
 
MAXON_METHOD INTERFACETYPE * ToUpper () const
 
MAXON_METHOD INTERFACETYPE * ToLower () const
 
MAXON_METHOD COMPARERESULT ComparePart (const INTERFACETYPE *str, STRINGCOMPARISON mode, StringPosition position, StringCount count) const
 
MAXON_FUNCTION COMPARERESULT Compare (const INTERFACETYPE *str, STRINGCOMPARISON mode=STRINGCOMPARISON::UNICODE_NUMBERS) const
 
MAXON_FUNCTION Bool IsEqual (const INTERFACETYPE *str) const
 
MAXON_METHOD UInt GetHashCode () const
 
MAXON_METHOD void SetChar (Int pos, CHARTYPE ch)
 
MAXON_METHOD CHARTYPE GetChar (Int pos) const
 
MAXON_FUNCTION Result< Float64ToFloat64 (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< Float32ToFloat32 (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< FloatToFloat (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< Int64ToInt64 (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< Int32ToInt32 (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< IntToInt (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< UInt64ToUInt64 (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< UInt32ToUInt32 (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION Result< UIntToUInt (STRINGCONVERSION flags=STRINGCONVERSION::NONE) const
 
MAXON_FUNCTION INTERFACETYPE * AppendInt (Int32 v)
 
MAXON_FUNCTION INTERFACETYPE * AppendUInt (UInt32 v)
 
MAXON_FUNCTION INTERFACETYPE * AppendInt (Int64 v)
 
MAXON_FUNCTION INTERFACETYPE * AppendUInt (UInt64 v)
 
MAXON_METHOD Result< void > GetUtf32 (Utf32CharBuffer &stringData) const
 
MAXON_METHOD Result< void > TrimLeft ()
 
MAXON_METHOD Result< void > TrimRight ()
 
MAXON_METHOD Result< void > Split (const REFTYPE &splitSymbol, Bool trim, const ValueReceiver< const REFTYPE &> &parts) const
 
MAXON_METHOD Result< IntReplace (CHARTYPE find, CHARTYPE replace)
 
MAXON_METHOD Result< IntReplace (const REFTYPE &find, const REFTYPE &replace)
 
MAXON_METHOD Result< IntReplace (CHARTYPE find, const REFTYPE &replace)
 
MAXON_FUNCTION Bool Find (const REFTYPE &str, Int *pos, StringPosition start=0) const
 
MAXON_FUNCTION Bool FindLast (const REFTYPE &str, Int *pos, StringPosition start=StringEnd()) const
 
MAXON_FUNCTION Bool Find (CHARTYPE ch, Int *pos, StringPosition start=0) const
 
MAXON_FUNCTION Bool FindLast (CHARTYPE ch, Int *pos, StringPosition start=StringEnd()) const
 
MAXON_FUNCTION Bool FindUpper (const REFTYPE &str, Int *pos, StringPosition start=0) const
 
MAXON_FUNCTION Bool FindLastUpper (const REFTYPE &str, Int *pos, StringPosition start=StringEnd()) const
 
MAXON_FUNCTION INTERFACETYPE * GetLeftPart (StringPosition start) const
 
MAXON_FUNCTION INTERFACETYPE * GetRightPart (StringPosition start) const
 
MAXON_FUNCTION Bool StartsWith (CHARTYPE ch) const
 
MAXON_FUNCTION Bool StartsWith (const REFTYPE &str) const
 
MAXON_FUNCTION Bool EndsWith (CHARTYPE ch) const
 
MAXON_FUNCTION Bool EndsWith (const REFTYPE &str) const
 
MAXON_FUNCTION Result< void > Trim ()
 

Static Public Member Functions

static MAXON_FUNCTION REFTYPE FloatToString (Float32 value, Int charsBeforeComma=STRING_DYNAMIC_DIGITS, Int digitsAfterComma=-3, Bool exponent=false, CHARTYPE fillChar=' ')
 
static MAXON_FUNCTION REFTYPE FloatToString (Float64 value, Int charsBeforeComma=STRING_DYNAMIC_DIGITS, Int digitsAfterComma=-3, Bool exponent=false, CHARTYPE fillChar=' ')
 
static MAXON_FUNCTION REFTYPE IntToString (Int32 v)
 
static MAXON_FUNCTION REFTYPE UIntToString (UInt32 v)
 
static MAXON_FUNCTION REFTYPE IntToString (Int64 v)
 
static MAXON_FUNCTION REFTYPE UIntToString (UInt64 v)
 
static MAXON_FUNCTION REFTYPE MemorySizeToString (Int64 v, Bool mebibytes=true)
 
static MAXON_FUNCTION REFTYPE HexToString (UInt32 v, Bool prefix0x=true)
 
static MAXON_FUNCTION REFTYPE HexToString (UInt64 v, Bool prefix0x=true)
 
static MAXON_FUNCTION REFTYPE PointerToString (const void *v)
 

Member Typedef Documentation

◆ Super

Member Function Documentation

◆ GetLength()

MAXON_METHOD Int GetLength ( ) const

Returns the length (number of elements) of the string, not the size of the block.

◆ Init()

MAXON_METHOD Result<void> Init ( Int  count = 0,
CHARTYPE  fillChar = 0 
)

Initializes the string with a specific length and a default character.

Parameters
[in]countNumber of characters of the new string.
[in]fillCharCharacter to fill the string with.
Returns
OK on success.

◆ Shrink()

MAXON_METHOD Result<void> Shrink ( )

Optimizes the memory usage. This can only be done if the string previously contained 16- or 32-bit Unicode characters that now have been removed or if the string was longer before.

Returns
OK on success. Also returns OK if the string already is in its smallest state.

◆ Append() [1/2]

MAXON_METHOD Result<void> Append ( const INTERFACETYPE *  str)

Concatenates 2 strings, use this operation instead of a = a + b as it is much faster.

Returns
OK on success.

◆ Append() [2/2]

MAXON_METHOD Result<void> Append ( const CHARTYPE *  str,
Int  len 
)

Concatenates 2 strings of which the second is represented by len characters at address str in memory.

Parameters
[in]strCharacter pointer.
[in]lenNumber of characters.
Returns
OK on success.

◆ AppendChar()

MAXON_FUNCTION Result<void> AppendChar ( CHARTYPE  v)

Appends a character to the current string.

Parameters
[in]vThe character that will be added.
Returns
OK on success.

◆ FindIndex() [1/2]

MAXON_METHOD Int FindIndex ( const INTERFACETYPE *  str,
StringPosition  start = 0 
) const

Searches for the first occurrence of 'str' within a string.

Parameters
[in]strThe search string.
[in]startStarting position within the current string to search from. If it is out of bounds the function will return InvalidArrayIndex.
Returns
The index at which 'str' has been found or InvalidArrayIndex. {default=InvalidArrayIndex}

◆ FindLastIndex() [1/2]

MAXON_METHOD Int FindLastIndex ( const INTERFACETYPE *  str,
StringPosition  start = StringEnd() 
) const

Searches for the last occurrence of 'str' within a string.

Parameters
[in]strThe search string.
[in]startStarting position within the current string to search from (backwards). The character at the given position will not be included in the search. If it is out of bounds the function will return InvalidArrayIndex.
Returns
The index at which 'str' has been found or InvalidArrayIndex. {default=InvalidArrayIndex}

◆ FindIndex() [2/2]

MAXON_METHOD Int FindIndex ( CHARTYPE  ch,
StringPosition  start = 0 
) const

Searches for the first occurrence of character 'ch' within a string.

Parameters
[in]chThe search character.
[in]startStarting position within the current string to search from. If it is out of bounds the function will return InvalidArrayIndex.
Returns
The index at which 'ch' has been found or InvalidArrayIndex. {default=InvalidArrayIndex}

◆ FindLastIndex() [2/2]

MAXON_METHOD Int FindLastIndex ( CHARTYPE  ch,
StringPosition  start = StringEnd() 
) const

Searches for the last occurrence of character 'ch' within a string.

Parameters
[in]chThe search character.
[in]startStarting position within the current string to search from (backwards). The character at the given position will not be included in the search. If it is out of bounds the function will return InvalidArrayIndex.
Returns
The index at which 'ch' has been found or InvalidArrayIndex. {default=InvalidArrayIndex}

◆ FindUpperIndex()

MAXON_METHOD Int FindUpperIndex ( const INTERFACETYPE *  str,
StringPosition  start = 0 
) const

Uppercase search for the first occurrence of 'str' within a string (which doesn't need to contain uppercase characters).

Parameters
[in]strThe search string, must be completely uppercase, otherwise no matches will be found.
[in]startStarting position within the current string to search from. If it is out of bounds the function will return InvalidArrayIndex.
Returns
The index at which 'str' has been found or InvalidArrayIndex. {default=InvalidArrayIndex}

◆ FindLastUpperIndex()

MAXON_METHOD Int FindLastUpperIndex ( const INTERFACETYPE *  str,
StringPosition  start = StringEnd() 
) const

Uppercase search for the last occurrence of 'str' within a string (which doesn't need to contain uppercase characters).

Parameters
[in]strThe search string, must be completely uppercase, otherwise no matches will be found.
[in]startStarting position within the current string to search from (backwards). The character at the given position will not be included in the search. If it is out of bounds the function will return InvalidArrayIndex.
Returns
The index at which 'str' has been found or InvalidArrayIndex. {default=InvalidArrayIndex}

◆ Erase()

MAXON_METHOD Result<void> Erase ( StringPosition  position,
StringCount  count 
)

Erases a range of characters within a string.

Parameters
[in]positionThe starting position to delete 'count' characters. If the position is out of bounds an error will be returned.
[in]countNumber of characters to delete. If you want to delete all characters until the end pass StringEnd(). If the number is larger than what is available an error will be returned.
Returns
OK on success.

◆ Insert() [1/2]

MAXON_METHOD Result<void> Insert ( StringPosition  position,
const INTERFACETYPE *  str,
StringPosition  strStart = 0,
StringCount  strCount = StringEnd() 
)

Inserts a string at a specific position.

Parameters
[in]positionInsert position in the current string. StringEnd() is a valid position. If the position is out of bounds an error is returned.
[in]strString to be inserted.
[in]strStartStarting position of the string to be inserted. If the position is out of bounds an error is returned.
[in]strCountNumber of characters to be inserted. If the number of characters is too large an error is returned.
Returns
OK on success.

◆ Insert() [2/2]

MAXON_METHOD Result<void> Insert ( StringPosition  position,
CHARTYPE  ch 
)

Inserts a single unicode character at a specific position.

Parameters
[in]positionInsert position, needs to be within boundaries.
[in]chUnicode character to insert.
Returns
OK on success.

◆ GetPart()

MAXON_METHOD INTERFACETYPE* GetPart ( StringPosition  start,
StringCount  count 
) const

Creates a part of the current string.

Parameters
[in]startPosition where the new partial string will start.
[in]countNumber of characters for the partial string. If it is larger than the number of available characters an empty string will be returned.
Returns
The partial string, or empty string if 'start' was out of boundaries. Will be an empty reference if GetPart fails (apply iferr for error handling).

◆ ToUpper()

MAXON_METHOD INTERFACETYPE* ToUpper ( ) const

Returns the uppercase version of a string.

Returns
Uppercase version of a string. Will be an empty reference if ToUpper fails (apply iferr for error handling).

◆ ToLower()

MAXON_METHOD INTERFACETYPE* ToLower ( ) const

Returns the lowercase version of a string.

Returns
Lowercase version of a string. Will be an empty reference if ToLower fails (apply iferr for error handling).

◆ ComparePart()

MAXON_METHOD COMPARERESULT ComparePart ( const INTERFACETYPE *  str,
STRINGCOMPARISON  mode,
StringPosition  position,
StringCount  count 
) const

Compares a part of this against 'str' for exact match. Example:

"abcdefghijk"_s.ComparePart("bcd"_s,STRINGCOMPARISON::MEMORY,1,3);

returns COMPARESTRING::EQUAL for matching "bcd"

Parameters
[in]strComparison object.
[in]modeComparison mode.
[in]positionStarting position in the current string that 'str' will be compared against. The interval [position..count] will be clipped against valid boundaries.
[in]countNumber of characters in the current string that 'str' will be compared against. count can be longer than the string length and will be clipped accordingly.
Returns
See COMPARERESULT.

◆ Compare()

MAXON_FUNCTION COMPARERESULT Compare ( const INTERFACETYPE *  str,
STRINGCOMPARISON  mode = STRINGCOMPARISON::UNICODE_NUMBERS 
) const

Compares the object against 'str' for exact match.

Parameters
[in]strComparison object.
[in]modeComparison mode.
Returns
See COMPARERESULT.

◆ IsEqual()

MAXON_FUNCTION Bool IsEqual ( const INTERFACETYPE *  str) const

Compare strings for equality.

Returns
True if equal.

◆ GetHashCode()

MAXON_METHOD UInt GetHashCode ( ) const

◆ SetChar()

MAXON_METHOD void SetChar ( Int  pos,
CHARTYPE  ch 
)

Changes the character at the given position (used internally by CharPtr).

Parameters
[in]posCharacter index. If it is negative the position is relative to end, e.g. -1 indicates the last character. The position must be within boundaries, however only a debug assert will happen otherwise.
[in]chCharacter value.

{refclass=false}

◆ GetChar()

MAXON_METHOD CHARTYPE GetChar ( Int  pos) const

Retrieves the character at a given position. If the position is out of bounds 0 will be returned.

Parameters
[in]posCharacter position. If it is negative the position is relative to end, e.g. -1 indicates the last character. The position must be within boundaries, however only a debug assert will happen otherwise.
Returns
The character.

{refclass=false}

◆ ToFloat64()

Converts a string to a 64-bit floating point value. This routine does no formula parsing. While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Floating point value of the string.

◆ ToFloat32()

Converts a string to a 32-bit floating point value. This routine does no formula parsing. While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Floating point value of the string.

◆ ToFloat()

Converts a string to a floating point value. This routine does no formula parsing. While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Floating point value of the string.

◆ ToInt64()

Converts a string to a 64 bit integer value. This routine does no formula parsing and does not support any suffixes/prefixes except for 0x (hexadecimal numbers). While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Integer value of the string.

◆ ToInt32()

Converts a string to a 32 bit integer value. This routine does no formula parsing and does not support any suffixes/prefixes except for 0x (hexadecimal numbers). While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Integer value of the string.

◆ ToInt()

Converts a string to an integer value. This routine does no formula parsing and does not support any suffixes/prefixes except for 0x (hexadecimal numbers). While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Integer value of the string.

◆ ToUInt64()

Converts a string to a 64 bit unsigned integer value. This routine does no formula parsing and does not support any suffixes/prefixes except for 0x (hexadecimal numbers). While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Integer value of the string.

◆ ToUInt32()

Converts a string to a 32 bit unsigned integer value. This routine does no formula parsing and does not support any suffixes/prefixes except for 0x (hexadecimal numbers). While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Integer value of the string.

◆ ToUInt()

Converts a string to an unsigned integer value. This routine does no formula parsing and does not support any suffixes/prefixes except for 0x (hexadecimal numbers). While leading whitespaces are allowed by default no trailing characters of any kind are allowed.

Parameters
[in]flagsOptional flags for the conversion.
Returns
Integer value of the string.

◆ FloatToString() [1/2]

static MAXON_FUNCTION REFTYPE FloatToString ( Float32  value,
Int  charsBeforeComma = STRING_DYNAMIC_DIGITS,
Int  digitsAfterComma = -3,
Bool  exponent = false,
CHARTYPE  fillChar = ' ' 
)
static

Converts a floating point value into formatted text.

Parameters
[in]valueFloating point value to convert into text.
[in]charsBeforeCommaCharacters before the decimal point. If STRING_DYNAMIC_DIGITS is passed or 'charsBeforeComma' is too low to represent 'value' it is automatically increased/adjusted. If 'charsBeforeComma' is positive and exponent is false fill characters will be added to the beginning. If STRING_MAXIMUM_PRECISION is passed, then the result will be an exact representation of the value (possibly using exponential notation).
[in]digitsAfterCommaDigits after the decimal point. If a negative number is passed the number of digits is automatically chosen and up to (-digitsAfterComma).
[in]exponentForce exponential-style output (e.g. 1.0e+10).
[in]fillCharFill character for digits before the decimal point. E.g. if you specify 4 for charsBeforeComma, '*' for fillChar and your value is 1.5 you'll get ***1.5 as a result. This value has no impact if exponent is true.
Returns
String object with the decimal text of the value.

◆ FloatToString() [2/2]

static MAXON_FUNCTION REFTYPE FloatToString ( Float64  value,
Int  charsBeforeComma = STRING_DYNAMIC_DIGITS,
Int  digitsAfterComma = -3,
Bool  exponent = false,
CHARTYPE  fillChar = ' ' 
)
static

Converts a floating point value into formatted text.

Parameters
[in]valueFloating point value to convert into text.
[in]charsBeforeCommaCharacters before the decimal point. If STRING_DYNAMIC_DIGITS is passed or 'charsBeforeComma' is too low to represent 'value' it is automatically increased/adjusted. If 'charsBeforeComma' is positive and exponent is false fill characters will be added to the beginning. If STRING_MAXIMUM_PRECISION is passed, then the result will be an exact representation of the value (possibly using exponential notation).
[in]digitsAfterCommaDigits after the decimal point. If a negative number is passed the number of digits is automatically chosen and up to (-digitsAfterComma).
[in]exponentForce exponential-style output (e.g. 1.0e+10).
[in]fillCharFill character for digits before the decimal point. E.g. if you specify 4 for charsBeforeComma, '*' for fillChar and your value is 1.5 you'll get ***1.5 as a result. This value has no impact if exponent is true.
Returns
String object with the decimal text of the value.

◆ AppendInt() [1/2]

MAXON_FUNCTION INTERFACETYPE* AppendInt ( Int32  v)

Appends a number to the current string.

Parameters
[in]vThe number that will be added.
Returns
The current string. Will be an empty reference if AppendInt fails (apply iferr for error handling). {returnsThis,noResult}

◆ AppendUInt() [1/2]

MAXON_FUNCTION INTERFACETYPE* AppendUInt ( UInt32  v)

Appends a number to the current string.

Parameters
[in]vThe number that will be added.
Returns
The current string. Will be an empty reference if AppendUInt fails (apply iferr for error handling). {returnsThis,noResult}

◆ AppendInt() [2/2]

MAXON_FUNCTION INTERFACETYPE* AppendInt ( Int64  v)

Appends a number to the current string.

Parameters
[in]vThe number that will be added.
Returns
The current string. Will be an empty reference if AppendInt fails (apply iferr for error handling). {returnsThis,noResult}

◆ AppendUInt() [2/2]

MAXON_FUNCTION INTERFACETYPE* AppendUInt ( UInt64  v)

Appends a number to the current string.

Parameters
[in]vThe number that will be added.
Returns
The current string. Will be an empty reference if AppendUInt fails (apply iferr for error handling). {returnsThis,noResult}

◆ IntToString() [1/2]

static MAXON_FUNCTION REFTYPE IntToString ( Int32  v)
static

Formats a Int32 value as decimal text.

Parameters
[in]vInt32 value.
Returns
String object with the decimal text of the value. Will be an empty reference on failure (apply iferr for error handling).

◆ UIntToString() [1/2]

static MAXON_FUNCTION REFTYPE UIntToString ( UInt32  v)
static

Formats a UInt32 value as decimal text.

Parameters
[in]vUInt32 value.
Returns
String object with the decimal text of the value. Will be an empty reference on failure (apply iferr for error handling).

◆ IntToString() [2/2]

static MAXON_FUNCTION REFTYPE IntToString ( Int64  v)
static

Formats a Int64 value as decimal text.

Parameters
[in]vInt64 value.
Returns
String object with the decimal text of the value. Will be an empty reference on failure (apply iferr for error handling).

◆ UIntToString() [2/2]

static MAXON_FUNCTION REFTYPE UIntToString ( UInt64  v)
static

Formats a UInt64 value as decimal text.

Parameters
[in]vInt64 value.
Returns
String object with the decimal text of the value. Will be an empty reference on failure (apply iferr for error handling).

◆ MemorySizeToString()

static MAXON_FUNCTION REFTYPE MemorySizeToString ( Int64  v,
Bool  mebibytes = true 
)
static

Formats a Int64 value as a memory information.

Parameters
[in]vThe size of bytes that should be formated as memory text.
[in]mebibytesdefines if a value of 1343443 is either output as "1.28 MiB" (mebibytes) or "1.34 MB" (megabytes).
Returns
String object for the given mem value.

◆ HexToString() [1/2]

static MAXON_FUNCTION REFTYPE HexToString ( UInt32  v,
Bool  prefix0x = true 
)
static

Formats a Int32 value as hexadecimal text.

Parameters
[in]vInt32 value.
[in]prefix0xStart the string with 0x as prefix.
Returns
String object with the hexadecimal text of the value.

◆ HexToString() [2/2]

static MAXON_FUNCTION REFTYPE HexToString ( UInt64  v,
Bool  prefix0x = true 
)
static

Formats a Int64 value as hexadecimal text.

Parameters
[in]vInt64 value.
[in]prefix0xStart the string with 0x as prefix.
Returns
String object with the hexadecimal text of the value.

◆ PointerToString()

static MAXON_FUNCTION REFTYPE PointerToString ( const void *  v)
static

Formats a pointer as hexadecimal text. The pointer starts with 0x prefix.

Parameters
[in]vPointer to convert.
Returns
String object with the hexadecimal text of the value.

◆ GetUtf32()

MAXON_METHOD Result<void> GetUtf32 ( Utf32CharBuffer stringData) const

Copies the string as UTF-32 encoded characters into the passed array. The array will be resized and contain the non \0 - terminated data.

Parameters
[out]stringDataThe array to receive the data.
Returns
OK on success.

◆ TrimLeft()

MAXON_METHOD Result<void> TrimLeft ( )

Removes all characters with value <= 0x20 (e.g. space, tab, line feed) at the beginning of the string.

Returns
OK on success.

◆ TrimRight()

MAXON_METHOD Result<void> TrimRight ( )

Removes all characters with value <= 0x20 (e.g. space, tab, line feed) at the end of the string.

Returns
OK on success.

◆ Split()

MAXON_METHOD Result<void> Split ( const REFTYPE &  splitSymbol,
Bool  trim,
const ValueReceiver< const REFTYPE &> &  parts 
) const

Splits the string into parts separated by the split symbol (e.g. a comma).

Parameters
[in]splitSymbolString containing the split symbol.
[in]trimIf true each separated part will be trimmed (see Trim).
[out]partsArray to be filled with the separated strings.
Returns
OK on success.

◆ Replace() [1/3]

MAXON_METHOD Result<Int> Replace ( CHARTYPE  find,
CHARTYPE  replace 
)

Replaces all occurrences of the character 'find' in the current string with the given character 'replace'.

Parameters
[in]findSearch character. Each occurrence will be replaced with 'replace'.
[in]replaceReplacement of 'find'.
Returns
Number of replaced characters.

◆ Replace() [2/3]

MAXON_METHOD Result<Int> Replace ( const REFTYPE &  find,
const REFTYPE &  replace 
)

Replaces all occurrences of string 'find' in the current string with the given string 'replace'.

Parameters
[in]findSearch string. Each occurrence will be replaced with 'replace'.
[in]replaceReplacement of 'find'. Can be an empty string, in which case all 'find' strings will be removed.
Returns
Number of replaced strings.

◆ Replace() [3/3]

MAXON_METHOD Result<Int> Replace ( CHARTYPE  find,
const REFTYPE &  replace 
)

Replaces all occurrences of the character 'find' in the current string with the given string 'replace'.

Parameters
[in]findSearch character. Each occurrence will be replaced with 'replace'.
[in]replaceReplacement of 'find'. Can be an empty string, in which case all 'find' characters will be removed.
Returns
Number of replaced strings.

◆ Find() [1/2]

MAXON_FUNCTION Bool Find ( const REFTYPE &  str,
Int pos,
StringPosition  start = 0 
) const

Searches for the first occurrence of 'str' within a string.

Parameters
[in]strThe search string.
[out]posPointer to be filled with the position where 'str' was found. This parameter can be a nullptr. In case no occurence was found *pos is initialized with InvalidArrayIndex.
[in]startStarting position within the current string to search from. If it is out of bounds the function will return false.
Returns
True if 'str' has been found, in that case *pos contains the position where the first occurance was found.

◆ FindLast() [1/2]

MAXON_FUNCTION Bool FindLast ( const REFTYPE &  str,
Int pos,
StringPosition  start = StringEnd() 
) const

Searches for the last occurrence of 'str' within a string.

Parameters
[in]strThe search string.
[out]posPointer to be filled with the position where 'str' was found. This parameter can be a nullptr. In case no occurence was found *pos is initialized with InvalidArrayIndex.
[in]startStarting position within the current string to search from (backwards). The character at the given position will not be included in the search. If it is out of bounds the function will return false.
Returns
True if 'str' has been found, in that case *pos contains the position where the last occurance was found.

◆ Find() [2/2]

MAXON_FUNCTION Bool Find ( CHARTYPE  ch,
Int pos,
StringPosition  start = 0 
) const

Searches for the first occurrence of character 'ch' within a string.

Parameters
[in]chThe search character.
[out]posPointer to be filled with the position where 'ch' was found. This parameter can be a nullptr. In case no occurence was found *pos is initialized with InvalidArrayIndex.
[in]startStarting position within the current string to search from. If it is out of bounds the function will return false.
Returns
True if 'ch' has been found, in that case *pos contains the position where the first occurance was found.

◆ FindLast() [2/2]

MAXON_FUNCTION Bool FindLast ( CHARTYPE  ch,
Int pos,
StringPosition  start = StringEnd() 
) const

Searches for the last occurrence of character 'ch' within a string.

Parameters
[in]chThe search character.
[out]posPointer to be filled with the position where 'ch' was found. This parameter can be a nullptr. In case no occurence was found *pos is initialized with InvalidArrayIndex.
[in]startStarting position within the current string to search from (backwards). The character at the given position will not be included in the search. If it is out of bounds the function will return false.
Returns
True if 'ch' has been found, in that case *pos contains the position where the last occurance was found.

◆ FindUpper()

MAXON_FUNCTION Bool FindUpper ( const REFTYPE &  str,
Int pos,
StringPosition  start = 0 
) const

Uppercase search for the first occurrence of 'str' within a string (which doesn't need to contain uppercase characters).

Parameters
[in]strThe search string, must be completely uppercase, otherwise no matches will be found.
[out]posPointer to be filled with the position where 'ch' was found. This parameter can be a nullptr. In case no occurence was found *pos is initialized with InvalidArrayIndex.
[in]startStarting position within the current string to search from. If it is out of bounds the function will return false.
Returns
True if 'str' has been found, in that case *pos contains the position where the first occurance was found.

◆ FindLastUpper()

MAXON_FUNCTION Bool FindLastUpper ( const REFTYPE &  str,
Int pos,
StringPosition  start = StringEnd() 
) const

Uppercase search for the last occurrence of 'str' within a string (which doesn't need to contain uppercase characters).

Parameters
[in]strThe search string, must be completely uppercase, otherwise no matches will be found.
[out]posPointer to be filled with the position where 'ch' was found. This parameter can be a nullptr. In case no occurence was found *pos is initialized with InvalidArrayIndex.
[in]startStarting position within the current string to search from (backwards). The character at the given position will not be included in the search. If it is out of bounds the function will return false.
Returns
True if 'str' has been found, in that case *pos contains the position where the last occurance was found.

◆ GetLeftPart()

MAXON_FUNCTION INTERFACETYPE* GetLeftPart ( StringPosition  start) const

Returns the string part left of the given position. The character at position will not be included.

Parameters
[in]startPartitioning position.
Returns
The partial string, or empty string if 'start' was out of boundaries. Will be an empty reference on failure (apply iferr for error handling).

◆ GetRightPart()

MAXON_FUNCTION INTERFACETYPE* GetRightPart ( StringPosition  start) const

Returns the string part right of the given position. The character at position will be included.

Parameters
[in]startPartitioning position.
Returns
The partial string, or empty string if 'start' was out of boundaries. Will be an empty reference on failure (apply iferr for error handling).

◆ StartsWith() [1/2]

MAXON_FUNCTION Bool StartsWith ( CHARTYPE  ch) const

Checks if the string starts with a certain character.

Parameters
[in]chThe character to be checked.
Returns
True if the string starts with the given character.

◆ StartsWith() [2/2]

MAXON_FUNCTION Bool StartsWith ( const REFTYPE &  str) const

Checks if the current string starts with a given string.

Parameters
[in]strThe string part.
Returns
True if the string starts with the string 'str'.

◆ EndsWith() [1/2]

MAXON_FUNCTION Bool EndsWith ( CHARTYPE  ch) const

Checks if the string ends with a certain character.

Parameters
[in]chThe character to be checked.
Returns
True if the string end with the given character.

◆ EndsWith() [2/2]

MAXON_FUNCTION Bool EndsWith ( const REFTYPE &  str) const

Checks if the current string end with a given string.

Parameters
[in]strThe string part.
Returns
True if the string ends with the string 'str'.

◆ Trim()

MAXON_FUNCTION Result<void> Trim ( )

Removes all characters with value <= 0x20 (e.g. space, tab, line feed) at the beginning and the end of the string.

Returns
OK on success.