Qore reflection Module  1.9.1
Qore::Reflection::Function Class Reference

A class representing a Qore function. More...

Inheritance diagram for Qore::Reflection::Function:
Qore::Reflection::AbstractReflectionFunction

Public Member Methods

auto call (...)
 calls the function with the given arguments More...
 
auto callArgs (*softlist< auto > argv)
 calls the given function with the given arguments as a list More...
 
 constructor (string path)
 Creates the function from the name or namespace-justified path supplied as an argument. More...
 
FunctionVariant getVariant (...)
 Returns the given direct child function variant declared in this function or throws an exception if the function variant is not defined. More...
 
FunctionVariant getVariantArgs (softlist< Type > argv)
 Returns the given direct child function variant declared in this function or throws an exception if the function variant is not defined. More...
 
list< FunctionVariantgetVariants ()
 returns the variants implemented by the function More...
 
- Public Member Methods inherited from Qore::Reflection::AbstractReflectionFunction
 constructor ()
 Throws an exception if called directly; this class can only be instantiated by builtin subclasses. More...
 
list< string > getCodeFlagList ()
 returns a list of strings of code flags common to all variants for this function More...
 
int getCodeFlags ()
 returns a bitfield of code flags common to all variants for this function More...
 
int getDomain ()
 returns the functional domain common to all variants for this function (for builtin functions only) as a bitfield of functional_domain_constants More...
 
list< string > getDomainStringList ()
 returns a list of functional domain strings common to all variants for this function (for builtin functions only); an empty list is returned for user functions More...
 
*string getModuleName ()
 Returns the module name providing the function or method or nothing if the function or method was not provided by a module. More...
 
string getName ()
 returns the function or method name More...
 
bool isBuiltin ()
 returns True if the function or method is a builtin function or method More...
 
bool isEqual (AbstractReflectionFunction func)
 Returns True if the function or method object passed as an argument is equal to the current object; False if not. More...
 
bool isInjected ()
 returns True if the function or method has been injected as a dependency injection More...
 
bool isMethod ()
 returns True if the object is a method but not a pseudo-method More...
 
bool isPseudoMethod ()
 returns True if the object is a pseudo-method More...
 
bool isUser ()
 returns True if the function or method is a user function or method More...
 
int numVariants ()
 returns the number of variants implemented by the function or method More...
 

Static Public Member Methods

static list< FunctionfindAllRegex (string pattern, *int re_opts)
 Returns a list of functions matching the regular expression pattern argument or an empty list if no functions match. More...
 
static list< FunctionfindAllRegex (Program pgm, string pattern, *int re_opts)
 Returns a list of functions matching the regular expression pattern argument or an empty list if no functions match. More...
 
static Function forName (string path)
 Returns a Function object from the function name or namespace-justified path as a string. More...
 
static Function forName (Program pgm, string path)
 Returns a Function object from the function name or namespace-justified path as a string. More...
 

Detailed Description

A class representing a Qore function.

Restrictions:
Qore::PO_NO_REFLECTION
Since
Qore 0.9.0

Member Function Documentation

◆ call()

auto Qore::Reflection::Function::call (   ...)

calls the function with the given arguments

Example:
auto v = f.call(arg1, arg2);
Parameters
...optional arguments to the function
Returns
the return value of the function call
Exceptions
PROGRAM-ERRORthrown if the Program object holding the function has been destroyed
See also
callArgs()

◆ callArgs()

auto Qore::Reflection::Function::callArgs ( *softlist< auto >  argv)

calls the given function with the given arguments as a list

Example:
auto v = f.callArgs(argv);
Parameters
argvoptional arguments to the function
Returns
the return value of the function call
Exceptions
PROGRAM-ERRORthrown if the Program object holding the function has been destroyed
See also
call()

◆ constructor()

Qore::Reflection::Function::constructor ( string  path)

Creates the function from the name or namespace-justified path supplied as an argument.

Example:
Function f("Qore::printf");
Parameters
paththe function name or namespace-justified path as a string
Exceptions
UNKNOWN-FUNCTIONcannot find a function with the given name or path
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion
See also
forName()

