Loading...
Searching...
No Matches
Qore::Reflection::Class Class Reference

This class provides information about Qore classes. More...

`#include <QC_Class.dox.h>`

Inheritance diagram for Qore::Reflection::Class:

## Public Member Functions

| constructor (string path)
| Creates the object from the class name or namespace-justified path as a string.
hash< MethodAccessInfo > | findMethod (string name)
| Returns information about the given method if it's accessible in the class hierarchy or throws an exception if the method does not exist.
hash< MethodAccessInfo > | findNormalMethod (string name)
| Returns information about the given normal (non-static) method if it's accessible in the class hierarchy or throws an exception if the method does not exist.
hash< MethodAccessInfo > | findStaticMethod (string name)
| Returns information about the given static method if it's accessible in the class hierarchy or throws an exception if the method does not exist.
list< Class > | getClassHierarchy ()
| Returns a list of all unique classes in the class hierarchy (including classes inherited with private:internal access protection) in constructor execution order; the current class is always returned in the last position of the list.
ClassConstant | getConstant (string name)
| Returns the given class constant or throws an exception if the constant is not defined.
list< ClassConstant > | getConstants ()
| Returns a list of all declared class constants.
ConstructorMethod | getConstructorMethod ()
| returns the given constructor method or throws an exception if the class does not implement a constructor method
ConstructorMethodVariant | getConstructorVariant (...)
| Returns the given constructor method variant, otherwise throws an exception if no constructor method variant can be matched.
ConstructorMethodVariant | getConstructorVariantArgs (*softlist< Type > argv)
| Returns the given constructor method variant, otherwise throws an exception if no constructor method variant can be matched.
list< ConstructorMethodVariant > | getConstructorVariants ()
| returns a list of all constructor method variants
CopyMethod | getCopyMethod ()
| returns the given copy method or throws an exception if the class does not implement a copy method
CopyMethodVariant | getCopyVariant ()
| Returns the copy method variant, otherwise throws an exception if no copy method variant has been defined.
DestructorMethod | getDestructorMethod ()
| returns the given destructor method or throws an exception if the class does not implement a destructor method
DestructorMethodVariant | getDestructorVariant ()
| Returns the destructor method variant, otherwise throws an exception if no destructor method variant has been defined.
*CopyMethodVariant | getIfCopyVariant ()
| returns the copy method variant or NOTHING if no copy method has been defined
*DestructorMethodVariant | getIfDestructorVariant ()
| returns the destructor variant or NOTHING if no destructor has been defined
int | getInheritanceAccess (Class base_class)
| Returns the accessibility of the class passed as an argument in the hierarchy of the current class as an access value or `0` if the argument class is not present in the current class's hierarchy at all.
AbstractClassMember | getMember (string name)
| returns the requested member or throws an exception if the member is not defined in the class
list< AbstractClassMember > | getMembers ()
| returns a list of all declared class members, non-static (first) and static (second) in declaration order
*string | getModuleName ()
| Returns the module name providing the class or NOTHING if the class was not provided by a module.
Namespace | getNamespace ()
| Returns the namespace for the class.
NormalMember | getNormalMember (string name)
| returns the requested normal (non-static) member or throws an exception if the normal member is not defined in the class
NormalMethod | getNormalMethod (string name)
| returns the given normal (non-special, non-static) method or throws an exception if the method does not exist
list< NormalMethod > | getNormalMethods ()
| returns a list of all normal (non-static, non-special) class methods
NormalMethodVariant | getNormalVariant (string name,...)
| returns the given normal (non-static, non-special) method variant, otherwise throws an exception if no method variant can be matched
NormalMethodVariant | getNormalVariantArgs (string name, *softlist< Type > argv)
| Returns the given normal (non-static, non-special) method variant, otherwise throws an exception if no method variant can be matched.
list< NormalMethodVariant > | getNormalVariants ()
| returns a list of all normal (non-static, non-special) method variants
Type | getOrNothingType ()
| Returns the "or nothing" type object for this class.
string | getPathName ()
| returns the class's full namespace-justified path name
StaticMember | getStaticMember (string name)
| returns the requested static member or throws an exception if the static member is not defined in the class
StaticMethod | getStaticMethod (string name)
| returns the given static method or throws an exception if the method does not exist
StaticMethodVariant | getStaticVariant (string name,...)
| Returns the given static method variant, otherwise throws an exception if no static method variant can be matched.
StaticMethodVariant | getStaticVariantArgs (string name, *softlist< Type > argv)
| Returns the given static method variant, otherwise throws an exception if no static method variant can be matched.
list< StaticMethodVariant > | getStaticVariants ()
| returns a list of all static method variants
Type | getType ()
| Returns the type object for this class.
bool | hasConstructorMethod ()
| returns True if the class has at least one constructor method variant
bool | hasCopyMethod ()
| returns True if the class has a copy method
bool | hasDestructorMethod ()
| returns True if the class has a destructor method
int | instanceOf (object obj)
| Returns the accessibility of the current class in the given object as an access value or `0` if the object does not inherit the class at all.
object | newObject (...)
| creates an object if the current class with the given arguments
object | newObjectArgs (*softlist argv)
| creates an object if the current class with the arguments for the constructor given as a list
Public Member Functions inherited from Qore::Reflection::AbstractClass
| constructor ()
| Throws an exception if called directly; this class can only be instantiated by builtin subclasses.
int | getDomain ()
| returns the functional domain of the class (for builtin classes only) as a bitfield of Functional Domain Constants
list< string > | getDomainStringList ()
| returns a list of functional domain strings for the class (for builtin classes only); an empty list is returned for user classes
binary | getHash ()
| returns a unique binary hash for the class
int | getId ()
| returns the internal ID of the class which is only valid for the current execution session
string | getLanguage ()
| returns the class's programming language
AbstractMethod | getMethod (string name)
| returns the given method or throws an exception if the method does not exist in the local class
list< AbstractMethod > | getMethods ()
| returns a list of all class methods including special and static methods
list< string > | getModifierList ()
| returns a list of strings of modifiers describing the class
int | getModifiers ()
| returns a bitfield of modifiers describing the class
string | getName ()
| returns the class's name
list< hash< ClassAccessInfo > > | getParentClasses ()
| Returns a list of immediate parent classes and access information; if the Class has no parent classes, then an empty list is returned.
AbstractMethodVariant | getVariant (string name,...)
| returns the given method variant, otherwise throws an exception if no method variant can be matched
AbstractMethodVariant | getVariantArgs (string name, *softlist< Type > argv)
| returns the given method variant, otherwise throws an exception if no method variant can be matched
list< AbstractMethodVariant > | getVariants ()
| returns a list of all class method variants including variants for special and static methods
bool | hasMemberGate ()
| returns True if the class implements a "memberGate" method
bool | hasMemberNotification ()
| returns True if the class implements a "memberNotification" method
bool | hasMethodGate ()
| returns True if the class implements a "methodGate" method
bool | isAbstract ()
| returns True if the class has at least one abstract method
bool | isBuiltin ()
| returns True if the class is a builtin class
bool | isEqual (AbstractClass cls)
| Returns True if the Class object passed as an argument is equal to the current object; False if not.
bool | isInjected ()
| returns True if the class was injected as a dependency injection
bool | isModulePublic ()
| returns True if the class has the module public flag set
bool | isPseudoClass ()
| returns True if the class is a pseudo-class
bool | isUser ()
| returns True if the class is a user class

