A string class. More...

#include "murl_string.h"

Public Types

typedef const CharConstIterator
 Definition of the const iterator.
 

Public Member Functions

 String ()
 Construct an empty string.
 
 String (const String &str)
 Construct using a given string. More...
 
 String (const Char *str)
 Construct a copy from a given C-string. More...
 
 String (const String &str, SInt32 length)
 Construct a copy of a given string and length. More...
 
 String (const Char *str, SInt32 length)
 Construct a copy from a given C-string & length. More...
 
 String (const UInt8 *str, SInt32 length)
 Construct a copy from a given byte pointer and length. More...
 
 String (Char charCode, SInt32 length)
 Construct and fill a string with a given character and length. More...
 
 ~String ()
 Destroy the string.
 
void Clear ()
 Clear the string and remove the underlying storage.
 
void Shrink ()
 Shrink the string so that the underlying storage is only as large as necessary.
 
Bool Reserve (SInt32 count)
 Reserve additional storage space. More...
 
Bool CutAt (SInt32 pos)
 Cut the string on a given position. More...
 
String Trim () const
 Trim white spaces from left and right.
 
String TrimLeft () const
 Trim white spaces from left.
 
String TrimRight () const
 Trim white spaces from right.
 
String ToLowerUTF8 () const
 Get the lower case string including UTF-8 characters. More...
 
String ToUpperUTF8 () const
 Get the upper case string including UTF-8 characters. More...
 
SInt32 GetLengthUTF8 () const
 Count the number of UTF-8 characters. More...
 
String GetUTF8Char (SInt32 pos) const
 Get a UTF-8 character at a specified position. More...
 
StringArray GetUTF8Chars () const
 Get the UTF-8 characters. More...
 
WCharArray GetWChars () const
 Get the wide-characters. More...
 
Bool GetWChars (WCharArray &wcharArray) const
 Get the wide-characters and success status. More...
 
UInt16Array GetUTF16Chars () const
 Get the UTF-16 characters. More...
 
Bool GetUTF16Chars (UInt16Array &utf16Array) const
 Get the UTF-16 characters and success status. More...
 
UInt32Array GetUTF32Chars () const
 Get the UTF-32 characters. More...
 
Bool GetUTF32Chars (UInt32Array &utf32Array) const
 Get the UTF-32 characters and success status. More...
 
Bool SetWChars (const WCharArray &wcharArray)
 Set UTF-8 characters from a wide-character string. More...
 
Bool SetWChars (const WChar *wcharArray)
 Set UTF-8 characters from a wide-character string pointer. More...
 
Bool SetUTF16Chars (const UInt16Array &utf16Array)
 Set UTF-8 characters from an UTF16 string. More...
 
Bool SetUTF16Chars (const UInt16 *utf16Array)
 Set UTF-8 characters from an UTF16 string pointer. More...
 
Bool SetUTF32Chars (const UInt32Array &utf32Array)
 Set UTF-8 characters from an UTF32 string. More...
 
Bool SetUTF32Chars (const UInt32 *utf32Array)
 Set UTF-8 characters from an UTF32 string pointer. More...
 
StringCat (const StringArray &stringArray)
 Append all strings from an string array. More...
 
Bool RemoveLastUTF8 ()
 Remove the last character from the string including UTF-8. More...
 
Char GetChar (SInt32 pos) const
 Get a character at a specified position. More...
 
Bool Set (SInt32 pos, Char charCode)
 Set a character. More...
 
void Set (const String &str)
 Set to a given string. More...
 
void Set (const Char *str, SInt32 length)
 Set to a given string and length. More...
 
Bool Insert (SInt32 pos, Char charCode)
 Insert a character. More...
 
Bool Insert (SInt32 pos, const Char *str, SInt32 count)
 Insert a C-string & length. More...
 
Bool Insert (SInt32 pos, const String &str)
 Insert a string. More...
 
Bool Insert (SInt32 pos, const Char *str)
 Insert a C-string. More...
 
Bool Remove (SInt32 pos, SInt32 count=1)
 Remove character(s). More...
 
SInt32 RemoveChar (Char character)
 Remove all occurrences of a character. More...
 
StringCat (const Char *str)
 Append a C-string. More...
 
StringCat (const String &str)
 Append a string. More...
 
StringCat (Char charCode, SInt32 count)
 Append characters. More...
 
StringCat (const String &str, SInt32 length)
 Append from a given string and length. More...
 
StringCat (const UInt8 *str, SInt32 length)
 Append from a given byte pointer and length. More...
 
StringCat ()
 Get a reference of the string. More...
 
StringCat (Char charCode)
 Append a character. More...
 
StringCat (const Char *str, SInt32 length)
 Append from a given C-string & length. More...
 
String Mid (SInt32 from, SInt32 count) const
 Get a substring copy. More...
 
String Mid (const String &startDelimiter, const String &endDelimiter, Bool isStartOptional=true, Bool isEndOptional=true) const
 Get a substring copy using delimiters. More...
 
String Mid (SInt32 from) const
 Get a substring copy. More...
 
String Right (SInt32 count) const
 Get a substring from the right. More...
 
String Left (SInt32 count) const
 Get a substring from the left. More...
 
UInt32 Replace (const Char *find, SInt32 findLen, const Char *replace, SInt32 replaceLen)
 Find any occurrence of a C-string & length and replace each occurrence by a C-string & length. More...
 
UInt32 Replace (const String &find, const String &replace)
 Find any occurrence of a string and replace each occurrence by a string. More...
 
UInt32 Replace (const Char *find, const Char *replace)
 Find any occurrence of a C-string and replace each occurrence by a C-string. More...
 
UInt32 Replace (const String &find, const Char *replace)
 Find any occurrence of a string and replace each occurrence by a C-string. More...
 
UInt32 Replace (const Char *find, const String &replace)
 Find any occurrence of a C-string and replace each occurrence by a string. More...
 
