Qore Programming Language Reference Manual  0.8.11.1
Miscellaneous Functions

Functions

string Qore::backquote (string cmd, *reference rc)
 Executes a process and returns a string of the output (stdout only) More...
 
nothing Qore::backquote ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
any Qore::call_builtin_function (string name,...)
 Calls a function and returns the return value, passing the remaining arguments after the function name to the builtin function. More...
 
any Qore::call_builtin_function_args (string name, *softlist vargs)
 Calls a function and returns the return value, using the optional second argument as a list of arguments for the function. More...
 
any Qore::call_function (string name,...)
 Calls a function and returns the return value, passing the remaining arguments after the function name to the function. More...
 
any Qore::call_function (code f,...)
 Calls the given call reference or closure and returns the result, passing the remaining arguments to the call reference or closure. More...
 
any Qore::call_function_args (string name, *softlist vargs)
 Calls a function and returns the return value, using the optional second argument as a list of arguments for the function. More...
 
any Qore::call_function_args (code f, *softlist vargs)
 Calls the given call reference or closure and returns the result, using the optional second argument as a list of arguments to the call reference or closure. More...
 
string Qore::decode_url (string url)
 Decodes percent numeric codes in a URL string and returns the decoded string in UTF-8 encoding. More...
 
nothing Qore::decode_url ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::encode_url (string url, softbool encode_all=False)
 Encodes URLs by substituting '%' characters with '%25', spaces (' ') with '%20', and non-ascii characters by percent-encoded representations. More...
 
bool Qore::exists (...)
 A function performing the same role as the exists operator. More...
 
bool Qore::existsFunction (string name)
 Returns True if the function exists in the current program's function name space. More...
 
bool Qore::existsFunction (code c)
 Always returns True. More...
 
nothing Qore::existsFunction ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*string Qore::functionType (string name)
 Returns "builtin" (for a builtin function), "user" (for a user function), or NOTHING (if the function cannot be found) according to the function name passed. More...
 
nothing Qore::functionType ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*int Qore::getByte (string str, softint offset=0)
 Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
nothing Qore::getByte ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*int Qore::getByte (binary b, softint offset=0)
 Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
string Qore::getClassName (object obj)
 Returns the class name of the object passed. More...
 
nothing Qore::getClassName ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
list Qore::getFeatureList ()
 Returns a list of strings of the builtin and module-supplied features of Qore. More...
 
hash Qore::getModuleHash ()
 Returns a hash of hashes describing the currently-loaded Qore modules; the top-level hash keys are the module names. More...
 
list Qore::getModuleList ()
 Returns a list of hashes describing the currently-loaded Qore modules. More...
 
*int Qore::getWord32 (string str, softint offset=0)
 Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::getWord32 (binary b, softint offset=0)
 Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
nothing Qore::getWord32 ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*int Qore::get_byte (string str, softint offset=0)
 Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_byte (binary b, softint offset=0)
 Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
string Qore::get_default_encoding ()
 Returns the name of the default character encoding. More...
 
string Qore::get_ex_pos (hash ex)
 returns a descriptive string for an exception location; the source and offset information will also be included in the string returned if present in the exception hash argument More...
 
int Qore::get_parse_options ()
 returns the current parse options for the current Program object More...
 
hash Qore::get_qore_library_info ()
 Returns a hash of library build and version info. More...
 
hash Qore::get_qore_option_hash ()
 Returns a hash of hashes giving information about Qore library options for the current build. More...
 
list Qore::get_qore_option_list ()
 Returns a list of hashes giving information about Qore library options for the current build. More...
 
*string Qore::get_script_dir ()
 Returns the name of the directory from which the current script was executed or NOTHING if unknown (i.e. no parent script, script read from stdin, etc) More...
 
*string Qore::get_script_name ()
 Returns the filename of the current script if known or NOTHING if unknown (i.e. no parent script, script read from stdin, etc) More...
 
*string Qore::get_script_path ()
 Returns the path (directory and filename) of the current script or NOTHING if unknown (i.e. no parent script, script read from stdin, etc) More...
 
*int Qore::get_word_16 (string str, softint offset=0)
 Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_16 (binary b, softint offset=0)
 Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_16_lsb (string str, softint offset=0)
 Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_16_lsb (binary b, softint offset=0)
 Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_32 (string str, softint offset=0)
 Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_32 (binary b, softint offset=0)
 Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_32_lsb (string str, softint offset=0)
 Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_32_lsb (binary b, softint offset=0)
 Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_64 (string str, softint offset=0)
 Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_64 (binary b, softint offset=0)
 Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_64_lsb (string str, softint offset=0)
 Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
*int Qore::get_word_64_lsb (binary b, softint offset=0)
 Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data. More...
 
bool Qore::has_key (hash h, string key)
 Returns True if the given key exists in the hash (does not necessarily have to have a value assigned); exceptions are only raised if string encoding errors are encountered. More...
 
bool Qore::has_key (object obj, string key)
 Returns True if the given key exists in the object (does not necessarily have to have a value assigned); exceptions are only raised if string encoding errors are encountered or in case of object access errors. More...
 
list Qore::hash_values (hash h)
 Returns a list of all the values in the hash argument passed. More...
 