## Static Public Member Functions

static list< Class > | findAllRegex (string pattern, *int re_opts)
| Returns a list of classes matching the regular expression pattern argument or an empty list if no classes match.
static list< Class > | findAllRegex (Program pgm, string pattern, *int re_opts)
| Returns a list of classes matching the regular expression pattern argument or an empty list if no classes match.
static Class | forName (string path)
| Returns a Class object from the class name or namespace-justified path as a string.
static Class | forName (Program pgm, string path)
| Returns a Class object from the class name or namespace-justified path as a string.
static Class | getClass (object obj)
| Returns the class for the object.

## Detailed Description

This class provides information about Qore classes.

Restrictions:
  Qore::PO_NO_REFLECTION

Since
  Qore 0.9

## Member Function Documentation

## constructor()

Qore::Reflection::Class::constructor | ( | string | path | ) |

Creates the object from the class name or namespace-justified path as a string.

Example:
  Class cls("Thread::Mutex");

Parameters

  path | the class name or namespace-justified path as a string

Exceptions

  UNKNOWN-CLASS | cannot find a class with the given name or path
  ENCODING-CONVERSION-ERROR | this 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< Class > Qore::Reflection::Class::findAllRegex | ( | Program | pgm,
|  | string | pattern,
|  | *int | re_opts )

