Qore Programming Language Reference Manual
0.8.7
|
Methods in this pseudo-class can be executed on strings. More...
Public Member Functions | |
bool | empty () |
Returns True if the string is empty, False if not. | |
string | encoding () |
Returns the name of the string's character encoding. | |
int | find (softstring substr, softint pos=0) |
Retrieves the character position of a substring within a string. | |
bool | intp () |
Returns True if the string can be converted to an integer, False if not, this depends on the first (or possibly second) character of the string, if it's 0 - 9 (possibly preceded by "-" ), then the method returns True. | |
bool | isDataAscii () |
returns True if the string is empty or has no characters with the high bit set (ie all characters < 128) | |
bool | isDataPrintableAscii () |
returns True if the string is empty or only contains printable non-control ASCII characters (ie all characters > 31 && < 127) | |
int | length () |
Returns the number of characters in the string; may not be equal to the byte length (returned by <string>::strlen() and <string>::size()) for multi-byte character encodings. | |
string | lwr () |
Returns the string in lower case. | |
bool | regex (string regex, int options=0) |
Returns True if the regular expression matches the string passed, otherwise returns False. | |
*list | regexExtract (string regex, int options=0) |
Returns a list of substrings in a string based on matching patterns defined by a regular expression. | |
int | rfind (softstring substr, softint pos=-1) |
Retrieves the character position of a substring within a string, starting the search from the end of the string. | |
int | size () |
Returns the number of bytes in the string (not including the terminating null character ('\0' ) | |
list | split (string sep, bool with_separator=False) |
Splits a string into a list of components based on a separator string. | |
list | split (string sep, string quote, bool trim_unquoted=False) |
Splits a string into a list of components based on a separator string and a quote character. | |
int | strlen () |
Returns the number of bytes in the string (not including the terminating null character ('\0' ) | |
bool | strp () |
Returns True by default. | |
string | substr (softint start) |
Returns a portion of a string starting from an integer offset. | |
string | substr (softint start, softint len) |
Returns a portion of a string starting from an integer offset, with a length parameter. | |
string | toMD5 () |
Returns the MD5 message digest of the string as a hex string. | |
string | toSHA1 () |
Returns the SHA1 message digest of the string as a hex string. | |
string | toSHA224 () |
Returns the SHA-224 message digest (a variant of SHA-2) of the string as a hex string. | |
string | toSHA256 () |
Returns the SHA-256 message digest (a variant of SHA-2) of the string as a hex string. | |
string | toSHA384 () |
Returns the SHA-384 message digest (a variant of SHA-2) of the string as a hex string. | |
string | toSHA512 () |
Returns the SHA-512 message digest (a variant of SHA-2) of the string as a hex string. | |
int | typeCode () |
Returns Qore::NT_STRING. | |
string | upr () |
Returns the string in upper case. | |
bool | val () |
Returns False if the string is empty or has the exact value "0" , True if not (note that if %strict-bool-eval is set, this method returns a boolean value corresponding to the string value after conversion to a numeric value) | |
![]() | |
bool | callp () |
Returns False; this method is reimplemented in other types and will return True if the given expression is a callable value (ie closures or call references) | |
bool | empty () |
Returns True; this method will be reimplemented in container types where it may return False. | |
bool | intp () |
Returns False; this method is reimplemented in other types and will return True if the given expression can be converted to an integer. | |
AbstractIterator | iterator () |
Returns an iterator object for the value; the default iterator object returned is SingleValueIterator. | |
int | lsize () |
Returns 1; the return value of this method should give the list size of the value, which is normally 1 for non-lists (except for NOTHING where the size will be 0) and the number of the elements in the list for lists; this method will be reimplemented in other types where it may return other values. | |
int | size () |
Returns zero; this method will be reimplemented in container types where it may return a non-zero value. | |
bool | strp () |
Returns False; this method is reimplemented in other types and will return True if the given expression can be converted to a string. | |
bool | toBool () |
Returns the boolean representation of the value; the default is False. | |
float | toFloat () |
Returns the floating-point representation of the value; the default is 0.0. | |
int | toInt () |
Returns the integer representation of the value; the default is 0. | |
string | toString () |
Returns the string representation of the value; the default is an empty string. | |
string | type () |
Returns the string type for the value. | |
int | typeCode () |
Returns the type code for the value. | |
bool | val () |
Returns False; this method is reimplemented in other types and will return True if the given expression has a value. | |
Methods in this pseudo-class can be executed on strings.
bool <string>::empty | ( | ) |
string <string>::encoding | ( | ) |
Returns the name of the string's character encoding.
int <string>::find | ( | softstring | substr, |
softint | pos = 0 |
||
) |
Retrieves the character position of a substring within a string.
The pos argument and the return value are in character positions; byte offsets may differ from the character offsets with multi-byte character encodings.
substr | the substring to find in the string; if the character encoding of this string does not match str, then it will be converted to str's character encoding before processing |
pos | the starting character position for the search |
ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion |
INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data |
bool <string>::intp | ( | ) |
Returns True if the string can be converted to an integer, False if not, this depends on the first (or possibly second) character of the string, if it's 0 - 9 (possibly preceded by "-"
), then the method returns True.
"-"
), then the method returns Truebool <string>::isDataAscii | ( | ) |
bool <string>::isDataPrintableAscii | ( | ) |
returns True if the string is empty or only contains printable non-control ASCII characters (ie all characters > 31 && < 127)
int <string>::length | ( | ) |
Returns the number of characters in the string; may not be equal to the byte length (returned by <string>::strlen() and <string>::size()) for multi-byte character encodings.
string <string>::lwr | ( | ) |
Returns the string in lower case.
Returns True if the regular expression matches the string passed, otherwise returns False.
Strings are converted to UTF-8 for pattern-matching; if any invalid encodings are encountered, an ENCODING-CONVERSION-ERROR is raised
regex | the regular expression pattern |
options | regular expression options; see Regular Expression Constants for possible values |
REGEX-COMPILATION-ERROR | There was an error compiling the regular expression |
REGEX-OPTION-ERROR | the option argument contains invalid option bits |
ENCODING-CONVERSION-ERROR | this exception could be thrown if an encoding error is encountered when converting the given strings to UTF-8 |
Returns a list of substrings in a string based on matching patterns defined by a regular expression.
Strings are converted to UTF-8 for pattern-matching; if any invalid encodings are encountered, an ENCODING-CONVERSION-ERROR is raised
regex | the regular expression to use for matching, elements should be given in parentheses |
options | regular expression options; see Regular Expression Constants for possible values |
REGEX-COMPILATION-ERROR | There was an error compiling the regular expression |
REGEX-OPTION-ERROR | the option argument contains invalid option bits |
ENCODING-CONVERSION-ERROR | this exception could be thrown if an encoding error is encountered when converting the given strings to UTF-8 |
int <string>::rfind | ( | softstring | substr, |
softint | pos = -1 |
||
) |
Retrieves the character position of a substring within a string, starting the search from the end of the string.
The pos argument and the return value are in character positions; byte offsets may differ from the character offsets with multi-byte character encodings.
substr | the substring to find in str; if the character encoding of this string does not match str, then it will be converted to str's character encoding before processing |
pos | the starting character position for the search, -1 means start from the end of the string |
ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion |
INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data |
int <string>::size | ( | ) |
Returns the number of bytes in the string (not including the terminating null character ('\0'
)
'\0'
)Splits a string into a list of components based on a separator string.
sep | the separator string; if the separator string is not found in the string to split, then a list with only one element containing the entire string argument is returned'; if this string has a different character encoding than str, then it will be converted to str's character encoding |
with_separator | include the separator string in every element |
ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion |
Splits a string into a list of components based on a separator string and a quote character.
The quote character can appear as the first part of a field, in which case it is assumed to designate the entire field. If instances of the quote character are found in the field preceded by a backquote character ("\"
), then these quote characters are included as part of the field's text and not treated as quote characters. Also the separator character can appear as a part of a field with this variant. This variant is useful for parsing CSV files, for example.
sep | the separator string; if the separator string is not found in the string to split, then a list with only one element containing the entire string argument is returned'; if this string has a different character encoding than str, then it will be converted to str's character encoding |
quote | the quote character |
trim_unquoted | remove leading and trailing whitespace from unquoted fields |
ENCODING-CONVERSION-ERROR | this exception could be thrown if the string arguments have different character encodings and an error occurs during encoding conversion |
SPLIT-ERROR | field missing closing quote character; extra text following quoted field |
trim_unquoted
parameter int <string>::strlen | ( | ) |
Returns the number of bytes in the string (not including the terminating null character ('\0'
)
'\0'
)bool <string>::strp | ( | ) |
string <string>::substr | ( | softint | start | ) |
Returns a portion of a string starting from an integer offset.
Arguments can be negative, giving offsets from the end of the string. All offsets are character positions, not byte positions.
start | The starting character for the substring where the first character is at offset 0; if the offset is negative, it designates the number of characters from the end of the string. If the offset is 0, then the entire string is returned. |
INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data |
string <string>::substr | ( | softint | start, |
softint | len | ||
) |
Returns a portion of a string starting from an integer offset, with a length parameter.
Arguments can be negative, giving offsets from the end of the string. All offsets are character positions, not byte positions.
start | The starting character for the substring where the first character is at offset 0; if the offset is negative, it designates the number of characters from the end of the string |
len | The maximum number of characters to copy; if this value is negative, the rest of the string from start will be copied to the substring, except without - len characters from the end of the string |
INVALID-ENCODING | this exception could be thrown if a character offset calculation fails due to invalid encoding of multi-byte character data |
string <string>::toMD5 | ( | ) |
Returns the MD5 message digest of the string as a hex string.
The trailing null character is not included in the digest returned.
"5d41402abc4b2a76b9719d911017c592"
)MD5-DIGEST-ERROR | error calculating digest (should not normally happen) |
string <string>::toSHA1 | ( | ) |
Returns the SHA1 message digest of the string as a hex string.
The trailing null character is not included in the digest returned.
"aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
)SHA1-DIGEST-ERROR | error calculating digest (should not normally happen) |
string <string>::toSHA224 | ( | ) |
Returns the SHA-224 message digest (a variant of SHA-2) of the string as a hex string.
The trailing null character is not included in the digest returned.
"ea09ae9cc6768c50fcee903ed054556e5bfc8347907f12598aa24193"
)SHA224-DIGEST-ERROR | error calculating digest (should not normally happen) |
string <string>::toSHA256 | ( | ) |
Returns the SHA-256 message digest (a variant of SHA-2) of the string as a hex string.
The trailing null character is not included in the digest returned.
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
)SHA256-DIGEST-ERROR | error calculating digest (should not normally happen) |
string <string>::toSHA384 | ( | ) |
Returns the SHA-384 message digest (a variant of SHA-2) of the string as a hex string.
The trailing null character is not included in the digest returned.
"59e1748777448c69de6b800d7a33bbfb9ff1b463e44354c3553bcdb9c666fa90125a3c79f90397bdf5f6a13de828684f"
)SHA384-DIGEST-ERROR | error calculating digest (should not normally happen) |
string <string>::toSHA512 | ( | ) |
Returns the SHA-512 message digest (a variant of SHA-2) of the string as a hex string.
The trailing null character is not included in the digest returned.
"9b71d224bd62f3785d96d46ad3ea3d73319bfbc2890caadae2dff72519673ca72323c3d99ba5c11d7c7acc6e14b8c5da0c4663475c2e5c3adef46f73bcdec043"
)SHA512-DIGEST-ERROR | error calculating digest (should not normally happen) |
int <string>::typeCode | ( | ) |
string <string>::upr | ( | ) |
Returns the string in upper case.
bool <string>::val | ( | ) |
Returns False if the string is empty or has the exact value "0"
, True if not (note that if %strict-bool-eval is set, this method returns a boolean value corresponding to the string value after conversion to a numeric value)
"0"
, True if not (note that if %strict-bool-eval is set, this method returns a boolean value corresponding to the string value after conversion to a numeric value)