nothing Qore::hash_values ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::hextoint (string str)
 Returns an integer for a hexadecimal string value; throws an exception if non-hex digits are found. More...
 
nothing Qore::hextoint ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::html_decode (string str)
 Returns a string with any HTML escape codes translated to the original characters. More...
 
nothing Qore::html_decode ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::html_encode (string str)
 Returns a string with characters needing HTML escaping translated to HTML escape codes. More...
 
nothing Qore::html_encode ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
nothing Qore::load_module (string name)
 Loads in a Qore module at run-time. More...
 
nothing Qore::load_module ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::makeBase64String (string str, softint maxlinelen=-1)
 Returns a base64-encoded representation of a string. More...
 
string Qore::makeBase64String (binary bin, softint maxlinelen=-1)
 Returns a base64-encoded representation of a binary object. More...
 
nothing Qore::makeBase64String ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::makeHexString (string str)
 Returns a hex-encoded representation of a string. More...
 
string Qore::makeHexString (binary bin)
 Returns a hex-encoded representation of a binary object. More...
 
nothing Qore::makeHexString ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*hash Qore::parse (string code, string label, *softint warning_mask, *string source, *softint offset, softbool format_label=True)
 Adds the text passed to the current program's code, tagged with the given label. More...
 
nothing Qore::parse ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
binary Qore::parseBase64String (string str)
 Parses a base64 encoded string and returns a binary object of the decoded data. More...
 
nothing Qore::parseBase64String ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::parseBase64StringToString (string str, *string encoding)
 Parses a base64 encoded string and returns a string of the decoded data. More...
 
nothing Qore::parseBase64StringToString ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
binary Qore::parseHexString (string hexstr)
 Parses a hex-encoded string and returns the binary object. More...
 
nothing Qore::parseHexString ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
*hash Qore::parseURL (string url, bool keep_brackets=False)
 Parses a URL string and returns a hash of the components; if the URL cannot be parsed then NOTHING is returned. More...
 
nothing Qore::parseURL ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
hash Qore::parse_url (string url, bool keep_brackets=False)
 Parses a URL string and returns a hash of the components; throws an exception if the string cannot be parsed as a URL. More...
 
string Qore::splice (string str)
 This function always returns an empty string "". More...
 
string Qore::splice (string str, softint start)
 Returns a string based on the argument string but with characters removed from a certain character index. More...
 
string Qore::splice (string str, softint start, softint len, *string nstr)
 Returns a string based on the argument string but optionally with characters removed and/or added from a certain character index. More...
 
list Qore::splice (list l, softint start)
 Returns a list based on the argument list but with elements removed from the given index to the end of the list. More...
 
list Qore::splice (list l, softint start, softint len, *softlist nlist)
 Returns a list based on the argument list but optionally with elements removed and/or added from a certain index. More...
 
nothing Qore::splice ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::strtoint (string num, softint base=10)
 parses a string representing a number in a configurable base and returns the integer More...
 
nothing Qore::strtoint ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 

Detailed Description

Miscellaneous functions

Function Documentation

string Qore::backquote ( string  cmd,
*reference  rc 
)

Executes a process and returns a string of the output (stdout only)

Restrictions:
Qore::PO_NO_EXTERNAL_PROCESS
Parameters
cmdThe shell command to executed as a subprocess
rcan optional reference to an integer to return the return code of the process
Returns
The stdout of the shell command that was executed
Example:
my int $rc;
my string $files = $files = backquote("ls", \$rc);
Exceptions
BACKQUOTE-ERRORAn error occurred with the fork() or opening the stdout pipe
See also
Since
Qore 0.8.8 the rc argument was added
nothing Qore::backquote ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_EXTERNAL_PROCESS
Code Flags:
RUNTIME_NOOP
any Qore::call_builtin_function ( string  name,
  ... 
)

Calls a function and returns the return value, passing the remaining arguments after the function name to the builtin function.

Parameters
nameThe name of the builtin function to call
...Any optional arguments to the function
Returns
The value returned by the called function
Example:
my any $result = call_builtin_function("func_name", $arg1, $arg2);
Exceptions
INVALID-FUNCTION-ACCESSParse options do not allow access to the function
NO-FUNCTIONThe function does not exist
Note
The function called could also throw other exceptions
Since
0.8.4 this function no longer restricts its search to builtin functions as as of Qore 0.8.4 builtin and user functions are stored identically internally; there is only one function implementation which can contain both builtin and user variants
any Qore::call_builtin_function_args ( string  name,
*softlist  vargs 
)

Calls a function and returns the return value, using the optional second argument as a list of arguments for the function.

Parameters
nameThe name of the builtin function to call
vargsOptionally a single argument to the function or a list of arguments to the function
Returns
The value returned by the called function
Example:
my any $result = call_builtin_function_args("func_name", ($arg1, $arg2));
Exceptions
INVALID-FUNCTION-ACCESSParse options do not allow access to the function
NO-FUNCTIONThe function does not exist
Note
The function called could also throw other exceptions
Since
0.8.4 this function no longer restricts its search to builtin functions as as of Qore 0.8.4 builtin and user functions are stored identically internally; there is only one function implementation which can contain both builtin and user variants
any Qore::call_function ( string  name,
  ... 
)

Calls a function and returns the return value, passing the remaining arguments after the function name to the function.

Parameters
nameThe name of the function to call
...Any optional arguments to the function
Returns
The value returned by the called function
Example:
my any $result = call_function("func_name", $arg1, $arg2);
Exceptions
INVALID-FUNCTION-ACCESSParse options do not allow access to the function
NO-FUNCTIONThe function does not exist
Note
The function called could also throw other exceptions
any Qore::call_function ( code  f,
  ... 
)

Calls the given call reference or closure and returns the result, passing the remaining arguments to the call reference or closure.

Parameters
fThe call reference or closure
...Any optional arguments to the call reference or closure
Example:
my any $result = call_function($call_ref, $arg1, $arg2);
Note
The call reference or closure called could also throw other exceptions
any Qore::call_function_args ( string  name,
*softlist  vargs 
)

Calls a function and returns the return value, using the optional second argument as a list of arguments for the function.

Parameters
nameThe name of the function to call
vargsOptionally a single argument to the function or a list of arguments to the function
Returns
The value returned by the called function
Example:
my any $result = call_function_args("func_name", ($arg1, $arg2));
Exceptions
INVALID-FUNCTION-ACCESSParse options do not allow access to the function
NO-FUNCTIONThe function does not exist
Note
The function called could also throw other exceptions
any Qore::call_function_args ( code  f,
*softlist  vargs 
)

Calls the given call reference or closure and returns the result, using the optional second argument as a list of arguments to the call reference or closure.

Parameters
fThe call reference or closure
vargsOptionally a single argument to the call reference or closure or a list of arguments to the call reference or closure
Example:
my any $result = call_function_args($call_ref, ($arg1, $arg2));
Note
The call reference or closure called could also throw other exceptions
string Qore::decode_url ( string  url)

Decodes percent numeric codes in a URL string and returns the decoded string in UTF-8 encoding.

Code Flags:
CONSTANT
Parameters
urla URL string with percent-encodings to decode
Returns
the URL string in UTF-8 encoding with all percent-encodings decoded
Example:
my string $decoded_url = decode_url($encoded_url);
Note
percent decoding is made according to RFC 3986
See also
encode_url()
nothing Qore::decode_url ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::encode_url ( string  url,
softbool  encode_all = False 
)

Encodes URLs by substituting '%' characters with '%25', spaces (' ') with '%20', and non-ascii characters by percent-encoded representations.