static

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

Code Flags:
  RET_VALUE_ONLY

Example:
  # return all accessible classes that start with the letter "T"
  list<Class> l = Class::findAllRegex(pgm, "^T");

Parameters

  pgm | the Program object to search
  pattern | the regular expression pattern to match
  re_opts | see Regular Expression Constants for possible values

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

## findAllRegex() [2/2]

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

static

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

Code Flags:
  RET_VALUE_ONLY

Example:
  # return all accessible classes that start with the letter "T"
  list<Class> l = Class::findAllRegex("^T");

Parameters

  pattern | the regular expression pattern to match
  re_opts | see Regular Expression Constants for possible values

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

## findMethod()

hash< MethodAccessInfo > Qore::Reflection::Class::findMethod | ( | string | name | ) |

Returns information about the given method if it's accessible in the class hierarchy or throws an exception if the method does not exist.

Code Flags:
  RET_VALUE_ONLY

Example:
  hash<MethodAccessInfo> info = cls.findMethod(name);
  printf("find('%s::%s()': found '%s::%s()'; class access %y, variants: %d\n", cls.getName(), name,
  info.method.getClass().getName(), info.access_string, info.method.getVariants().size());

Searches the class hierarchy for normal methods (including special methods) and then static methods for the given method name

Parameters

  name | the name of the method

Returns
  information about the given method; the access information in the hash is the access of the class containing the method; to get the access modifier of any method variant, the maximum of the access value provided here and the access value of the variant must be taken.

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  METHOD-ERROR | unknown method
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

Note
  Methods group variants with the same name; see AbstractMethod::getVariant() for a method to retrieve a specific variant from a method.

See also
  - findNormalMethod()
  - findStaticMethod()
  - AbstractClass::getMethod()

## findNormalMethod()

hash< MethodAccessInfo > Qore::Reflection::Class::findNormalMethod | ( | string | name | ) |

Returns information about the given normal (non-static) method if it's accessible in the class hierarchy or throws an exception if the method does not exist.

Code Flags:
  RET_VALUE_ONLY

Example:
  hash<MethodAccessInfo> info = cls.findNormalMethod(name);
  printf("find('%s::%s()': found '%s::%s()'; class access %y, variants: %d\n", cls.getName(), name,
  info.method.getClass().getName(), info.access_string, info.method.getVariants().size());

Searches the class hierarchy for normal methods for the given method name

Parameters

  name | the name of the method

Returns
  information about the given method; the access information in the hash is the access of the class containing the method; to get the access modifier of any method variant, the maximum of the access value provided here and the access value of the variant must be taken.

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  METHOD-ERROR | unknown method
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

Note
  Methods group variants with the same name; see AbstractMethod::getVariant() for a method to retrieve a specific variant from a method.

See also
  - findMethod()
  - findStaticMethod()
  - AbstractClass::getMethod()

## findStaticMethod()

hash< MethodAccessInfo > Qore::Reflection::Class::findStaticMethod | ( | string | name | ) |

Returns information about the given static method if it's accessible in the class hierarchy or throws an exception if the method does not exist.

Code Flags:
  RET_VALUE_ONLY

Example:
  hash<MethodAccessInfo> info = cls.findStaticMethod(name);
  printf("find('%s::%s()': found '%s::%s()'; class access %y, variants: %d\n", cls.getName(), name,
  info.method.getClass().getName(), info.access_string, info.method.getVariants().size());

Searches the class hierarchy for static methods for the given method name

Parameters

  name | the name of the method

Returns
  information about the given method; the access information in the hash is the access of the class containing the method; to get the access modifier of any method variant, the maximum of the access value provided here and the access value of the variant must be taken.

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  METHOD-ERROR | unknown method
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

Note
  Methods group variants with the same name; see AbstractMethod::getVariant() for a method to retrieve a specific variant from a method.

See also
  - findMethod()
  - findNormalMethod()
  - AbstractClass::getMethod()

## forName() [1/2]

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

static

Returns a Class object from the class name or namespace-justified path as a string.

Code Flags:
  RET_VALUE_ONLY

Example:
  Class cls = Class::forName(pgm, "Thread::Mutex");

Parameters

  pgm | the Program object to search
  path | the class name or namespace-justified path as a string

Returns
  a class object corresponding to the name or namespace-justified path provided as an argument

Exceptions

  UNKNOWN-CLASS | cannot find a class with the given name or path
  ENCODING-CONVERSION-ERROR | this 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 Class Qore::Reflection::Class::forName | ( | string | path | ) |

static

Returns a Class object from the class name or namespace-justified path as a string.

Code Flags:
  RET_VALUE_ONLY

Example:
  Class cls = Class::forName("Thread::Mutex");

Parameters

  path | the class name or namespace-justified path as a string

Returns
  a class object corresponding to the name or namespace-justified path provided as an argument

Exceptions

  UNKNOWN-CLASS | cannot find a class with the given name or path
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

## getClass()

static Class Qore::Reflection::Class::getClass | ( | object | obj | ) |

static

Returns the class for the object.

Code Flags:
  CONSTANT

Example:
  Class cls = Class::getClass(obj);

Parameters

  obj | the object to return the class for

Returns
  the class for the object

## getClassHierarchy()

list< Class > Qore::Reflection::Class::getClassHierarchy | ( |  | ) |

Returns a list of all unique classes in the class hierarchy (including classes inherited with private:internal access protection) in constructor execution order; the current class is always returned in the last position of the list.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<Class> l = cls.getClassHierarchy();

Returns
  a list of all unique classes in the class hierarchy (including classes inherited with private:internal access protection) in constructor execution order; the current class is always returned in the last position of the list

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getConstant()

ClassConstant Qore::Reflection::Class::getConstant | ( | string | name | ) |

Returns the given class constant or throws an exception if the constant is not defined.

Code Flags:
  RET_VALUE_ONLY

Example:
  ClassConstant con = cls.getConstant(name);

Returns
  the given class constant or throws an exception if the constant is not defined

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  UNKNOWN-CONSTANT | thrown if the constant cannot be found
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

## getConstants()

list< ClassConstant > Qore::Reflection::Class::getConstants | ( |  | ) |

Returns a list of all declared class constants.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<ClassConstant> l = cls.getConstants();

Returns
  a list of all declared class constants

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getConstructorMethod()

ConstructorMethod Qore::Reflection::Class::getConstructorMethod | ( |  | ) |

returns the given constructor method or throws an exception if the class does not implement a constructor method

Code Flags:
  RET_VALUE_ONLY

Example:
  ConstructorMethod m = cls.getConstructorMethod();

Returns
  the given constructor method

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  METHOD-ERROR | the class does not implement a constructor method

See also
  - getMethod()
  - getNormalMethod()
  - getStaticMethod()
  - getDestructorMethod()
  - getCopyMethd()

## getConstructorVariant()

ConstructorMethodVariant Qore::Reflection::Class::getConstructorVariant | ( |  | ... | ) |

Returns the given constructor method variant, otherwise throws an exception if no constructor method variant can be matched.

Code Flags:
  RET_VALUE_ONLY

Example:
  ConstructorMethodVariant m = cls.getConstructorVariant(IntType, StringType);

Searches constructor methods only and then matches the arguments by type to return the variant

Parameters

  ... | Type arguments giving parameter types

Returns
  the given constructor method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | no constructor method defined
  VARIANT-MATCH-ERROR | no constructor method variant van be found matching the given argument types

See also
  - getConstructorVariantArgs()
  - getExactConstructorVariant()
  - getExactConstructorVariantArgs()

## getConstructorVariantArgs()

ConstructorMethodVariant Qore::Reflection::Class::getConstructorVariantArgs | ( | *softlist< Type > | argv | ) |

Returns the given constructor method variant, otherwise throws an exception if no constructor method variant can be matched.

Code Flags:
  RET_VALUE_ONLY

Example:
  ConstructorMethodVariant m = cls.getConstructorVariantArgs((IntType, StringType));

Searches static methods only for the given method name and and then matches the arguments by type

Parameters

  argv | Type arguments giving parameter types

Returns
  the given static method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | no constructor method defined
  VARIANT-MATCH-ERROR | no method constructor variant van be found matching the given argument types

See also
  - getConstructorVariant()
  - getExactConstructorVariant()
  - getExactConstructorVariantArgs()

## getConstructorVariants()

list< ConstructorMethodVariant > Qore::Reflection::Class::getConstructorVariants | ( |  | ) |

returns a list of all constructor method variants

Code Flags:
  RET_VALUE_ONLY

Example:
  list<ConstructorMethodVariant> l = cls.getConstructorVariants();

Returns
  a list of all constructor method variants

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getCopyMethod()

CopyMethod Qore::Reflection::Class::getCopyMethod | ( |  | ) |

returns the given copy method or throws an exception if the class does not implement a copy method

Code Flags:
  RET_VALUE_ONLY

Example:
  CopyMethod m = cls.getCopyMethod();

Returns
  the given copy method

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  METHOD-ERROR | the class does not implement a copy method

See also
  - getMethod()
  - getNormalMethod()
  - getStaticMethod()
  - getConstructorMethod()
  - getDestructorMethod()

## getCopyVariant()

CopyMethodVariant Qore::Reflection::Class::getCopyVariant | ( |  | ) |

Returns the copy method variant, otherwise throws an exception if no copy method variant has been defined.

Code Flags:
  RET_VALUE_ONLY

Example:
  CopyMethodVariant m = cls.getCopyVariant();

Searches copy methods only

Returns
  the given copy method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | no copy method defined

See also
  - getIfCopyVariant()

## getDestructorMethod()

DestructorMethod Qore::Reflection::Class::getDestructorMethod | ( |  | ) |

returns the given destructor method or throws an exception if the class does not implement a destructor method

Code Flags:
  RET_VALUE_ONLY

Example:
  DestructorMethod m = cls.getDestructorMethod();

Returns
  the given destructor method

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  METHOD-ERROR | the class does not implement a destructor method

See also
  - getMethod()
  - getNormalMethod()
  - getStaticMethod()
  - getConstructorMethod()
  - getCopyMethd()

## getDestructorVariant()

DestructorMethodVariant Qore::Reflection::Class::getDestructorVariant | ( |  | ) |

Returns the destructor method variant, otherwise throws an exception if no destructor method variant has been defined.

Code Flags:
  RET_VALUE_ONLY

Example:
  DestructorMethodVariant m = cls.getDestructorVariant();

Searches destructor methods only

Returns
  the given destructor method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | no destructor method defined

See also
  - getIfDestructorVariant()

## getIfCopyVariant()

*CopyMethodVariant Qore::Reflection::Class::getIfCopyVariant | ( |  | ) |

returns the copy method variant or NOTHING if no copy method has been defined

Code Flags:
  RET_VALUE_ONLY

Example:
  *CopyMethodVariant dv = cls.getIfCopyVariant();

Returns
  the copy method variant or NOTHING if no copy method has been defined

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

Note
  copy methods may not be overloaded, therefore if a copy method is defined, it will only have one variant

See also
  getCopyVariant()

## getIfDestructorVariant()

*DestructorMethodVariant Qore::Reflection::Class::getIfDestructorVariant | ( |  | ) |

returns the destructor variant or NOTHING if no destructor has been defined

Code Flags:
  RET_VALUE_ONLY

Example:
  *DestructorMethodVariant dv = cls.getIfDestructorVariant();

Returns
  the destructor variant or NOTHING if no destructor has been defined

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

See also
  getDestructorVariant()

## getInheritanceAccess()

int Qore::Reflection::Class::getInheritanceAccess | ( | Class | base_class | ) |

Returns the accessibility of the class passed as an argument in the hierarchy of the current class as an access value or `0` if the argument class is not present in the current class's hierarchy at all.

Code Flags:
  CONSTANT

Example:
  if (!cls.getInheritanceAccess(base_class)) {
  printf("class %y does not inherit class %y\n", cls.getPathName(), base_class.getPathName());
  }

Parameters

  base_class | the class to try to find in the current class's hieerarchy

Returns
  an access value giving the accessibility of the base class in the current class's hierarchy or `0` if the argument class is not present in the current class's hierarchy at all; see Access Constants for possible return values (plus `0` meaning no inheritance)

## getMember()

AbstractClassMember Qore::Reflection::Class::getMember | ( | string | name | ) |

returns the requested member or throws an exception if the member is not defined in the class

Code Flags:
  RET_VALUE_ONLY

Example:
  AbstractClassMember m = cls.getMember(name);

Returns
  the requested member or throws an exception if the member is not defined in the class

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  UNKNOWN-MEMBER | if the requested member is not defined in the class
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getNormalMember()
  - getStaticMember()

## getMembers()

list< AbstractClassMember > Qore::Reflection::Class::getMembers | ( |  | ) |

returns a list of all declared class members, non-static (first) and static (second) in declaration order

Code Flags:
  RET_VALUE_ONLY

Example:
  list<AbstractClassMember> l = cls.getMembers();

Returns
  a list of all declared class members, non-static (first) and static (second) in declaration order

Note
  only members declared in the local class are returned

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getModuleName()

*string Qore::Reflection::Class::getModuleName | ( |  | ) |

Returns the module name providing the class or NOTHING if the class was not provided by a module.

Code Flags:
  RET_VALUE_ONLY

Example:
  *string str = cls.getModuleName();

Returns
  the module name providing the class or NOTHING if the class was not provided by a module

## getNamespace()

Namespace Qore::Reflection::Class::getNamespace | ( |  | ) |

Returns the namespace for the class.

Code Flags:
  CONSTANT

Example:
  Namespace ns = cls.getNamespace();

Returns
  the namespace for the class

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getNormalMember()

NormalMember Qore::Reflection::Class::getNormalMember | ( | string | name | ) |

returns the requested normal (non-static) member or throws an exception if the normal member is not defined in the class

Code Flags:
  RET_VALUE_ONLY

Example:
  NormalMember m = cls.getNormalMember(name);

Returns
  the requested normal (non-static) member or throws an exception if the member is not defined in the class

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  UNKNOWN-NORMAL-MEMBER | if the requested normal (non-static) member is not defined in the class
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getMember()
  - getStaticMember()

## getNormalMethod()

NormalMethod Qore::Reflection::Class::getNormalMethod | ( | string | name | ) |

returns the given normal (non-special, non-static) method or throws an exception if the method does not exist

Code Flags:
  RET_VALUE_ONLY

Example:
  NormalMethod m = cls.getNormalMethod(name);

Parameters

  name | the name of the normal (non-special, non-static) method

Returns
  the given normal (non-special, non-static) method

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  UNKNOWN-METHOD | unknown method or method is not normal
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getMethod()
  - getStaticMethod()
  - getConstructorMethod()
  - getDestructorMethod()
  - getCopyMethd()

## getNormalMethods()

list< NormalMethod > Qore::Reflection::Class::getNormalMethods | ( |  | ) |

returns a list of all normal (non-static, non-special) class methods

Code Flags:
  RET_VALUE_ONLY

Example:
  list<NormalMethod> l = cls.getNormalMethods();

Returns
  a list of all normal (non-static, non-special) class methods

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getNormalVariant()

NormalMethodVariant Qore::Reflection::Class::getNormalVariant | ( | string | name,
|  |  | ... )

returns the given normal (non-static, non-special) method variant, otherwise throws an exception if no method variant can be matched

Code Flags:
  RET_VALUE_ONLY

Example:
  NormalMethodVariant m = cls.getNormalVariant(name, IntType, StringType);

Searches normal (non-static, non-special) methods only for the given method name and and then matches the arguments by type to return the variant.

Parameters

  name | the name of the normal (non-static, non-special) method
  ... | Type arguments giving parameter types

Returns
  the given normal (non-static, non-special) method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | unknown normal (non-static, non-special) method
  VARIANT-MATCH-ERROR | no normal (non-static, non-special) method variant van be found matching the given argument types
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getNormalVariantArgs()
  - getExactNormalVariant()
  - getExactNormalVariantArgs()

## getNormalVariantArgs()

NormalMethodVariant Qore::Reflection::Class::getNormalVariantArgs | ( | string | name,
|  | *softlist< Type > | argv )

Returns the given normal (non-static, non-special) method variant, otherwise throws an exception if no method variant can be matched.

Code Flags:
  RET_VALUE_ONLY

Example:
  NormalMethodVariant m = cls.getNormalVariantArgs(name, (IntType, StringType));

Searches normal (non-static, non-special) methods only for the given method name and and then matches the arguments by type

Parameters

  name | the name of the normal (non-static, non-special) method
  argv | Type arguments giving parameter types

Returns
  the given normal (non-static, non-special) method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | unknown normal (non-static, non-special) method
  VARIANT-MATCH-ERROR | no normal (non-static, non-special) method variant van be found matching the given argument types
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getNormalVariant()
  - getExactNormalVariant()
  - getExactNormalVariantArgs()

## getNormalVariants()

list< NormalMethodVariant > Qore::Reflection::Class::getNormalVariants | ( |  | ) |

returns a list of all normal (non-static, non-special) method variants

Code Flags:
  RET_VALUE_ONLY

Example:
  list<NormalMethodVariant> l = cls.getNormalVariants();

Returns
  a list of all normal (non-static, non-special) method variants

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getOrNothingType()

Type Qore::Reflection::Class::getOrNothingType | ( |  | ) |

Returns the "or nothing" type object for this class.

Code Flags:
  RET_VALUE_ONLY

Example:
  Type t = cls.getOrNothingType();

Returns
  the "or nothing" type object for this class

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

See also
  getType()

## getPathName()

string Qore::Reflection::Class::getPathName | ( |  | ) |

returns the class's full namespace-justified path name

Code Flags:
  RET_VALUE_ONLY

Example:
  string name = cls.getPathName();

Returns
  the class's full namespace-justified path name

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

See also
  getName()

## getStaticMember()

StaticMember Qore::Reflection::Class::getStaticMember | ( | string | name | ) |

returns the requested static member or throws an exception if the static member is not defined in the class

Code Flags:
  RET_VALUE_ONLY

Example:
  StaticMember m = cls.getStaticMember(name);

Returns
  the requested static member or throws an exception if the member is not defined in the class

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  UNKNOWN-STATIC-MEMBER | if the requested static member is not defined in the class
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getMember()
  - getNormalMember()

## getStaticMethod()

StaticMethod Qore::Reflection::Class::getStaticMethod | ( | string | name | ) |

returns the given static method or throws an exception if the method does not exist

Code Flags:
  RET_VALUE_ONLY

Example:
  StaticMethod m = cls.getStaticMethod(name);

Parameters

  name | the name of the static method

Returns
  the given static method

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  UNKNOWN-METHOD | unknown method or method is not static
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getMethod()
  - getNormalMethod()
  - getConstructorMethod()
  - getDestructorMethod()
  - getCopyMethd()

## getStaticVariant()

StaticMethodVariant Qore::Reflection::Class::getStaticVariant | ( | string | name,
|  |  | ... )

Returns the given static method variant, otherwise throws an exception if no static method variant can be matched.

Code Flags:
  RET_VALUE_ONLY

Example:
  StaticMethodVariant m = cls.getStaticVariant(name, IntType, StringType);

Searches static methods only for the given method name and and then matches the arguments by type to return the variant

Parameters

  name | the name of the static method
  ... | Type arguments giving parameter types

Returns
  the given static method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | unknown static method
  VARIANT-MATCH-ERROR | no static method variant van be found matching the given argument types
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getStaticVariantArgs()
  - getExactStaticVariant()
  - getExactStaticVariantArgs()

## getStaticVariantArgs()

StaticMethodVariant Qore::Reflection::Class::getStaticVariantArgs | ( | string | name,
|  | *softlist< Type > | argv )

Returns the given static method variant, otherwise throws an exception if no static method variant can be matched.

Code Flags:
  RET_VALUE_ONLY