◆ findAllRegex() [1/2]

static list<Function> Qore::Reflection::Function::findAllRegex ( Program  pgm,
string  pattern,
*int  re_opts 
)
static

Returns a list of functions matching the regular expression pattern argument or an empty list if no functions match.

Code Flags:
RET_VALUE_ONLY
Example:
# return all accessible functions that start with the letter "g"
list<Function> l = Function::findAllRegex(pgm, "^gg");
Parameters
pgmthe Program object to search
patternthe regular expression pattern to match
re_optssee regex_constants for possible values
Returns
a list of functions matching the regular expression pattern argument or an empty list if no functions match

◆ findAllRegex() [2/2]

static list<Function> Qore::Reflection::Function::findAllRegex ( string  pattern,
*int  re_opts 
)
static

Returns a list of functions matching the regular expression pattern argument or an empty list if no functions match.

Code Flags:
RET_VALUE_ONLY
Example:
# return all accessible functions that start with the letter "g"
list<Function> l = Function::findAllRegex("^gg");
Parameters
patternthe regular expression pattern to match
re_optssee regex_constants for possible values
Returns
a list of functions matching the regular expression pattern argument or an empty list if no functions match

◆ forName() [1/2]

static Function Qore::Reflection::Function::forName ( Program  pgm,
string  path 
)
static

Returns a Function object from the function name or namespace-justified path as a string.

Code Flags:
RET_VALUE_ONLY
Example:
Function f = Function::forName(pgm, "Qore::printf");
Parameters
pgmthe Program object to search
paththe function name or namespace-justified path as a string
Returns
a function object corresponding to the name or namespace-justified path provided as an argument
Exceptions
UNKNOWN-FUNCTIONcannot find a function with the given name or path
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

◆ forName() [2/2]

static Function Qore::Reflection::Function::forName ( string  path)
static

Returns a Function object from the function name or namespace-justified path as a string.

Code Flags:
RET_VALUE_ONLY
Example:
Function f = Function::forName("Qore::printf");
Parameters
paththe function name or namespace-justified path as a string
Returns
a function object corresponding to the name or namespace-justified path provided as an argument
Exceptions
UNKNOWN-FUNCTIONcannot find a function with the given name or path
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

◆ getVariant()

FunctionVariant Qore::Reflection::Function::getVariant (   ...)

Returns the given direct child function variant declared in this function or throws an exception if the function variant is not defined.

Code Flags:
RET_VALUE_ONLY
Example:
FunctionVariant v = n.getVariant(IntType, StringType);
Parameters
...type arguments for the variant; types must be compatible for the search to be successful
Returns
given function variant or throws an exception if the function variant is not defined in this function
Exceptions
PROGRAM-ERRORthrown if the Program object holding the function has been destroyed
VARIANT-MATCH-ERRORthrown if the function variant cannot be matched to the given arguments
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion
See also

◆ getVariantArgs()

FunctionVariant Qore::Reflection::Function::getVariantArgs ( softlist< Type argv)

Returns the given direct child function variant declared in this function or throws an exception if the function variant is not defined.

Code Flags:
RET_VALUE_ONLY
Example:
FunctionVariant v = n.getVariantArgs((IntType, StringType));
Parameters
argvtype arguments for the variant; types must be compatible for the search to be successful
Returns
given function variant or throws an exception if the function variant is not defined in this function
Exceptions
PROGRAM-ERRORthrown if the Program object holding the function has been destroyed
VARIANT-MATCH-ERRORthrown if the function variant cannot be matched to the given arguments
ENCODING-CONVERSION-ERRORthis exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion
See also

◆ getVariants()

list<FunctionVariant> Qore::Reflection::Function::getVariants ( )

returns the variants implemented by the function

Code Flags:
RET_VALUE_ONLY
Example:
list<FunctionVariant> l = f.getVariants();
Returns
the variants implemented by the function
Exceptions
PROGRAM-ERRORthrown if the Program object holding the function has been destroyed

The documentation for this class was generated from the following file: