![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
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
Construct an empty string.
Murl.String new()
Construct and fill a string with a given character and length.
Murl.String new(Char charCode, Integer length)
charCode | The character code to fill. |
length | The number of bytes to fill. |
Construct using a given string.
Murl.String new(String str)
str | The original string. |
Construct a copy of a given string and length. Verify (assert in debug build) 'length' against the length of 'str'.
Murl.String new(String str, Integer length)
str | The string to copy. |
length | The number of bytes to copy. |
Clear the string and remove the underlying storage.
Clear()
Shrink the string so that the underlying storage is only as large as necessary.
Shrink()
Reserve additional storage space.
Boolean Reserve(Integer count)
count | The number of additional bytes to reserve. |
Cut the string on a given position. Verify (assert in debug build) 'pos' against the string length.
pos | The position to cut the string. |
Trim white spaces from left and right.
String Trim()
Trim white spaces from left.
String TrimLeft()
Trim white spaces from right.
String TrimRight()
Get the lower case string including UTF-8 characters.
String ToLowerUTF8()
Get the upper case string including UTF-8 characters.
String ToUpperUTF8()
Count the number of UTF-8 characters.
Integer GetLengthUTF8()
Get a UTF-8 character at a specified position. Verify (assert in debug build) 'pos' against the string length.
String GetUTF8Char(Integer pos)
pos | The byte position to get the character from. |
Get the UTF-8 characters.
Murl.Array.String GetUTF8Chars()
Get the wide-characters.
Murl.Array.WChar GetWChars()
Get the wide-characters and success status.
Boolean, Murl.Array.WChar GetWChars(Murl.Array.WChar wcharArray)
wcharArray | The wide-characters array return value. |
Get the UTF-16 characters.
Murl.Array.UInt16 GetUTF16Chars()
Get the UTF-16 characters and success status.
Boolean, Murl.Array.UInt16 GetUTF16Chars(Murl.Array.UInt16 utf16Array)
utf16Array | The UTF-16 characters array return value. |
Get the UTF-32 characters.
Murl.Array.UInt32 GetUTF32Chars()
Get the UTF-32 characters and success status.
Boolean, Murl.Array.UInt32 GetUTF32Chars(Murl.Array.UInt32 utf32Array)
utf32Array | The UTF-32 characters array return value. |
Set UTF-8 characters from a wide-character string.
Boolean SetWChars(Murl.Array.WChar wcharArray)
wcharArray | The wide-characters array. |
Set UTF-8 characters from an UTF16 string.
Boolean SetUTF16Chars(Murl.Array.UInt16 utf16Array)
utf16Array | The UTF-16 characters array. |
Set UTF-8 characters from an UTF32 string.
Boolean SetUTF32Chars(Murl.Array.UInt32 utf32Array)
utf32Array | The UTF-32 characters array. |
Get a reference of the string.
String Cat()
Append a character.
charCode | The character code to append. |
Append characters.
String Cat(Char charCode, Integer count)
charCode | The character code to append. |
count | The number of characters to append. |
Append a string.
str | The string to append. |
Append from a given string and length.
String Cat(String str, Integer length)
str | The string to append. |
length | The number of bytes to copy. |
Append all strings from an string array.
String Cat(Murl.Array.String stringArray)
stringArray | The string array to append. |
Remove the last character from the string including UTF-8.
Boolean RemoveLastUTF8()
Get a character at a specified position. Verify (assert in debug build) 'pos' against the string length.
pos | The byte position to get the character from. |
Set a character. Verify (assert in debug build) 'pos' against the string length.
Boolean Set(Integer pos, Char charCode)
pos | The byte position. |
charCode | The character code to set. |
Set to a given string.
Set(String str)
str | The string to set. |
Set to a given string and length.
Set(String str, Integer length)
str | The string to copy. |
length | The number of bytes to copy. |
Insert a character.
Boolean Insert(Integer pos, Char charCode)
pos | The byte position to insert. |
charCode | The character code to insert. |
Insert a string.
Boolean Insert(Integer pos, String str)
pos | The byte position to insert. |
str | The string to insert. |
Insert a C-string & length.
Boolean Insert(Integer pos, String str, Integer count)
pos | The byte position to insert. |
str | The C-string to insert. |
count | The number of bytes to insert. |
Remove character(s). Verify (assert in debug build) 'pos' and 'count' against the string length.
Boolean Remove(Integer pos, Integer count)
pos | The byte position to remove. |
count | The number of characters to remove. |
Remove all occurrences of a character.
Integer RemoveChar(Char character)
character | The character to remove. |
Get a substring copy.
from | The byte position to start. |
Get a substring copy.
String Mid(Integer from, Integer count)
from | The byte position to start. |
count | the number of bytes to copy. |
Get a substring copy using delimiters.
String Mid(String startDelimiter, String endDelimiter, Boolean isStartOptional, Boolean isEndOptional)
startDelimiter | The start delimiter string. |
endDelimiter | The end delimiter string. |
isStartOptional | false if start delimiter is required to be found. |
isEndOptional | false if end delimiter is required to be found. |
Get a substring from the right.
count | Number of bytes to copy. |
Get a substring from the left.
count | Number of bytes to copy. |
Find any occurrence of a C-string & length and replace each occurrence by a C-string & length.
Integer Replace(String find, Integer findLen, String replace, Integer replaceLen)
find | The C-string to find. |
findLen | The number of bytes to find. |
replace | The C-string to replace. |
replaceLen | The number of bytes to replace. |
Find any occurrence of a string and replace each occurrence by a string.
Integer Replace(String find, String replace)
find | The string to find. |
replace | The string to replace. |
Find a C-string & length. Verify (assert in debug build) 'from' against the string length.
Integer Find(Integer length, String str, Integer from)
length | The number of bytes to find. |
str | The C-string to find. |
from | The byte position to start. |
Find a character. Verify (assert in debug build) 'from' against the string length.
Integer Find(Char charCode, Integer from)
charCode | The character to find. |
from | The byte position to start. |
Find a C-string.
Integer Find(String str, Integer from)
str | The C-string to find. |
from | The byte position to start. |
Find a C-string & length from right to left at position. Verify (assert in debug build) 'from' against the string length.
Integer ReverseFind(Integer length, String str, Integer from)
length | The number of bytes to find. |
str | The C-string to find. |
from | The byte position to start. |
Find a character from right to left.
Integer ReverseFind(Char charCode)
charCode | The character to find. |
Find a character from right to left. Verify (assert in debug build) 'from' against the string length.
Integer ReverseFind(Char charCode, Integer from)
charCode | The character to find. |
from | The byte position to start. |
Find a C-string from right to left.
Integer ReverseFind(String str)
str | The C-string to find. |
Find a C-string from right to left at position.
Integer ReverseFind(String str, Integer from)
str | The C-string to find. |
from | The byte position to start. |
Find first character from a character set C-string & length. Verify (assert in debug build) 'from' against the string length.
Integer FindFirstOf(Integer length, String str, Integer from)
length | The number of bytes in the C-string. |
str | The character set C-string. |
from | The byte position to start. |
Find first character from a character set C-string.
Integer FindFirstOf(String str, Integer from)
str | The character set C-string. |
from | The byte position to start. |
Find the first character not matching any of the characters in a given set. Verify (assert in debug build) 'from' against the string length.
Integer FindFirstNotOf(Integer length, String str, Integer from)
length | The number of bytes in the given C-string character set. |
str | The character set C-string. |
from | The byte position to start. |
Find the first character not matching any of the characters in a given set.
Integer FindFirstNotOf(String str, Integer from)
str | The character set C-string. |
from | The byte position to start. |
Check if the start matches a string.
Boolean StartsWith(String str)
str | The string to match. |
Check if the start matches a C-string & length.
Boolean StartsWith(String str, Integer length)
str | The C-string to match. |
length | The number of bytes to match. |
Check if the end matches a string.
str | The string to match. |
Check if the end matches a C-string & length.
Boolean EndsWith(String str, Integer length)
str | The C-string to match. |
length | The number of bytes to match. |
Compare a string.
str | The string to compare. |
Check if a string is equal.
str | The string to compare. |
Calculate the string hash value.
Integer GetHashValue()
Get the number of allocated bytes for characters, excluding the zero terminator.
Integer GetAlloc()
Get number of byte characters.
Integer GetLength()
Check if the string is empty.
Boolean IsEmpty()
Get a const reference of the string. Convenience method for Lua scripting support.
String ToString()
Get the pointer to the first character.
String Begin()
Get the pointer to the end of the string.
String End()
Get the pointer to the last character.
String Last()
Exchange the content of the string with a given second one.
other | The second string. |
The length operator is denoted by the unary prefix operator #.
Converts the object content to a string in a reasonable format.
The array operator. Verify (assert in debug build) 'pos' against the string length.
pos | The character byte position. |
Addition operator for character and string.
Addition operator for Double and string.
Addition operator for string and character.
Addition operator for string and string.
Addition operator for Bool and string.
Addition operator for Color and string.
Addition operator for Time and string.
Less than operator for string and string.
Less than or equal to operator for string and string.
Equal to comparison operator for string and string.