| Qore reflection Module 1.14.0

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Qore::Reflection::AbstractVariant Class Reference

The abstract base class for Qore class variants. More...

`#include <QC_AbstractVariant.dox.h>`

Inheritance diagram for Qore::Reflection::AbstractVariant:

## Public Member Functions
| constructor ()
| Throws an exception if called directly; this class can only be instantiated by builtin subclasses.
bool | empty ()
| returns True if the variant has no code implementation; False if it does
list< string > | getCodeFlagList ()
| returns a list of strings of code flags describing the variant
int | getCodeFlags ()
| returns a bitfield of code flags describing the variant
list< auto > | getDefaultArgs ()
| returns a list of default arguments for parameters for the variant; if the variant has no parameters, an empty list is returned
int | getDomain ()
| returns the functional domain of the variant (for builtin variants only) as a bitfield of Functional Domain Constants
list< string > | getDomainStringList ()
| returns a list of functional domain strings for the variant (for builtin variants only); an empty list is returned for user variants
AbstractReflectionFunction | getFunction ()
| Returns the abstract function object that contains the variant.
list< string > | getModifierList ()
| returns a list of strings of modifiers describing the variant
int | getModifiers ()
| returns a bitfield of modifiers describing the variant
list< string > | getParamNames ()
| returns a list of parameter variable name for the variant; if the variant has no parameters, an empty list is returned
string | getParamString ()
| returns a string giving a list of the parameters of the variant, including types, variable names, and default values
list< Type > | getParamTypes ()
| returns a list of parameter types for the variant; if the variant has no parameters, an empty list is returned
Type | getReturnType ()
| returns the return type of the variant
string | getReturnTypeString ()
| returns a string for the return type
hash< SourceLocationInfo > | getSourceLocation ()
| Returns the source location of the variant declaration.
bool | hasBody ()
| returns True if the variant has a code implementation; False if not (i.e. it is empty)
bool | isBuiltin ()
| returns True if the variant is a builtin variant
bool | isEqual (AbstractVariant variant)
| Returns True if the variant passed as an argument is equal to the current object; False if not.
bool | isInjected ()
| returns True if the function or method that the variant belongs to (and therefore the variant itself) has been injected as a dependency injection
bool | isMethodVariant ()
| returns True if the variant is a method variant but not a pseudo-method variant
bool | isPseudoMethodVariant ()
| returns True if the object is a pseudo-method variant
bool | isUser ()
| returns True if the variant is a user variant
int | numParams ()
| returns the number of parameters in the signature
string | toString ()
| returns a string for the variant's signature including any modifiers (`"synchronized"`, `"private"`, etc), the return type, the class name (if any, without a namespace prefix and followed by `"::"`), and the function or method name followed by parameter types in parentheses

## Detailed Description

The abstract base class for Qore class variants.

Restrictions:
  Qore::PO_NO_REFLECTION

This class cannot be instantiated directly and also cannot be directly inherited by user-defined classes.

See also
  AbstractMethod

Since
  Qore 0.9.0

## Member Function Documentation

## ◆ constructor()

Qore::Reflection::AbstractVariant::constructor | ( |  | ) |

Throws an exception if called directly; this class can only be instantiated by builtin subclasses.

Exceptions

  ABSTRACTVARIANT-CONSTRUCTOR-ERROR | this exception is thrown if this class is constructed directly (also if directly inherited by user classes)

## ◆ empty()

bool Qore::Reflection::AbstractVariant::empty | ( |  | ) |

returns True if the variant has no code implementation; False if it does

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = v.isEmpty();

Returns
  True if the variant has no code implementation; False if it does

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

Note
  - complementary to hasBody()
  - abstract method variants will return True here

## ◆ getCodeFlagList()

list< string > Qore::Reflection::AbstractVariant::getCodeFlagList | ( |  | ) |

returns a list of strings of code flags describing the variant

Code Flags:
  RET_VALUE_ONLY

Example:
  list<string> l = v.getCodeFlagList();

Returns
  list of strings of code flags describing the variant; possible values are:
  - `"NOOP"`: the variant has the CF_NOOP flag set
  - `"USES_EXTRA_ARGS"`: the variant has the CF_USES_EXTRA_ARGS flag set
  - `"CONSTANT"`: the variant has the CF_CONSTANT flag set
  - `"DEPRECATED"`: the variant has the CF_DEPRECATED flag set
  - `"RET_VALUE_ONLY"`: the variant has the CF_RET_VALUE_ONLY flag set
  - `"RUNTIME_NOOP"`: the variant has the CF_RUNTIME_NOOP flag set

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