Example:
  StaticMethodVariant m = cls.getStaticVariantArgs(name, (IntType, StringType));

Searches static methods only for the given method name and and then matches the arguments by type

Parameters

  name | the name of the static method
  argv | Type arguments giving parameter types

Returns
  the given static method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  GETVARIANT-ERROR | invalid argument to method
  METHOD-ERROR | unknown static method
  VARIANT-MATCH-ERROR | no method static variant van be found matching the given argument types
  ENCODING-CONVERSION-ERROR | this exception could be thrown if the string argument is not in the default character encoding and an error occurs during encoding conversion

See also
  - getStaticVariant()
  - getExactStaticVariant()
  - getExactStaticVariantArgs()

## getStaticVariants()

list< StaticMethodVariant > Qore::Reflection::Class::getStaticVariants | ( |  | ) |

returns a list of all static method variants

Code Flags:
  RET_VALUE_ONLY

Example:
  list<StaticMethodVariant> l = cls.getStaticVariants();

Returns
  a list of all static method variants

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## getType()

Type Qore::Reflection::Class::getType | ( |  | ) |

Returns the type object for this class.

Code Flags:
  RET_VALUE_ONLY

Example:
  Type t = cls.getType();

Returns
  the type object for this class

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

See also
  getOrNothingType()

## hasConstructorMethod()

bool Qore::Reflection::Class::hasConstructorMethod | ( |  | ) |

returns True if the class has at least one constructor method variant

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = cls.hasConstructorMethod();

Returns
  True if the class has at least one constructor method variant

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## hasCopyMethod()

bool Qore::Reflection::Class::hasCopyMethod | ( |  | ) |

returns True if the class has a copy method

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = cls.hasCopyMethod();

Returns
  True if the class has a copy method

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## hasDestructorMethod()

bool Qore::Reflection::Class::hasDestructorMethod | ( |  | ) |

returns True if the class has a destructor method

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = cls.hasDestructorMethod();

Returns
  True if the class has a destructor method

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed

## instanceOf()

int Qore::Reflection::Class::instanceOf | ( | object | obj | ) |

Returns the accessibility of the current class in the given object as an access value or `0` if the object does not inherit the class at all.

Code Flags:
  CONSTANT

Example:
  if (!cls.instanceOf(obj)) {
  printf("object of class %y does not inherit %y\n", obj.className(), cls.getPathName());
  }

Parameters

  obj | the object to test

Returns
  an access value giving the accessibility of the class in the object or `0` if the object does not inherit the class at all; see Access Constants for possible return values (plus `0` meaning no inheritance)

## newObject()

object Qore::Reflection::Class::newObject | ( |  | ... | ) |

creates an object if the current class with the given arguments

Example:
  object o = cls.newObject();

Parameters

  ... | the arguments for the cosntructor, if any

Returns
  an object if the current class based on the constructor arguments passed

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  CREATE-OBJECT-ERROR | class implements features restricted by current parse options / sandboxing restrictions
  CONSTRUCTOR-IS-PRIVATE | attempt to instantiate an object with a private constructor from outside the class
  ABSTRACT-CLASS-ERROR | thrown if the class has abstract methods

Note
  see the class documentation for the class to be instantiated for a list of additional exceptions that can be thrown

See also
  - newObjectArgs()
  - create_object()
  - create_object_args()

## newObjectArgs()

object Qore::Reflection::Class::newObjectArgs | ( | *softlist | argv | ) |

creates an object if the current class with the arguments for the constructor given as a list

Example:
  object o = cls.newObjectArgs(args);

Parameters

  argv | the arguments for the constructor

Returns
  an object if the current class based on the constructor arguments passed

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the class has been destroyed
  CREATE-OBJECT-ERROR | class implements features restricted by current parse options / sandboxing restrictions
  CONSTRUCTOR-IS-PRIVATE | attempt to instantiate an object with a private constructor from outside the class
  ABSTRACT-CLASS-ERROR | thrown if the class has abstract methods

Note
  see the class documentation for the class to be instantiated for a list of additional exceptions that can be thrown

See also
  - newObject()
  - create_object()
  - create_object_args()

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

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