SInt32 Find (Char charCode, SInt32 from=0) const
 Find a character. More...
 
SInt32 Find (SInt32 length, const Char *str, SInt32 from) const
 Find a C-string & length. More...
 
SInt32 Find (const Char *str, SInt32 from=0) const
 Find a C-string. More...
 
SInt32 Find (const String &str, SInt32 from=0) const
 Find a string. More...
 
SInt32 ReverseFind (Char charCode, SInt32 from) const
 Find a character from right to left. More...
 
SInt32 ReverseFind (Char charCode) const
 Find a character from right to left. More...
 
SInt32 ReverseFind (SInt32 length, const Char *str, SInt32 from) const
 Find a C-string & length from right to left at position. More...
 
SInt32 ReverseFind (const Char *str, SInt32 from) const
 Find a C-string from right to left at position. More...
 
SInt32 ReverseFind (const String &str, SInt32 from) const
 Find a string from right to left at position. More...
 
SInt32 ReverseFind (const Char *str) const
 Find a C-string from right to left. More...
 
SInt32 ReverseFind (const String &str) const
 Find a string from right to left. More...
 
SInt32 FindFirstOf (SInt32 length, const Char *str, SInt32 from) const
 Find first character from a character set C-string & length. More...
 
SInt32 FindFirstOf (const Char *str, SInt32 from=0) const
 Find first character from a character set C-string. More...
 
SInt32 FindFirstOf (const String &str, SInt32 from=0) const
 Find first character from a character set string. More...
 
SInt32 FindFirstNotOf (SInt32 length, const Char *str, SInt32 from) const
 Find the first character not matching any of the characters in a given set. More...
 
SInt32 FindFirstNotOf (const Char *str, SInt32 from=0) const
 Find the first character not matching any of the characters in a given set. More...
 
SInt32 FindFirstNotOf (const String &str, SInt32 from=0) const
 Find the first character not matching any of the characters in a given set. More...
 
Bool StartsWith (const Char *str, SInt32 length) const
 Check if the start matches a C-string & length. More...
 
Bool StartsWith (const Char *str) const
 Check if the start matches a C-string. More...
 
Bool StartsWith (const String &str) const
 Check if the start matches a string. More...
 
Bool EndsWith (const Char *str, SInt32 length) const
 Check if the end matches a C-string & length. More...
 
Bool EndsWith (const Char *str) const
 Check if the end matches a C-string. More...
 
Bool EndsWith (const String &str) const
 Check if the end matches a string. More...
 
SInt32 Compare (const Char *str) const
 Compare a C-string. More...
 
SInt32 Compare (const String &str) const
 Compare a string. More...
 
Bool IsEqual (const Char *str) const
 Check if a C-string is equal. More...
 
Bool IsEqual (const String &str) const
 Check if a string is equal. More...
 
UInt32 GetHashValue () const
 Calculate the string hash value. More...
 
SInt32 GetAlloc () const
 Get the number of allocated bytes for characters, excluding the zero terminator. More...
 
SInt32 GetLength () const
 Get number of byte characters. More...
 
Bool IsEmpty () const
 Check if the string is empty. More...
 
const StringToString () const
 Get a const reference of the string. More...
 
const CharBegin () const
 Get the pointer to the first character. More...
 
const CharEnd () const
 Get the pointer to the end of the string. More...
 
const CharLast () const
 Get the pointer to the last character. More...
 
 operator const Char * () const
 Conversion operator to C-string. More...
 
 operator const UInt8 * () const
 Conversion operator to byte pointer. More...
 
 operator const void * () const
 Conversion operator to void pointer. More...
 
Char operator[] (SInt32 pos) const
 The array operator. More...
 
Char operator* () const
 Indirection operator. More...
 
Stringoperator= (const Char *str)
 Assignment operator for C-string. More...
 
Stringoperator= (const String &str)
 Assignment operator for string. More...
 
const Stringoperator+= (Char chr)
 In-place addition operator for a character. More...
 
const Stringoperator+= (const Char *str)
 In-place addition operator for const C-string. More...
 
const Stringoperator+= (const String &str)
 In-place addition operator for string. More...
 
const Stringoperator+= (UInt64 value)
 In-place addition operator for UInt64. More...
 
const Stringoperator+= (SInt64 value)
 In-place addition operator for SInt64. More...
 
const Stringoperator+= (UInt32 value)
 In-place addition operator for UInt32. More...
 
const Stringoperator+= (SInt32 value)
 In-place addition operator for SInt32. More...
 
const Stringoperator+= (Double value)
 In-place addition operator for Double. More...
 
const Stringoperator+= (const Color &value)
 In-place addition operator for Color. More...
 
const Stringoperator+= (Bool value)
 In-place addition operator for Bool. More...
 
const Stringoperator+= (const System::Time &value)
 In-place addition operator for Color. More...
 
void Swap (String &other)
 Exchange the content of the string with a given second one. More...
 

Friends

String operator+ (const String &lhs, const String &rhs)
 Addition operator for string and string. More...
 
String operator+ (const String &lhs, const Char *rhs)
 Addition operator for string and C-string. More...
 
String operator+ (const Char *lhs, const String &rhs)
 Addition operator for C-string and string. More...
 
String operator+ (const String &lhs, Char rhs)
 Addition operator for string and character. More...
 
String operator+ (Char lhs, const String &rhs)
 Addition operator for character and string. More...
 
String operator+ (const String &lhs, UInt64 rhs)
 Addition operator for UInt64 and string. More...
 
String operator+ (const String &lhs, SInt64 rhs)
 Addition operator for SInt64 and string. More...
 
String operator+ (const String &lhs, UInt32 rhs)
 Addition operator for UInt32 and string. More...
 
String operator+ (const String &lhs, SInt32 rhs)
 Addition operator for SInt32 and string. More...
 
String operator+ (const String &lhs, Double rhs)
 Addition operator for Double and string. More...
 