See also
  getCodeFlags()

## ◆ getCodeFlags()

int Qore::Reflection::AbstractVariant::getCodeFlags | ( |  | ) |

returns a bitfield of code flags describing the variant

Code Flags:
  CONSTANT

Example:
  int i = v.getCodeFlags();

Returns
  a bitfield of code flags describing the variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

See also
  getCodeFlagList()

## ◆ getDefaultArgs()

list< auto > Qore::Reflection::AbstractVariant::getDefaultArgs | ( |  | ) |

returns a list of default arguments for parameters for the variant; if the variant has no parameters, an empty list is returned

Code Flags:
  RET_VALUE_ONLY

Example:
  list<auto> l = v.getDefaultArgs();

Returns
  a list of default arguments for parameters for the variant; if the variant has no parameters, an empty list is returned

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ getDomain()

int Qore::Reflection::AbstractVariant::getDomain | ( |  | ) |

returns the functional domain of the variant (for builtin variants only) as a bitfield of Functional Domain Constants

Code Flags:
  RET_VALUE_ONLY

Example:
  int i = v.getDomain();

Returns
  the functional domain of the variant (for builtin variants only) as a bitfield of Functional Domain Constants

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

Note
  user variants always return 0 here; a value is only returned by builtin variants

## ◆ getDomainStringList()

list< string > Qore::Reflection::AbstractVariant::getDomainStringList | ( |  | ) |

returns a list of functional domain strings for the variant (for builtin variants only); an empty list is returned for user variants

Code Flags:
  RET_VALUE_ONLY

Example:
  list<string> l = v.getDomainStringList();

Returns
  a list of functional domain strings for the variant (for builtin variants only)

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

Note
  user variants always return an empty list here

## ◆ getFunction()

AbstractReflectionFunction Qore::Reflection::AbstractVariant::getFunction | ( |  | ) |

Returns the abstract function object that contains the variant.

Code Flags:
  RET_VALUE_ONLY

Example:
  AbstractReflectionFunction f = v.getFunction();

Returns
  the abstract function object that contains the variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ getModifierList()

list< string > Qore::Reflection::AbstractVariant::getModifierList | ( |  | ) |

returns a list of strings of modifiers describing the variant

Code Flags:
  RET_VALUE_ONLY

Example:
  list<string> l = v.getModifierList();

Returns
  list of strings of modifiers describing the variant; possible values are:
  - `"abstract"`: the variant is Abstract Methods
  - `"final"`: (only returned for method variants) the variant has the final flag set
  - `"private"`: (only returned for method variants) gives the accessibility of the variant
  - `"private:internal"`: (only returned for method variants) gives the accessibility of the variant
  - `"public"`: for function variants, the variant has the module public flag set on the function, for method variants, this gives the accessibility of the variant
  - `"static"`: (only returned for method variants) the variant is a static method variant
  - `"synchronized"`: the variant is synchronized

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

See also
  getModifiers()

## ◆ getModifiers()

int Qore::Reflection::AbstractVariant::getModifiers | ( |  | ) |

returns a bitfield of modifiers describing the variant

Code Flags:
  RET_VALUE_ONLY

Example:
  int i = v.getModifiers();

Returns
  a bitfield of modifiers describing the variant; possible values are:
  - MC_ABSTRACT: the variant is Abstract Methods
  - MC_FINAL: the variant has the final flag set
  - MC_PRIVATE: (only returned for method variants) gives the accessibility of the variant
  - MC_PRIVATEINTERNAL: (only returned for method variants) gives the accessibility of the variant
  - MC_PUBLIC: for functions, the variant has the module public flag set on the class or the function (not related to any inheritance properties in a class hierarchy), for method variants, this gives the accessibility of the variant
  - MC_STATIC: the variant is a static method variant
  - MC_SYNCHRONIZED: the variant is synchronized

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

See also
  getModifierList()

## ◆ getParamNames()

list< string > Qore::Reflection::AbstractVariant::getParamNames | ( |  | ) |

returns a list of parameter variable name for the variant; if the variant has no parameters, an empty list is returned

Code Flags:
  RET_VALUE_ONLY

Example:
  list<string> l = v.getParamNames();

Returns
  a list of parameter variable name for the variant; if the variant has no parameters, an empty list is returned

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ getParamString()

string Qore::Reflection::AbstractVariant::getParamString | ( |  | ) |

returns a string giving a list of the parameters of the variant, including types, variable names, and default values

Code Flags:
  RET_VALUE_ONLY

Example:
  string str = v.getParamString();
  # ex: "int num = 0, *string label"