Code Flags:
CONSTANT
Parameters
urla URL string to encode
encode_allif True, then in addition to '%', spaces (' '), and non-ascii characters the following reserved characters (according to RFC 3986 are also encoded: '!', '*', '\'', '(', ')', ';', ':', '@', '&', '=', '+', '$', ',', '/', '?', '#', '[', ']'
Returns
the URL string with encoded according to the arguments
Example:
my string $encoded_url = encode_url($url);
See also
decode_url()
Since
Qore 0.8.9
bool Qore::exists (   ...)

A function performing the same role as the exists operator.

Code Flags:
CONSTANT
Parameters
...if only a single argument is passed, then this function returns True if the single argument exists, False if not; otherwise is multiple arguments are passed to the function, it always returns True; this is to emulate the behavior of the exists operator
Returns
if only a single argument is passed, then this function returns True if the single argument exists, False if not; otherwise is multiple arguments are passed to the function, it always returns True; this is to emulate the behavior of the exists operator
Example:
my bool $b = exists($val);
bool Qore::existsFunction ( string  name)

Returns True if the function exists in the current program's function name space.

Code Flags:
CONSTANT
Parameters
namethe name of the function to check
Returns
True if the function exists in the current program's function name space, False if not
Example:
my bool $b = existsFunction("func_name");
bool Qore::existsFunction ( code  c)

Always returns True.

This function variant is included for backwards-compatibility

Code Flags:
NOOP
Parameters
ca call reference or closure:
Returns
always returns True
nothing Qore::existsFunction ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
*string Qore::functionType ( string  name)

Returns "builtin" (for a builtin function), "user" (for a user function), or NOTHING (if the function cannot be found) according to the function name passed.

Parameters
nameThe function name to check
Returns
"builtin" (for a builtin function), "user" (for a user function), or NOTHING (if the function cannot be found) according to the function name passed
Example:
my *string $type = functionType("print");
nothing Qore::functionType ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
*int Qore::get_byte ( string  str,
softint  offset = 0 
)

Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

Code Flags:
CONSTANT
Parameters
strthe string data to process
offsetthe byte offset of the data to retrieve (the first value is at offset 0)
Returns
the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $byte = get_byte($str, 2); # returns the third byte of the string
Note
that for strings this function is not equivalent to the [] operator for multi-byte character encodings, as this function works purely on bytes and the [] operator operates on characters

Furthermore this function is identical to getByte(), except this function has no RUNTIME_NOOP variant
*int Qore::get_byte ( binary  b,
softint  offset = 0 
)

Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

Code Flags:
CONSTANT
Parameters
bthe data to process
offsetthe byte offset of the data to retrieve (the first value is at offset 0)
Returns
the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $byte = get_byte($bin, 2); # returns the third byte of the binary object
Note
this function is equivalent to the more efficient [] operator when used with a binary argument

Furthermore this function is identical to getByte(), except this function has no RUNTIME_NOOP variant
string Qore::get_default_encoding ( )

Returns the name of the default character encoding.

Returns
the name of the default character encoding
Example:
my string $encoding = get_default_encoding();
string Qore::get_ex_pos ( hash  ex)

returns a descriptive string for an exception location; the source and offset information will also be included in the string returned if present in the exception hash argument

Code Flags:
CONSTANT
Example:
try {
throw "oops", sprintf("arg %y is invalid", $arg);
}
catch (hash $ex) {
log("%s: %s: %s", get_ex_pos($ex), $ex.err, $ex.desc);
}
Parameters
exan exception hash
Returns
a string describing the exception location (ex: "sftp-poller.q:140")
Since
Qore 0.8.7
int Qore::get_parse_options ( )

returns the current parse options for the current Program object

Code Flags:
CONSTANT
Example:
my int $i = get_parse_options();
Returns
the current parse options for the current Program object
Since
Qore 0.8.7
hash Qore::get_qore_library_info ( )

Returns a hash of library build and version info.

Returns
a hash of library build and version info with the following keys:
  • PlatformOS: The operating system used to build the Qore library
  • PlatformCPU: The CPU used as a target for the Qore library build
  • VersionString: The full version string for this version of the Qore library
  • VersionMajor: An integer giving the Qore library's major version number
  • VersionMinor: An integer giving the Qore library's minor version number
  • VersionSub: An integer giving the Qore library's release version number
  • Build: An integer giving the Qore library's subversion revision number
  • BuildHost: A string giving information about the host used to compile the Qore library
  • Compiler: The compiler used to build the Qore library
  • ModuleDir: The module directory assumed by default in the Qore library
  • CFLAGS: The compiler flags used to compile the Qore library
  • LDFLAGS: The linker flags used to link the Qore library
Code Flags:
CONSTANT
Example:
hash Qore::get_qore_option_hash ( )

Returns a hash of hashes giving information about Qore library options for the current build.

Returns
a hash of hashes giving information about Qore library options for the current build; the hash keys are the constant names and the values are hashes with the following keys:
  • option: The string description of the option
  • constant: A string giving the name of the constant that has the boolean value for this option (equal to the hash key name)
  • type: The type of option
  • value: The boolean value of the option
Code Flags:
CONSTANT
Example:
See also
get_qore_option_list()
Since
Qore 0.8.4
list Qore::get_qore_option_list ( )

Returns a list of hashes giving information about Qore library options for the current build.

Returns
a list of hashes giving information about Qore library options for the current build; each hash will have the following keys:
  • option: The string description of the option
  • constant: A string giving the name of the constant that has the boolean value for this option
  • type: The type of option
  • value: The boolean value of the option
Code Flags:
CONSTANT
Example:
my list $l = get_qore_option_list();
See also
get_qore_option_hash()
*string Qore::get_script_dir ( )

Returns the name of the directory from which the current script was executed or NOTHING if unknown (i.e. no parent script, script read from stdin, etc)

Returns
the name of the directory from which the current script was executed or NOTHING if unknown (i.e. no parent script, script read from stdin, etc)
Example:
my *string $str = get_script_dir();
*string Qore::get_script_name ( )

Returns the filename of the current script if known or NOTHING if unknown (i.e. no parent script, script read from stdin, etc)

Returns
the filename of the current script if known or NOTHING if unknown (i.e. no parent script, script read from stdin, etc)
Example:
my *string $str = get_script_name();
*string Qore::get_script_path ( )

Returns the path (directory and filename) of the current script or NOTHING if unknown (i.e. no parent script, script read from stdin, etc)

Returns
the path (directory and filename) of the current script or NOTHING if unknown (i.e. no parent script, script read from stdin, etc)
Example:
my *string $str = get_script_path();
*int Qore::get_word_16 ( string  str,
softint  offset = 0 
)

Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
strthe string data to process
offsetthe 2-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_16($str, 2); # returns the third 2-byte (16-bit) value in the string
See also
get_word_16_lsb()
*int Qore::get_word_16 ( binary  b,
softint  offset = 0 
)

Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
bthe data to process
offsetthe 2-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_16($bin, 2); # returns the third 2-byte (16-bit) value in the binary object
See also
get_word_16_lsb()
*int Qore::get_word_16_lsb ( string  str,
softint  offset = 0 
)

Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes LSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
strthe string data to process
offsetthe 2-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_16_lsb($str, 2); # returns the third 2-byte (16-bit) value in the string
See also
get_word_16()
*int Qore::get_word_16_lsb ( binary  b,
softint  offset = 0 
)

Returns the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes LSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
bthe data to process
offsetthe 2-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 16-bit integer value at the given 2-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_16_lsb($bin, 2); # returns the third 2-byte (16-bit) value in the binary object
See also
get_word_16()
*int Qore::get_word_32 ( string  str,
softint  offset = 0 
)

Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
strthe string data to process
offsetthe 4-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_32($str, 4); # returns the third 4-byte (32-bit) value in the string
Note
This function is identical to getWord32(), except this function has no RUNTIME_NOOP variant
See also
get_word_32_lsb()
*int Qore::get_word_32 ( binary  b,
softint  offset = 0 
)

Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
bthe data to process
offsetthe 4-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_32($bin, 2); # returns the third 4-byte (32-bit) value in the binary object
Note
This function is identical to getWord32(), except this function has no RUNTIME_NOOP variant
See also
get_word_32_lsb()
*int Qore::get_word_32_lsb ( string  str,
softint  offset = 0 
)

Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes LSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
strthe string data to process
offsetthe 4-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_32_lsb($str, 4); # returns the third 4-byte (32-bit) value in the string
Note
This function is identical to getWord32(), except this function has no RUNTIME_NOOP variant
See also
get_word_32()
*int Qore::get_word_32_lsb ( binary  b,
softint  offset = 0 
)

Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes LSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
bthe data to process
offsetthe 4-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_32_lsb($bin, 2); # returns the third 4-byte (32-bit) value in the binary object
See also
get_word_32()
*int Qore::get_word_64 ( string  str,
softint  offset = 0 
)

Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
strthe string data to process
offsetthe 8-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_64($str, 4); # returns the third 8-byte (64-bit) value in the string
See also
get_word_64_lsb()
*int Qore::get_word_64 ( binary  b,
softint  offset = 0 
)

Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
bthe data to process
offsetthe 8-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_64($bin, 2); # returns the third 8-byte (64-bit) value in the binary object
See also
get_word_64_lsb()
*int Qore::get_word_64_lsb ( string  str,
softint  offset = 0 
)

Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes LSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
strthe string data to process
offsetthe 8-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_64_lsb($str, 4); # returns the third 8-byte (64-bit) value in the string
See also
get_word_64()
*int Qore::get_word_64_lsb ( binary  b,
softint  offset = 0 
)

Returns the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes LSB byte order when retrieving the value from the data

Code Flags:
CONSTANT
Parameters
bthe data to process
offsetthe 8-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 64-bit integer value at the given 8-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = get_word_64_lsb($bin, 2); # returns the third 8-byte (64-bit) value in the binary object
See also
get_word_64()
*int Qore::getByte ( string  str,
softint  offset = 0 
)

Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

Code Flags:
CONSTANT, DEPRECATED
Parameters
strthe string data to process
offsetthe byte offset of the data to retrieve (the first value is at offset 0)
Returns
the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $byte = get_byte($str, 2); # returns the third byte of the string
Note
that for strings this function is not equivalent to the [] operator for multi-byte character encodings, as this function works purely on bytes and the [] operator operates on characters

Furthermore this function is identical to get_byte(), except this function has a RUNTIME_NOOP variant
Since
Qore 0.8.4 marked as deprecated; use the get_byte() function instead
nothing Qore::getByte ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP, DEPRECATED
*int Qore::getByte ( binary  b,
softint  offset = 0 
)

Returns the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

Code Flags:
CONSTANT, DEPRECATED
Parameters
bthe data to process
offsetthe byte offset of the data to retrieve (the first value is at offset 0)
Returns
the byte value at the given byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $byte = get_byte($bin, 2); # returns the third byte of the binary object
Note
this function is equivalent to the more efficient [] operator when used with a binary argument

Furthermore this function is identical to get_byte(), except this function has a RUNTIME_NOOP variant
Since
Qore 0.8.4 marked as deprecated; use the get_byte() function instead
string Qore::getClassName ( object  obj)

Returns the class name of the object passed.

Parameters
objthe object to get the class name of
Returns
the class name of the object passed
Example:
my string $name = getClassName($obj);
nothing Qore::getClassName ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
list Qore::getFeatureList ( )

Returns a list of strings of the builtin and module-supplied features of Qore.

Returns
a list of strings of the builtin and module-supplied features of Qore
Code Flags:
CONSTANT
Example:
my list $list = getFeatureList();
hash Qore::getModuleHash ( )

Returns a hash of hashes describing the currently-loaded Qore modules; the top-level hash keys are the module names.

Returns
a hash of hashes describing the currently-loaded Qore modules; the top-level hash keys are the module names; the values are hashes with the following keys:
  • filename: the path to the module
  • name: the name of the module
  • desc: the description of the module
  • version: the version of the module
  • author: the author of the module
  • api_major: the major number of the Qore module API version the module support
  • api_minor: the minor number of the Qore module API version the module support
  • url: the module's URL
  • license: the module's license
Code Flags:
CONSTANT
Example:
my hash $mh = getModuleHash();
Since
Qore 0.8.1
list Qore::getModuleList ( )

Returns a list of hashes describing the currently-loaded Qore modules.

Returns
a list of hashes describing the currently-loaded Qore modules; each element in the list is a hash with the following keys:
  • filename: the path to the module
  • name: the name of the module
  • desc: the description of the module
  • version: the version of the module
  • author: the author of the module
  • api_major: the major number of the Qore module API version the module support
  • api_minor: the minor number of the Qore module API version the module support
  • url: the module's URL
  • license: the module's license
Code Flags:
CONSTANT
Example:
my list $list = getModuleList();
See also
getModuleHash()
*int Qore::getWord32 ( string  str,
softint  offset = 0 
)

Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT, DEPRECATED
Parameters
strthe string data to process
offsetthe 4-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = getWord32($str, 4); # returns the third 4-byte (32-bit) value in the string
Note
This function is identical to get_word_32(), except this function has a RUNTIME_NOOP variant
Since
Qore 0.8.4 marked as deprecated; use the get_word_32() function instead
*int Qore::getWord32 ( binary  b,
softint  offset = 0 
)

Returns the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data.

This function assumes MSB byte order when retrieving the value from the data

Code Flags:
CONSTANT, DEPRECATED
Parameters
bthe data to process
offsetthe 4-byte offset of the data to retrieve (the first value is at offset 0)
Returns
the 32-bit integer value at the given 4-byte offset (the first value is at offset 0) or NOTHING if the offset is not legal for the given data
Example:
my *int $val = getWord32($bin, 2); # returns the third 4-byte (32-bit) value in the binary object
Note
This function is identical to get_word_32(), except this function has a RUNTIME_NOOP variant
Since
Qore 0.8.4 marked as deprecated; use the get_word_32() function instead
nothing Qore::getWord32 ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
bool Qore::has_key ( hash  h,
string  key 
)

Returns True if the given key exists in the hash (does not necessarily have to have a value assigned); exceptions are only raised if string encoding errors are encountered.

Parameters
hthe hash to check
keythe key name to check; this value will be converted to the default character encoding to check the hash
Returns
True if the given key exists in the hash (does not necessarily have to have a value assigned), False if the key is not present at all
Example:
my bool $b = has_key($hash, "key");
Exceptions
ENCODING-CONVERSION-ERRORthis error is thrown if the given key cannot be converted to the default character encoding
bool Qore::has_key ( object  obj,
string  key 
)

Returns True if the given key exists in the object (does not necessarily have to have a value assigned); exceptions are only raised if string encoding errors are encountered or in case of object access errors.

Example:
my bool $b = has_key($obj, "key");
Exceptions
ENCODING-CONVERSION-ERRORthis error is thrown if the given key cannot be converted to the default character encoding
Note
object access exceptions could also be raised
list Qore::hash_values ( hash  h)

Returns a list of all the values in the hash argument passed.

Code Flags:
CONSTANT
Parameters
ha hash to get all the values of
Returns
a list of all the values in the hash argument passed
Example:
my list $vl = hash_values($vl);
Note
equivalent to <hash>::values()
See also
<hash>::keys()
nothing Qore::hash_values ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::hextoint ( string  str)

Returns an integer for a hexadecimal string value; throws an exception if non-hex digits are found.

Parameters
stra string of hexadecimal digits (like "6d4f84e0"; with or without leading "x" or "0x")
Returns
the base-10 integer corresponding to the argument
Example:
my int $i = hextoint("ab3d4e0f12");
Exceptions
PARSE-HEX-ERRORinvalid hex digit found
nothing Qore::hextoint ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::html_decode ( string  str)

Returns a string with any HTML escape codes translated to the original characters.

Code Flags:
CONSTANT
Parameters
strthe argument to decode
Returns
the string passed as an argument with any HTML escape codes translated to the original characters
Example:
my string $str = html_decode("&lt;hello&gt;"); # returns "<hello>"
nothing Qore::html_decode ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::html_encode ( string  str)

Returns a string with characters needing HTML escaping translated to HTML escape codes.

Code Flags:
CONSTANT
Parameters
strthe argument to process
Returns
the string passed as an argument with characters needing HTML escaping translated to HTML escape codes
Example:
my string $str = html_encode("<hello>"); # returns "&lt;hello&gt;"
nothing Qore::html_encode ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
nothing Qore::load_module ( string  name)

Loads in a Qore module at run-time.

If a feature with the same name already exists, then this feature's code is imported into the current Program object if necessary and no further action is taken.

Note that modules providing objects resolved at parse time (classes, constants, functions, etc) must be loaded with the %requires directive instead, unless all references to the objects provided by the module will be made in code embedded in child Program objects.

Restrictions:
Qore::PO_NO_MODULES
Parameters
nameeither a feature name (a module will be searched with this feature name) or a path to a module to load
Example:
load_module("mysql");
Exceptions
LOAD-MODULE-ERRORmodule cannot be loaded: API incompatibility, module defines symbols already defined in the target object, etc
See also
getModuleHash(), getFeatureList()
Since
Qore 0.8.7 this function can also be used in user module code
nothing Qore::load_module ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_MODULES
Code Flags:
RUNTIME_NOOP
string Qore::makeBase64String ( string  str,
softint  maxlinelen = -1 
)

Returns a base64-encoded representation of a string.

Implementation based on RFC-1421 and RFC-2045

Code Flags:
CONSTANT
Parameters
strthe string to encode
maxlinelenthe maximum length of a line in the resulting output string in bytes; if this value is > 0 then output lines will be separated by CRLF characters
Returns
the base64-encoded string of the data passed
Example:
my string $base64 = makeBase64String($data, 64);
Since
the maxlinelen parameter was added in Qore 0.8.4
See also
string Qore::makeBase64String ( binary  bin,
softint  maxlinelen = -1 
)

Returns a base64-encoded representation of a binary object.

Implementation based on RFC-1421 and RFC-2045

Code Flags:
CONSTANT
Parameters
binthe data to encode
maxlinelenthe maximum length of a line in the resulting output string in bytes; if this value is > 0 then output lines will be separated by CRLF characters
Returns
the base64-encoded string of the data passed
Example:
my string $base64 = makeBase64String($data, 64);
Since
the maxlinelen parameter was added in Qore 0.8.4
See also
nothing Qore::makeBase64String ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::makeHexString ( string  str)

Returns a hex-encoded representation of a string.

Code Flags:
CONSTANT
Parameters
strthe string to encode
Returns
a string of hex digits repsenting the bytes of the argument passed
Example:
my string $str = makeHexString($str2);
See also
string Qore::makeHexString ( binary  bin)

Returns a hex-encoded representation of a binary object.

Parameters
binthe binary object to encode
Returns
a string of hex digits repsenting the bytes of the argument passed
Example:
my string $str = makeHexString($bin);
See also
nothing Qore::makeHexString ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
*hash Qore::parse ( string  code,
string  label,
*softint  warning_mask,
*string  source,
*softint  offset,
softbool  format_label = True 
)

Adds the text passed to the current program's code, tagged with the given label.

Restrictions:
Qore::PO_NO_EMBEDDED_LOGIC, Qore::PO_IN_MODULE
Parameters
codethe string of Qore source code to parse; the parsed code will be added to the current program
labela label identifying the code or the code's source
warning_maskAn optional warning mask; see Warning Constants for values to combine by binary-or; if this arguments is 0 or not given then no warnings will be checked or issued and the return value will always be NOTHING
sourceAn optional source file name for the code being parsed; this is useful if sections of a file are parsed
offsetAn optional line offset for use with the source parameter; this gives the line offset in the file to the code being parsed
format_labelIf this argument is True, then the label is formatted as "<run-time-loaded: label>"; if False, then it is passed as-is
Example:
parse($code, $filename);
Note
This function could throw many parse exceptions which are not enumerated here; any parse errors will result in an appropriate exception.
See also
Since
Qore 0.8.7 the optional warning_mask, source, offset, and format_label arguments were added; also label formatting was added; these changes were made to align the functionality of this function with the Program::parse() and Program::parsePending() methods
nothing Qore::parse ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Restrictions:
Qore::PO_NO_EMBEDDED_LOGIC, Qore::PO_IN_MODULE
Code Flags:
RUNTIME_NOOP
hash Qore::parse_url ( string  url,
bool  keep_brackets = False 
)

Parses a URL string and returns a hash of the components; throws an exception if the string cannot be parsed as a URL.

Parameters
urlthe URL to parse (ex: "https://user:pass@host:8080/path"); either a hostname or path is required at a minimum or a PARSE-URL-ERROR exception is raised
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well; square brackets are used by some Qore methods to denote IPv6 addresses; for example see Socket::connect()
Returns
a hash of the components of the URL with the following keys (if data in the URL is present; note that at least either the "host" or the "path" keys will always be returned if no PARSE-URL-ERROR is raised):
  • protocol: the scheme in the URL (ex: "http")
  • path: any path given in the URL; the path will be prefixed by "/" if a hostname is found in the URL argument string, otherwise it will not if it was not given as such in the argument string
  • username: any username given in the URL
  • password: any password given in the URL
  • host: any hostname given in the URL; note that this key will be given if no other information can be found in the URL argument and the URL argument string has no "/" characters; depending on the usage context for this function, this may actually be a filename
  • port: any port number given in the URL
Example:
my hash $hash = parse_url($url_string);
Exceptions
PARSE-URL-ERRORThe URL string given could not be parsed
Note
URLs with UNIX sockets are generally supported in Qore with the following syntax: scheme://socket=<url_encoded_path>/path, where url_encoded_path is a path with URL-encoding as performed by encode_url(); for example: "http://socket=%2ftmp%socket-dir%2fsocket-file-1/url/path"; this allows a filesystem path to be used in the host portion of the URL and for the URL to include a URL path as well.
See also
parseURL() for a version of this function that does not throw exceptions if the URL cannot be parsed
binary Qore::parseBase64String ( string  str)

Parses a base64 encoded string and returns a binary object of the decoded data.

Implementation based on RFC-1421 and RFC-2045

Parameters
strthe base64-encoded input data to decode
Returns
a binary object of the decoded data
Example:
my binary $bin = parseBase64String($base64_string);
Exceptions
BASE64-PARSE-ERRORA syntax error occurred parsing the base64 string (invalid character, etc)
See also
parseHexString(), parseBase64StringToString()
nothing Qore::parseBase64String ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::parseBase64StringToString ( string  str,
*string  encoding 
)

Parses a base64 encoded string and returns a string of the decoded data.

Implementation based on RFC-1421 and RFC-2045

Parameters
strthe base64-encoded input data to decode
encodingthe character encoding tag for the string return value; if not present, the default character encoding is assumed.
Returns
a string of the decoded data tagged with the given encoding
Example:
my string $str = parseBase64String($base64_string);
Exceptions
BASE64-PARSE-ERRORA syntax error occurred parsing the base64 string (invalid character, etc)
Since
the encoding parameter was added in Qore 0.8.4
See also
parseBase64String()
nothing Qore::parseBase64StringToString ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
binary Qore::parseHexString ( string  hexstr)

Parses a hex-encoded string and returns the binary object.

Parameters
hexstra string of an even-number of only hexadecimal digits
Returns
a binary object of the decoded data
Example:
my binary $bin = parseHexString($hex_string);
Exceptions
PARSE-HEX-ERRORA syntax error occurred parsing the hex string (odd number of digits, invalid hex character, etc)
See also
parseBase64String()
makeHexString();
nothing Qore::parseHexString ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
*hash Qore::parseURL ( string  url,
bool  keep_brackets = False 
)

Parses a URL string and returns a hash of the components; if the URL cannot be parsed then NOTHING is returned.

Parameters
urlthe URL to parse (ex: "https://user:pass@host:8080/path"); either a hostname or path is required at a minimum or the function will return NOTHING
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well; square brackets are used by some Qore methods to denote IPv6 addresses; for example see Socket::connect()
Returns
a hash of the components of the URL with the following keys (if data in the URL is present; note that at least either the "host" or the "path" keys will always be returned if a hash is returned):
  • protocol: the scheme in the URL (ex: "http")
  • path: any path given in the URL; the path will be prefixed by "/" if a hostname is found in the URL argument string, otherwise it will not if it was not given as such in the argument string
  • username: any username given in the URL
  • password: any password given in the URL
  • host: any hostname given in the URL; note that this key will be given if no other information can be found in the URL argument and the URL argument string has no "/" characters; depending on the usage context for this function, this may actually be a filename
  • port: any port number given in the URL
Example:
my *hash $hash = parseURL($url_string);
Note
URLs with UNIX sockets are generally supported in Qore with the following syntax: scheme://socket=<url_encoded_path>/path, where url_encoded_path is a path with URL-encoding as performed by encode_url(); for example: "http://socket=%2ftmp%socket-dir%2fsocket-file-1/url/path"; this allows a filesystem path to be used in the host portion of the URL and for the URL to include a URL path as well.
See also
parse_url() for a version of this function that throws exceptions if the URL cannot be parsed
nothing Qore::parseURL ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::splice ( string  str)

This function always returns an empty string "".

This function variant is included for backwards-compatibility

Code Flags:
NOOP
Parameters
strno action is taken on the argument
Returns
always returns an empty string ""
string Qore::splice ( string  str,
softint  start 
)

Returns a string based on the argument string but with characters removed from a certain character index.

An exception can only be thrown here if an invalid multi-byte encoding is found

Parameters
strthe string to process
startthe character index (where the first character is 0) to start removing characters; if this value is negative, it gives the offset from the end of the string
Returns
the processed string
Example:
my string $str = splice($str2, 5);
See also
the splice operator
string Qore::splice ( string  str,
softint  start,
softint  len,
*string  nstr 
)

Returns a string based on the argument string but optionally with characters removed and/or added from a certain character index.

An exception can only be thrown here if an invalid multi-byte encoding is found

Parameters
strthe string to process
startthe character index (where the first character is 0) to start removing (and/or adding) characters; if this value is negative, it gives the offset from the end of the string
lenthe number of characters to remove; if this argument is 0 then no characters are removed; if this value is negative, then it gives an offset from the end of the string (ie -2 means remove all characters up to but not including the two last characters)
nstrthe optional string for inserting new characters
Returns
the processed string with characters removed and/or added according to the arguments
Example:
my string $str = splice($str2, 5, 7, "hello");
See also
the splice operator
list Qore::splice ( list  l,
softint  start 
)

Returns a list based on the argument list but with elements removed from the given index to the end of the list.

Exceptions can only be thrown here if objects are removed from the list and this causes them to go out of scope and an exception is thrown in one of the destructors

Parameters
lthe list to process
startthe starting element (where the first element is 0) to start removing elements; if this value is negative, it gives the offset from the end of the list
Example:
my list $l = splice($l2, 5);
See also
the splice operator
list Qore::splice ( list  l,
softint  start,
softint  len,
*softlist  nlist 
)

Returns a list based on the argument list but optionally with elements removed and/or added from a certain index.

Exceptions can only be thrown here if objects are removed from the list and this causes them to go out of scope and an exception is thrown in one of the destructors

Parameters
lthe list to process
startthe starting element (where the first element is 0) to start removing (and/or adding) elements; if this value is negative, it gives the offset from the end of the list
lenthe number of list elements to remove; if this argument is 0 then no elements are removed; if this value is negative, then it gives an offset from the end of the list (ie -2 means remove all elements up to but not including the two last elements)
nlistthe optional list for inserting new elements
Returns
the processed list with elements removed and/or added according to the arguments
Example:
my list $l = splice($l2, 5, 7, "hello");
See also
the splice operator
nothing Qore::splice ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::strtoint ( string  num,
softint  base = 10 
)

parses a string representing a number in a configurable base and returns the integer

Parameters
numa string representing a number
basethe base of the number
Returns
the integer represented by the string and the base
Example:
my int $i = strtoint("41", 8);
Exceptions
STRTOINT-ERRORcannot parse string; unsupported base, etc
nothing Qore::strtoint ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP