String Class Reference
The string class provides a Unicode character string. More...
See also: List of Classes
Member
- string( )
- string(string s)
- contains(string str)
- indexOf(string str, int index)
- lastIndexOf(string str, int index)
- left(int i)
- length()
- mid(int i, int k=-1)
- parameter(string s)
- remove(string str)
- replace(string macht,string with)
- setDate(string format="")
- setDateTime(string format="")
- setEng(double d)
- setNum(double d, int k)
- setNum(int i)
- setTime(string format="")
- size()
- split(string s)
- toDouble()
- toDoubleFromEng()
- toInt()
- 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 string
string::string(string s)
creates a string containing a copy of s. (introduced with version 20170520)
bool string::contains(string str)
Returns: true if the string contains the string str. Otherwise false.
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 from. 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 i)
Returns: the left i char of the string
int string::length()
Returns: length of the string (same as size)
string string::mid(int i, int k=-1)
Returns: length a path of the string starting at position i with the length k. The rest of the string starting at position i is returned if k is -1 or missing.
string string::parameter(string s)
Returns: the parameter str. Example:
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::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 d)
Set the string to the number d in engineering notation like 10k.
string string::setNum(double d, int k)
Set the string to the number d with precision of k
string string::setNum(int i)
Set the string to the number i
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.
string string::trimmed()
Returns: A string that has whitespace removed from the start and the end.