Class Reference string

The string class provides a Unicode character string. More...

Member

string( )
string(string item)
bool contains(string item)
int indexOf(string str, int index)
int lastIndexOf(string str, int index)
string left(int left)
sint length()
string mid(int position, int length=-1)
string parameter(string str)
string remove(string str)
string replace(string macht,string with)
string right(int right)
string setDate(string format="")
string setDateTime(string format="")
string setEng(double value)
string setHex(int hex-number)
string setNum(double value, int precision)
string setNum(int number)
string setTime(string format="")
int size()
stringList split(string s)
double toDouble()
double toDoubleFromEng()
int toInt()
istring toLower()
istring toUpper()
string trimmed()

Detailed Description

The string class provides a Unicode character string. In scripting interfaces this class will be mapped to build in string types.

Member Function Documentation


string::string( )

Creates a new empty string-


string::string(string item)

Creates a string containing a copy of item.


bool string::contains(string item)

Returns: true, if the string contains the string item. Otherwise false is returned.


int string::indexOf(string str, int index)

Returns: Returns the index position of the first occurrence of the string str in this string, searching forward from index position. Returns -1 if str is not found.


int string::lastIndexOf(string str, int index)

Returns: Returns the index position of the last occurrence of the string str in this string, searching backward from index position from. If from is -1, the search starts at the last character; if from is -2, at the next to last character and so on. Returns -1 ,if str is not found.


string string::left(int left)

Returns: the left chars of the string


sint string::length()

Returns: length of the string, identical with size


string string::mid(int position, int length=-1)

Returns: length a path of the string starting at position with the length. The rest of the string starting at position is returned if length is -1 or missing.


string string::parameter(string str)

Returns: the parameter str. Example:

string s="type=2 width=4 length=6";
s=s.parameter("width");
// s="4";

string string::remove(string str)

Remove all str from the string. The removement is case sensitive.


string string::replace(string macht,string with)

All existing strings match is replaced with with. The replacement is case sensitive.


string string::right(int right)

Returns: the right chars of the string (introduced with release 20180610)


string string::setDate(string format="")

Set the string to the current date. With the string format the format can be set. Without the string the date is set to local setup. setDateTime for possible formats


string string::setDateTime(string format="")

Set the string to the current date and time. With the string format the format can be set. Without the string the date is set to local setup.

The format string may contain:

Expression Output
d the day as number without a leading zero (1 to 31)
dd the day as number with a leading zero (01 to 31)
ddd the abbreviated localized day name (e.g. 'Mon' to 'Sun').
dddd the long localized day name (e.g. 'Qt::Monday' to 'Qt::Sunday').
M the month as number without a leading zero (1-12)
MM the month as number with a leading zero (01-12)
MMM the abbreviated localized month name (e.g. 'Jan' to 'Dec').
MMMM the long localized month name (e.g. 'January' to 'December').
yy the year as two digit number (00-99)
yyyy the year as four digit number (1752-8000)
h the hour without a leading zero (0 to 23 or 1 to 12 if AM/PM display)
hh the hour with a leading zero (00 to 23 or 01 to 12 if AM/PM display)
m the minute without a leading zero (0 to 59)
mm the minute with a leading zero (00 to 59)
s the second without a leading zero (0 to 59)
ss the second with a leading zero (00 to 59)
z the milliseconds without leading zeroes (0 to 999)
zzz the milliseconds with leading zeroes (000 to 999)
AP use AM/PM display. AP will be replaced by either "AM" or "PM".
ap use am/pm display. ap will be replaced by either "am" or "pm".

string string::setEng(double value)

Set the string to the number dalue in engineering notation like 10k.


string string::setHex(int hex-number)

Set the string to the hex-number as hexadecimal value. (introduced with version 20180408)


string string::setNum(double value, int precision)

Set the string to the number value with precision digits.


string string::setNum(int number)

Set the string to the number.


string string::setTime(string format="")

Set the string to the current time. With the string format the format can be set. Without the string the date is set to local setup. setDateTime for possible formats


int string::size()

Returns: length of the string (same as length)


stringList string::split(string s)

Returns: The string is spited into a stringList with s as separator char.


double string::toDouble()

Returns: The string is converted to a double.


double string::toDoubleFromEng()

Returns: The string is converted to a double respecting engineering notation like 10.6k, 7.3n, etc.


int string::toInt()

Returns: The string is converted to a integer.


istring string::toLower()

Returns: an lowercase copy of the string. (introduced with release 20180614)


istring string::toUpper()

Returns: an uppercase copy of the string. (introduced with release 20180614)


string string::trimmed()

Returns: A string that has whitespace removed from the start and the end.