String operator+ (const String &lhs, const Color &rhs)
 Addition operator for Color and string. More...
 
String operator+ (const String &lhs, Bool rhs)
 Addition operator for Bool and string. More...
 
String operator+ (const String &lhs, const System::Time &rhs)
 Addition operator for Time and string. More...
 
bool operator< (const String &lhs, const String &rhs)
 Less than operator for string and string. More...
 
bool operator< (const String &lhs, const Char *rhs)
 Less than operator for string and C-string. More...
 
bool operator< (const Char *lhs, const String &rhs)
 Less than operator for C-string and string. More...
 
bool operator<= (const String &lhs, const String &rhs)
 Less than or equal to operator for string and string. More...
 
bool operator<= (const String &lhs, const Char *rhs)
 Less than or equal to operator for string and C-string. More...
 
bool operator<= (const Char *lhs, const String &rhs)
 Less than or equal to operator for C-string and string. More...
 
bool operator> (const String &lhs, const String &rhs)
 Greater than operator for string and string. More...
 
bool operator> (const String &lhs, const Char *rhs)
 Greater than operator for string and C-string. More...
 
bool operator> (const Char *lhs, const String &rhs)
 Greater than operator for C-string and string. More...
 
bool operator>= (const String &lhs, const String &rhs)
 Greater than or equal to operator for string and string. More...
 
bool operator>= (const String &lhs, const Char *rhs)
 Greater than or equal to operator for string and C-string. More...
 
bool operator>= (const Char *lhs, const String &rhs)
 Greater than or equal to operator for C-string and string. More...
 
bool operator== (const String &lhs, const String &rhs)
 Equal to comparison operator for string and string. More...
 
bool operator== (const String &lhs, const Char *rhs)
 Equal to comparison operator for string and C-string. More...
 
bool operator== (const Char *lhs, const String &rhs)
 Equal to comparison operator for C-string and string. More...
 
bool operator!= (const String &lhs, const String &rhs)
 Not equal to comparison operator for string and string. More...
 
bool operator!= (const String &lhs, const Char *rhs)
 Not equal to comparison operator for string and C-string. More...
 
bool operator!= (const Char *lhs, const String &rhs)
 Not equal to comparison operator for C-string and string. More...
 

Detailed Description

A string class.

The string class contains an array of byte characters which can store an 8 bit encoded string or an UTF-8 encoded string. The array of characters is zero terminated.
A C-string is a pointer to an array of byte characters which is zero-terminated.
This class is based on the NTL String container, see http://www.ultimatepp.org

Constructor & Destructor Documentation

◆ String() [1/6]

Murl::String::String ( const String str)
inline

Construct using a given string.

Parameters
strThe original string.

◆ String() [2/6]

Murl::String::String ( const Char str)
inline

Construct a copy from a given C-string.

Parameters
strThe C-string to copy.

◆ String() [3/6]

Murl::String::String ( const String str,
SInt32  length 
)
inline

Construct a copy of a given string and length.

Verify (assert in debug build) 'length' against the length of 'str'.

Parameters
strThe string to copy.
lengthThe number of bytes to copy.

References Begin(), GetLength(), and MURL_VERIFY.

◆ String() [4/6]

Murl::String::String ( const Char str,
SInt32  length 
)
inline

Construct a copy from a given C-string & length.

Parameters
strThe C-string to copy.
lengthThe number of bytes to copy.

◆ String() [5/6]

Murl::String::String ( const UInt8 str,
SInt32  length 
)
inline

Construct a copy from a given byte pointer and length.

Parameters
strThe byte pointer to copy.
lengthThe number of bytes to copy.

◆ String() [6/6]

Murl::String::String ( Char  charCode,
SInt32  length 
)
inline

Construct and fill a string with a given character and length.

Parameters
charCodeThe character code to fill.
lengthThe number of bytes to fill.

Member Function Documentation

◆ Reserve()

Bool Murl::String::Reserve ( SInt32  count)
inline

Reserve additional storage space.

Parameters
countThe number of additional bytes to reserve.
Returns
true if successful.

◆ CutAt()

Bool Murl::String::CutAt ( SInt32  pos)

Cut the string on a given position.

Verify (assert in debug build) 'pos' against the string length.

Parameters
posThe position to cut the string.
Returns
true if successful.

◆ ToLowerUTF8()

String Murl::String::ToLowerUTF8 ( ) const

Get the lower case string including UTF-8 characters.

Returns
The lower case UTF-8 string.

◆ ToUpperUTF8()

String Murl::String::ToUpperUTF8 ( ) const

Get the upper case string including UTF-8 characters.

Returns
The upper case UTF-8 string.

◆ GetLengthUTF8()

SInt32 Murl::String::GetLengthUTF8 ( ) const

Count the number of UTF-8 characters.

Returns
The number of UTF-8 characters.

◆ GetUTF8Char()

String Murl::String::GetUTF8Char ( SInt32  pos) const

Get a UTF-8 character at a specified position.

Verify (assert in debug build) 'pos' against the string length.

Parameters
posThe byte position to get the character from.
Returns
The UTF-8 character at the specified position, or an empty string if the position is out of range.

◆ GetUTF8Chars()

StringArray Murl::String::GetUTF8Chars ( ) const

Get the UTF-8 characters.

Returns
The UTF-8 characters string array.

◆ GetWChars() [1/2]

WCharArray Murl::String::GetWChars ( ) const
inline

Get the wide-characters.

Returns
The wide-characters array, if the conversion fails the characters array is empty.

References Murl::Array< DataType >::Clear().

◆ GetWChars() [2/2]

Bool Murl::String::GetWChars ( WCharArray wcharArray) const

Get the wide-characters and success status.

Parameters
wcharArrayThe wide-characters array return value.
Returns
true if successful, if conversion fails the wcharArray contains the already converted characters and false is returned.

◆ GetUTF16Chars() [1/2]

UInt16Array Murl::String::GetUTF16Chars ( ) const
inline

Get the UTF-16 characters.

Returns
The UTF-16 characters array, if the conversion fails the characters array is empty.

References Murl::Array< DataType >::Clear().

◆ GetUTF16Chars() [2/2]

Bool Murl::String::GetUTF16Chars ( UInt16Array utf16Array) const

Get the UTF-16 characters and success status.

Parameters
utf16ArrayThe UTF-16 characters array return value.
Returns
true if successful, if conversion fails the utf16Array contains the already converted characters and false is returned.

◆ GetUTF32Chars() [1/2]

UInt32Array Murl::String::GetUTF32Chars ( ) const
inline

Get the UTF-32 characters.

Returns
The UTF-32 characters array, if the conversion fails the characters array is empty.

References Murl::Array< DataType >::Clear().

◆ GetUTF32Chars() [2/2]

Bool Murl::String::GetUTF32Chars ( UInt32Array utf32Array) const

Get the UTF-32 characters and success status.

Parameters
utf32ArrayThe UTF-32 characters array return value.
Returns
true if successful, if conversion fails the utf32Array contains the already converted characters and false is returned.

◆ SetWChars() [1/2]

Bool Murl::String::SetWChars ( const WCharArray wcharArray)

Set UTF-8 characters from a wide-character string.

Parameters
wcharArrayThe wide-characters array.
Returns
true if successful, if conversion fails this String contains the already converted characters and false is returned.

◆ SetWChars() [2/2]

Bool Murl::String::SetWChars ( const WChar wcharArray)

Set UTF-8 characters from a wide-character string pointer.

Parameters
wcharArrayA pointer to the zero-terminated wide-characters.
Returns
true if successful, if conversion fails this String contains the already converted characters and false is returned.

◆ SetUTF16Chars() [1/2]

Bool Murl::String::SetUTF16Chars ( const UInt16Array utf16Array)

Set UTF-8 characters from an UTF16 string.

Parameters
utf16ArrayThe UTF-16 characters array.
Returns
true if successful, if conversion fails this String contains the already converted characters and false is returned.

◆ SetUTF16Chars() [2/2]

Bool Murl::String::SetUTF16Chars ( const UInt16 utf16Array)

Set UTF-8 characters from an UTF16 string pointer.

Parameters
utf16ArrayA pointer to the zero-terminated UTF16 characters.
Returns
true if successful, if conversion fails this String contains the already converted characters and false is returned.

◆ SetUTF32Chars() [1/2]

Bool Murl::String::SetUTF32Chars ( const UInt32Array utf32Array)

Set UTF-8 characters from an UTF32 string.

Parameters
utf32ArrayThe UTF-32 characters array.
Returns
true if successful, if conversion fails this String contains the already converted characters and false is returned.

◆ SetUTF32Chars() [2/2]

Bool Murl::String::SetUTF32Chars ( const UInt32 utf32Array)

Set UTF-8 characters from an UTF32 string pointer.

Parameters
utf32ArrayA pointer to the zero-terminated UTF32 characters.
Returns
true if successful, if conversion fails this String contains the already converted characters and false is returned.

◆ Cat() [1/9]

String& Murl::String::Cat ( const StringArray stringArray)
inline

Append all strings from an string array.

Parameters
stringArrayThe string array to append.
Returns
The string itself.

References Murl::Array< DataType >::GetCount().

◆ RemoveLastUTF8()

Bool Murl::String::RemoveLastUTF8 ( )

Remove the last character from the string including UTF-8.

Returns
true if successful, false is string is empty.

◆ GetChar()

Char Murl::String::GetChar ( SInt32  pos) const
inline

Get a character at a specified position.

Verify (assert in debug build) 'pos' against the string length.

Parameters
posThe byte position to get the character from.
Returns
The character at the specified position, or 0 if the position is out of range.

References MURL_VERIFY.

◆ Set() [1/3]

Bool Murl::String::Set ( SInt32  pos,
Char  charCode 
)
inline

Set a character.

Verify (assert in debug build) 'pos' against the string length.

Parameters
posThe byte position.
charCodeThe character code to set.
Returns
true if successful.

References MURL_VERIFY.

◆ Set() [2/3]

void Murl::String::Set ( const String str)
inline

Set to a given string.

Parameters
strThe string to set.

◆ Set() [3/3]

void Murl::String::Set ( const Char str,
SInt32  length 
)

Set to a given string and length.

Parameters
strThe string to copy.
lengthThe number of bytes to copy.

◆ Insert() [1/4]

Bool Murl::String::Insert ( SInt32  pos,
Char  charCode 
)
inline

Insert a character.

Parameters
posThe byte position to insert.
charCodeThe character code to insert.
Returns
true if successful.

◆ Insert() [2/4]

Bool Murl::String::Insert ( SInt32  pos,
const Char str,
SInt32  count 
)
inline

Insert a C-string & length.

Parameters
posThe byte position to insert.
strThe C-string to insert.
countThe number of bytes to insert.
Returns
true if successful.

◆ Insert() [3/4]

Bool Murl::String::Insert ( SInt32  pos,
const String str 
)
inline

Insert a string.

Parameters
posThe byte position to insert.
strThe string to insert.
Returns
true if successful.

References GetLength().

◆ Insert() [4/4]

Bool Murl::String::Insert ( SInt32  pos,
const Char str 
)
inline

Insert a C-string.

Parameters
posThe byte position to insert.
strThe C-string to insert.
Returns
true if successful.

◆ Remove()

Bool Murl::String::Remove ( SInt32  pos,
SInt32  count = 1 
)

Remove character(s).

Verify (assert in debug build) 'pos' and 'count' against the string length.

Parameters
posThe byte position to remove.
countThe number of characters to remove.
Returns
true if successful.

◆ RemoveChar()

SInt32 Murl::String::RemoveChar ( Char  character)

Remove all occurrences of a character.

Parameters
characterThe character to remove.
Returns
The number of characters removed.

◆ Cat() [2/9]

String& Murl::String::Cat ( const Char str)
inline

Append a C-string.

Parameters
strThe C-string to append.
Returns
The string itself.

◆ Cat() [3/9]

String& Murl::String::Cat ( const String str)
inline

Append a string.

Parameters
strThe string to append.
Returns
The string itself.

References Begin(), and GetLength().

◆ Cat() [4/9]

String& Murl::String::Cat ( Char  charCode,
SInt32  count 
)

Append characters.

Parameters
charCodeThe character code to append.
countThe number of characters to append.
Returns
The string itself.

◆ Cat() [5/9]

String& Murl::String::Cat ( const String str,
SInt32  length 
)
inline

Append from a given string and length.

Parameters
strThe string to append.
lengthThe number of bytes to copy.
Returns
The string itself.

References Begin().

◆ Cat() [6/9]

String& Murl::String::Cat ( const UInt8 str,
SInt32  length 
)
inline

Append from a given byte pointer and length.

Parameters
strThe byte pointer to append.
lengthThe number of bytes to copy.
Returns
The string itself.

◆ Cat() [7/9]

String& Murl::String::Cat ( )
inline

Get a reference of the string.

Returns
The string reference.

◆ Cat() [8/9]

String& Murl::String::Cat ( Char  charCode)
inline

Append a character.

Parameters
charCodeThe character code to append.
Returns
The string itself.

◆ Cat() [9/9]

String& Murl::String::Cat ( const Char str,
SInt32  length 
)

Append from a given C-string & length.

Parameters
strThe C-string to append.
lengthThe number of bytes to copy.
Returns
The string itself.

◆ Mid() [1/3]

String Murl::String::Mid ( SInt32  from,
SInt32  count 
) const

Get a substring copy.

Parameters
fromThe byte position to start.
countthe number of bytes to copy.
Returns
The substring.

◆ Mid() [2/3]

String Murl::String::Mid ( const String startDelimiter,
const String endDelimiter,
Bool  isStartOptional = true,
Bool  isEndOptional = true 
) const

Get a substring copy using delimiters.

Parameters
startDelimiterThe start delimiter string.
endDelimiterThe end delimiter string.
isStartOptionalfalse if start delimiter is required to be found.
isEndOptionalfalse if end delimiter is required to be found.
Returns
The substring, or an empty string is a required limiter is not found.

◆ Mid() [3/3]

String Murl::String::Mid ( SInt32  from) const
inline

Get a substring copy.

Parameters
fromThe byte position to start.
Returns
The substring.

◆ Right()

String Murl::String::Right ( SInt32  count) const
inline

Get a substring from the right.

Parameters
countNumber of bytes to copy.
Returns
The substring.

◆ Left()

String Murl::String::Left ( SInt32  count) const
inline

Get a substring from the left.

Parameters
countNumber of bytes to copy.
Returns
The substring.

◆ Replace() [1/5]

UInt32 Murl::String::Replace ( const Char find,
SInt32  findLen,
const Char replace,
SInt32  replaceLen 
)

Find any occurrence of a C-string & length and replace each occurrence by a C-string & length.

Parameters
findThe C-string to find.
findLenThe number of bytes to find.
replaceThe C-string to replace.
replaceLenThe number of bytes to replace.
Returns
The number of replaced occurrences.

◆ Replace() [2/5]

UInt32 Murl::String::Replace ( const String find,
const String replace 
)
inline

Find any occurrence of a string and replace each occurrence by a string.

Parameters
findThe string to find.
replaceThe string to replace.
Returns
The number of replaced occurrences.

References Begin(), and GetLength().

◆ Replace() [3/5]

UInt32 Murl::String::Replace ( const Char find,
const Char replace 
)
inline

Find any occurrence of a C-string and replace each occurrence by a C-string.

Parameters
findThe C-string to find.
replaceThe C-string to replace.
Returns
The number of replaced occurrences.

◆ Replace() [4/5]

UInt32 Murl::String::Replace ( const String find,
const Char replace 
)
inline

Find any occurrence of a string and replace each occurrence by a C-string.

Parameters
findThe string to find.
replaceThe C-string to replace.
Returns
The number of replaced occurrences.

References Begin(), and GetLength().

◆ Replace() [5/5]

UInt32 Murl::String::Replace ( const Char find,
const String replace 
)
inline

Find any occurrence of a C-string and replace each occurrence by a string.

Parameters
findThe C-string to find.
replaceThe string to replace.
Returns
The number of replaced occurrences.

References Begin(), Murl::Util::Find(), and GetLength().

◆ Find() [1/4]

SInt32 Murl::String::Find ( Char  charCode,
SInt32  from = 0 
) const

Find a character.

Verify (assert in debug build) 'from' against the string length.

Parameters
charCodeThe character to find.
fromThe byte position to start.
Returns
The byte position of the character or -1 if not found.

Referenced by Murl::AttributeInfo::GetNameById().

◆ Find() [2/4]

SInt32 Murl::String::Find ( SInt32  length,
const Char str,
SInt32  from 
) const

Find a C-string & length.

Verify (assert in debug build) 'from' against the string length.

Parameters
lengthThe number of bytes to find.
strThe C-string to find.
fromThe byte position to start.
Returns
The byte position of the string or -1 if not found.

◆ Find() [3/4]

SInt32 Murl::String::Find ( const Char str,
SInt32  from = 0 
) const
inline

Find a C-string.

Parameters
strThe C-string to find.
fromThe byte position to start.
Returns
The byte position of the string or -1 if not found.

References Murl::Util::Find().

◆ Find() [4/4]

SInt32 Murl::String::Find ( const String str,
SInt32  from = 0 
) const
inline

Find a string.

Parameters
strThe string to find.
fromThe byte position to start.
Returns
The byte position of the string or -1 if not found.

References Begin(), Murl::Util::Find(), and GetLength().

◆ ReverseFind() [1/7]