Returns
  a string giving a list of the parameters of the variant, including types, variable names, and default values; an empty string is returned if the variant does not have any parameters

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ getParamTypes()

list< Type > Qore::Reflection::AbstractVariant::getParamTypes | ( |  | ) |

returns a list of parameter types for the variant; if the variant has no parameters, an empty list is returned

Code Flags:
  RET_VALUE_ONLY

Example:
  list<Type> l = v.getParamTypes();

Returns
  a list of parameter types for the variant; if the variant has no parameters, an empty list is returned

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ getReturnType()

Type Qore::Reflection::AbstractVariant::getReturnType | ( |  | ) |

returns the return type of the variant

Code Flags:
  RET_VALUE_ONLY

Example:
  Type t = v.getReturnType();

Returns
  the return type of the variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ getReturnTypeString()

string Qore::Reflection::AbstractVariant::getReturnTypeString | ( |  | ) |

returns a string for the return type

Code Flags:
  RET_VALUE_ONLY

Example:
  string str = v.getReturnTypeString();
  # ex: "int"

Returns
  a string for the return type

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ getSourceLocation()

hash< SourceLocationInfo > Qore::Reflection::AbstractVariant::getSourceLocation | ( |  | ) |

Returns the source location of the variant declaration.

Code Flags:
  RET_VALUE_ONLY

Example:
  hash<SourceLocationInfo> loc = v.getSourceLocation();

Returns
  the source location of the variant declaration

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ hasBody()

bool Qore::Reflection::AbstractVariant::hasBody | ( |  | ) |

returns True if the variant has a code implementation; False if not (i.e. it is empty)

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = v.hasBody();

Returns
  True if the variant has a code implementation; False if not (i.e. it is empty)

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

Note
  - complementary to empty()
  - abstract method variants will return False here

## ◆ isBuiltin()

bool Qore::Reflection::AbstractVariant::isBuiltin | ( |  | ) |

returns True if the variant is a builtin variant

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = v.isBuiltin();

Returns
  True if the variant is a builtin variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

Note
  complementary to isUser()

## ◆ isEqual()

bool Qore::Reflection::AbstractVariant::isEqual | ( | AbstractVariant | variant | ) |

Returns True if the variant passed as an argument is equal to the current object; False if not.

Code Flags:
  CONSTANT

Example:
  bool b = v1.isEqual(v2);

Parameters

  variant | the variant to check with the current object for equality

Returns
  True if the variant object passed as an argument is equal to the current object; False if not

Note
  if this method is called on variants from user classes created from the same source code but in different Program containers, it will return False

## ◆ isInjected()

bool Qore::Reflection::AbstractVariant::isInjected | ( |  | ) |

returns True if the function or method that the variant belongs to (and therefore the variant itself) has been injected as a dependency injection

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = v.isInjected();

Returns
  True if the function or method that the variant belongs to (and therefore the variant itself) has been injected as a dependency injection

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ isMethodVariant()

bool Qore::Reflection::AbstractVariant::isMethodVariant | ( |  | ) |

returns True if the variant is a method variant but not a pseudo-method variant

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = v.isMethodVariant();

Returns
  True if the variant is a method variant but not a pseudo-method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ isPseudoMethodVariant()

bool Qore::Reflection::AbstractVariant::isPseudoMethodVariant | ( |  | ) |

returns True if the object is a pseudo-method variant

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = f.isPseudoMethodVariant();

Returns
  True if the object is a pseudo-method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ isUser()

bool Qore::Reflection::AbstractVariant::isUser | ( |  | ) |

returns True if the variant is a user variant

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = v.isUser();

Returns
  True if the variant is a user variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

Note
  complementary to isBuiltin()

## ◆ numParams()

int Qore::Reflection::AbstractVariant::numParams | ( |  | ) |

returns the number of parameters in the signature

Code Flags:
  RET_VALUE_ONLY

Example:
  int n = v.numParams();

Returns
  the number of parameters in the signature

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

## ◆ toString()

string Qore::Reflection::AbstractVariant::toString | ( |  | ) |

returns a string for the variant's signature including any modifiers (`"synchronized"`, `"private"`, etc), the return type, the class name (if any, without a namespace prefix and followed by `"::"`), and the function or method name followed by parameter types in parentheses

Code Flags:
  RET_VALUE_ONLY

Example:
  string str = v.toString();

Returns
  a string for the variant's signature including any modifiers, the return type, the class name (if any, without a namespace prefix and followed by `"::"`), and the function or method name followed by parameter types in parentheses

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the function or method has been destroyed

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

- modules/reflection/src/QC_AbstractVariant.dox.h