SInt32 Murl::String::ReverseFind ( Char  charCode,
SInt32  from 
) const

Find a character from right to left.

Verify (assert in debug build) 'from' against the string length.

Parameters
charCodeThe character to find.
fromThe byte position to start.
Returns
The byte position of the character or -1 if not found.

◆ ReverseFind() [2/7]

SInt32 Murl::String::ReverseFind ( Char  charCode) const
inline

Find a character from right to left.

Parameters
charCodeThe character to find.
Returns
The byte position of the character or -1 if not found.

◆ ReverseFind() [3/7]

SInt32 Murl::String::ReverseFind ( SInt32  length,
const Char str,
SInt32  from 
) const

Find a C-string & length from right to left at position.

Verify (assert in debug build) 'from' against the string length.

Parameters
lengthThe number of bytes to find.
strThe C-string to find.
fromThe byte position to start.
Returns
The byte position of the character or -1 if not found.

◆ ReverseFind() [4/7]

SInt32 Murl::String::ReverseFind ( const Char str,
SInt32  from 
) const
inline

Find a C-string from right to left at position.

Parameters
strThe C-string to find.
fromThe byte position to start.
Returns
The byte position of the string or -1 if not found.

◆ ReverseFind() [5/7]

SInt32 Murl::String::ReverseFind ( const String str,
SInt32  from 
) const
inline

Find a string from right to left at position.

Parameters
strThe string to find.
fromThe byte position to start.
Returns
The byte position of the string or -1 if not found.

References Begin(), and GetLength().

◆ ReverseFind() [6/7]

SInt32 Murl::String::ReverseFind ( const Char str) const
inline

Find a C-string from right to left.

Parameters
strThe C-string to find.
Returns
The byte position of the string or -1 if not found.

◆ ReverseFind() [7/7]

SInt32 Murl::String::ReverseFind ( const String str) const
inline

Find a string from right to left.

Parameters
strThe string to find.
Returns
The byte position of the string or -1 if not found.

◆ FindFirstOf() [1/3]

SInt32 Murl::String::FindFirstOf ( SInt32  length,
const Char str,
SInt32  from 
) const

Find first character from a character set C-string & length.

Verify (assert in debug build) 'from' against the string length.

Parameters
lengthThe number of bytes in the C-string.
strThe character set C-string.
fromThe byte position to start.
Returns
The byte position of a matching character or -1 if not found.

◆ FindFirstOf() [2/3]

SInt32 Murl::String::FindFirstOf ( const Char str,
SInt32  from = 0 
) const
inline

Find first character from a character set C-string.

Parameters
strThe character set C-string.
fromThe byte position to start.
Returns
The byte position of a matching character or -1 if not found.

◆ FindFirstOf() [3/3]

SInt32 Murl::String::FindFirstOf ( const String str,
SInt32  from = 0 
) const
inline

Find first character from a character set string.

Parameters
strThe character set string.
fromThe byte position to start.
Returns
The byte position of a matching character or -1 if not found.

References Begin(), and GetLength().

◆ FindFirstNotOf() [1/3]

SInt32 Murl::String::FindFirstNotOf ( SInt32  length,
const Char str,
SInt32  from 
) const

Find the first character not matching any of the characters in a given set.

Verify (assert in debug build) 'from' against the string length.

Parameters
lengthThe number of bytes in the given C-string character set.
strThe character set C-string.
fromThe byte position to start.
Returns
The byte position of the first non-matching character or -1 if not found.

◆ FindFirstNotOf() [2/3]

SInt32 Murl::String::FindFirstNotOf ( const Char str,
SInt32  from = 0 
) const
inline

Find the first character not matching any of the characters in a given set.

Parameters
strThe character set C-string.
fromThe byte position to start.
Returns
The byte position of a matching character or -1 if not found.

◆ FindFirstNotOf() [3/3]

SInt32 Murl::String::FindFirstNotOf ( const String str,
SInt32  from = 0 
) const
inline

Find the first character not matching any of the characters in a given set.

Parameters
strThe character set string.
fromThe byte position to start.
Returns
The byte position of a matching character or -1 if not found.

References Begin(), and GetLength().

◆ StartsWith() [1/3]

Bool Murl::String::StartsWith ( const Char str,
SInt32  length 
) const
inline

Check if the start matches a C-string & length.

Parameters
strThe C-string to match.
lengthThe number of bytes to match.
Returns
true if the start matches the string.

References Murl::System::CLib::MemCompare().

◆ StartsWith() [2/3]

Bool Murl::String::StartsWith ( const Char str) const
inline

Check if the start matches a C-string.

Parameters
strThe C-string to match.
Returns
true if the start matches the string.

◆ StartsWith() [3/3]

Bool Murl::String::StartsWith ( const String str) const
inline

Check if the start matches a string.

Parameters
strThe string to match.
Returns
true if the start matches the string.

References Begin(), and GetLength().

◆ EndsWith() [1/3]

Bool Murl::String::EndsWith ( const Char str,
SInt32  length 
) const
inline

Check if the end matches a C-string & length.

Parameters
strThe C-string to match.
lengthThe number of bytes to match.
Returns
true if the end matches the string.

References Murl::System::CLib::MemCompare().

◆ EndsWith() [2/3]

Bool Murl::String::EndsWith ( const Char str) const
inline

Check if the end matches a C-string.

Parameters
strThe C-string to match.
Returns
true if the end matches the string.

◆ EndsWith() [3/3]

Bool Murl::String::EndsWith ( const String str) const
inline

Check if the end matches a string.

Parameters
strThe string to match.
Returns
true if the end matches the string.

References Begin(), and GetLength().

◆ Compare() [1/2]

SInt32 Murl::String::Compare ( const Char str) const

Compare a C-string.

Parameters
strThe C-string to compare.
Returns
return -1 if lower, 0 if equal, 1 if greater.

◆ Compare() [2/2]

SInt32 Murl::String::Compare ( const String str) const
inline

Compare a string.

Parameters
strThe string to compare.
Returns
return -1 if lower, 0 if equal, 1 if greater.

◆ IsEqual() [1/2]

Bool Murl::String::IsEqual ( const Char str) const
inline

Check if a C-string is equal.

Parameters
strThe C-string to compare.
Returns
return true if equal.

◆ IsEqual() [2/2]

Bool Murl::String::IsEqual ( const String str) const
inline

Check if a string is equal.

Parameters
strThe string to compare.
Returns
return true if equal.

◆ GetHashValue()

UInt32 Murl::String::GetHashValue ( ) const

Calculate the string hash value.

Returns
The hash value.

◆ GetAlloc()

SInt32 Murl::String::GetAlloc ( ) const
inline

Get the number of allocated bytes for characters, excluding the zero terminator.

Returns
The number of allocated bytes for characters.

◆ GetLength()

SInt32 Murl::String::GetLength ( ) const
inline

Get number of byte characters.

Returns
The number of byte characters.

Referenced by Cat(), EndsWith(), Find(), FindFirstNotOf(), FindFirstOf(), Insert(), Murl::ConstData::operator==(), Replace(), ReverseFind(), StartsWith(), and String().

◆ IsEmpty()

◆ ToString()

const String& Murl::String::ToString ( ) const
inline

Get a const reference of the string.

Convenience method for Lua scripting support.

Returns
The string reference.

◆ Begin()

◆ End()

const Char* Murl::String::End ( ) const
inline

Get the pointer to the end of the string.

Returns
The read-only pointer to end of the string.

◆ Last()

const Char* Murl::String::Last ( ) const
inline

Get the pointer to the last character.

Returns
The read-only pointer to the last character.

◆ operator const Char *()

Murl::String::operator const Char * ( ) const
inline

Conversion operator to C-string.

Returns
The pointer to the C-string.

◆ operator const UInt8 *()

Murl::String::operator const UInt8 * ( ) const
inline

Conversion operator to byte pointer.

Returns
The byte pointer to the Begin().

◆ operator const void *()

Murl::String::operator const void * ( ) const
inline

Conversion operator to void pointer.

Returns
The void pointer to the Begin().

◆ operator[]()

Char Murl::String::operator[] ( SInt32  pos) const
inline

The array operator.

Verify (assert in debug build) 'pos' against the string length.

Parameters
posThe character byte position.
Returns
The character at the specified position, if the position is out of range 0 is returned.

References MURL_VERIFY.

◆ operator*()

Char Murl::String::operator* ( ) const
inline

Indirection operator.

Returns
The first character.

◆ operator=() [1/2]

String& Murl::String::operator= ( const Char str)
inline

Assignment operator for C-string.

Parameters
strThe C-string to assign.
Returns
The object itself.

References Murl::System::CLib::Free().

◆ operator=() [2/2]

String& Murl::String::operator= ( const String str)
inline

Assignment operator for string.

Parameters
strThe string to assign.
Returns
The object itself.

◆ operator+=() [1/11]

const String& Murl::String::operator+= ( Char  chr)
inline

In-place addition operator for a character.

Parameters
chrThe character to add.
Returns
The object itself.

◆ operator+=() [2/11]

const String& Murl::String::operator+= ( const Char str)
inline

In-place addition operator for const C-string.

Parameters
strThe C-string to add.
Returns
The string itself.

◆ operator+=() [3/11]

const String& Murl::String::operator+= ( const String str)
inline

In-place addition operator for string.

Parameters
strThe string to add.
Returns
The string itself.

◆ operator+=() [4/11]

const String& Murl::String::operator+= ( UInt64  value)

In-place addition operator for UInt64.

Parameters
valueThe value to add.
Returns
The string itself.

◆ operator+=() [5/11]

const String& Murl::String::operator+= ( SInt64  value)

In-place addition operator for SInt64.

Parameters
valueThe value to add.
Returns
The string itself.

◆ operator+=() [6/11]

const String& Murl::String::operator+= ( UInt32  value)

In-place addition operator for UInt32.

Parameters
valueThe value to add.
Returns
The string itself.

◆ operator+=() [7/11]

const String& Murl::String::operator+= ( SInt32  value)

In-place addition operator for SInt32.

Parameters
valueThe value to add.
Returns
The string itself.

◆ operator+=() [8/11]

const String& Murl::String::operator+= ( Double  value)

In-place addition operator for Double.

Parameters
valueThe value to add.
Returns
The string itself.

◆ operator+=() [9/11]

const String& Murl::String::operator+= ( const Color value)

In-place addition operator for Color.

Parameters
valueThe value to add.
Returns
The string itself.

◆ operator+=() [10/11]

const String& Murl::String::operator+= ( Bool  value)

In-place addition operator for Bool.

Parameters
valueThe value to add.
Returns
The string itself.

◆ operator+=() [11/11]

const String& Murl::String::operator+= ( const System::Time value)

In-place addition operator for Color.

Parameters
valueThe value to add.
Returns
The string itself.

◆ Swap()

void Murl::String::Swap ( String other)

Exchange the content of the string with a given second one.

Parameters
otherThe second string.

Friends And Related Function Documentation

◆ operator+ [1/13]

String operator+ ( const String lhs,
const String rhs 
)
friend

Addition operator for string and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side string.
Returns
The concatenated string.

◆ operator+ [2/13]

String operator+ ( const String lhs,
const Char rhs 
)
friend

Addition operator for string and C-string.

Parameters
lhsThe left hand side string.
rhsThe right hand side C-string.
Returns
The concatenated string.

◆ operator+ [3/13]

String operator+ ( const Char lhs,
const String rhs 
)
friend

Addition operator for C-string and string.

Parameters
lhsThe left hand side C-string.
rhsThe right hand side string.
Returns
The concatenated string.

◆ operator+ [4/13]

String operator+ ( const String lhs,
Char  rhs 
)
friend

Addition operator for string and character.

Parameters
lhsThe left hand side string.
rhsThe right hand side character.
Returns
The concatenated string.

◆ operator+ [5/13]

String operator+ ( Char  lhs,
const String rhs 
)
friend

Addition operator for character and string.

Parameters
lhsThe left hand side character.
rhsThe right hand side string.
Returns
The concatenated string.

◆ operator+ [6/13]

String operator+ ( const String lhs,
UInt64  rhs 
)
friend

Addition operator for UInt64 and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator+ [7/13]

String operator+ ( const String lhs,
SInt64  rhs 
)
friend

Addition operator for SInt64 and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator+ [8/13]

String operator+ ( const String lhs,
UInt32  rhs 
)
friend

Addition operator for UInt32 and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator+ [9/13]

String operator+ ( const String lhs,
SInt32  rhs 
)
friend

Addition operator for SInt32 and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator+ [10/13]

String operator+ ( const String lhs,
Double  rhs 
)
friend

Addition operator for Double and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator+ [11/13]

String operator+ ( const String lhs,
const Color rhs 
)
friend

Addition operator for Color and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator+ [12/13]

String operator+ ( const String lhs,
Bool  rhs 
)
friend

Addition operator for Bool and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator+ [13/13]

String operator+ ( const String lhs,
const System::Time rhs 
)
friend

Addition operator for Time and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side variable.
Returns
The concatenated string.

◆ operator< [1/3]

bool operator< ( const String lhs,
const String rhs 
)
friend

Less than operator for string and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side string.
Returns
true if the left hand string is less than the right hand string.

◆ operator< [2/3]

bool operator< ( const String lhs,
const Char rhs 
)
friend

Less than operator for string and C-string.

Parameters
lhsThe left hand side string.
rhsThe right hand side C-string.
Returns
true if the left hand string is less than the right hand string.

◆ operator< [3/3]

bool operator< ( const Char lhs,
const String rhs 
)
friend

Less than operator for C-string and string.

Parameters
lhsThe left hand side C-string.
rhsThe right hand side string.
Returns
true if the left hand string is less than the right hand string.

◆ operator<= [1/3]

bool operator<= ( const String lhs,
const String rhs 
)
friend

Less than or equal to operator for string and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side string.
Returns
true if the left hand string is less than or equal to the right hand string.

◆ operator<= [2/3]

bool operator<= ( const String lhs,
const Char rhs 
)
friend

Less than or equal to operator for string and C-string.

Parameters
lhsThe left hand side string.
rhsThe right hand side C-string.
Returns
true if the left hand string is less than or equal to the right hand string.

◆ operator<= [3/3]

bool operator<= ( const Char lhs,
const String rhs 
)
friend

Less than or equal to operator for C-string and string.

Parameters
lhsThe left hand side C-string.
rhsThe right hand side string.
Returns
true if the left hand string is less than or equal to the right hand string.

◆ operator> [1/3]

bool operator> ( const String lhs,
const String rhs 
)
friend

Greater than operator for string and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side string.
Returns
true if the left hand string is greater than the right hand string.

◆ operator> [2/3]

bool operator> ( const String lhs,
const Char rhs 
)
friend

Greater than operator for string and C-string.

Parameters
lhsThe left hand side string.
rhsThe right hand side C-string.
Returns
true if the left hand string is greater than the right hand string.

◆ operator> [3/3]

bool operator> ( const Char lhs,
const String rhs 
)
friend

Greater than operator for C-string and string.

Parameters
lhsThe left hand side C-string.
rhsThe right hand side string.
Returns
true if the left hand string is greater than the right hand string.

◆ operator>= [1/3]

bool operator>= ( const String lhs,
const String rhs 
)
friend

Greater than or equal to operator for string and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side string.
Returns
true if the left hand string is greater than or equal to the right hand string.

◆ operator>= [2/3]

bool operator>= ( const String lhs,
const Char rhs 
)
friend

Greater than or equal to operator for string and C-string.

Parameters
lhsThe left hand side string.
rhsThe right hand side C-string.
Returns
true if the left hand string is greater than or equal to the right hand string.

◆ operator>= [3/3]

bool operator>= ( const Char lhs,
const String rhs 
)
friend

Greater than or equal to operator for C-string and string.

Parameters
lhsThe left hand side C-string.
rhsThe right hand side string.
Returns
true if the left hand string is greater than or equal to the right hand string.

◆ operator== [1/3]

bool operator== ( const String lhs,
const String rhs 
)
friend

Equal to comparison operator for string and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side string.
Returns
true if the strings are equal.

◆ operator== [2/3]

bool operator== ( const String lhs,
const Char rhs 
)
friend

Equal to comparison operator for string and C-string.

Parameters
lhsThe left hand side string.
rhsThe right hand side C-string.
Returns
true if the strings are equal.

◆ operator== [3/3]

bool operator== ( const Char lhs,
const String rhs 
)
friend

Equal to comparison operator for C-string and string.

Parameters
lhsThe left hand side C-string.
rhsThe right hand side string.
Returns
true if the strings are equal.

◆ operator!= [1/3]

bool operator!= ( const String lhs,
const String rhs 
)
friend

Not equal to comparison operator for string and string.

Parameters
lhsThe left hand side string.
rhsThe right hand side string.
Returns
true if the strings are not equal.

◆ operator!= [2/3]

bool operator!= ( const String lhs,
const Char rhs 
)
friend

Not equal to comparison operator for string and C-string.

Parameters
lhsThe left hand side string.
rhsThe right hand side C-string.
Returns
true if the strings are not equal.

◆ operator!= [3/3]

bool operator!= ( const Char lhs,
const String rhs 
)
friend

Not equal to comparison operator for C-string and string.

Parameters
lhsThe left hand side C-string.
rhsThe right hand side string.
Returns
true if the strings are not equal.

The documentation for this class was generated from the following file:
  • murl_string.h


Copyright © 2011-2018 Spraylight GmbH.