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

This namespace provides information about Qore namespaces. More...

`#include <QC_Namespace.dox.h>`

## Public Member Functions

| constructor (string path)
| Creates the object from the name name or namespace-justified path as a string. More...
Class | getClass (string name)
| Returns the given direct child class declared in this namespace or throws an exception if the class is not defined. More...
list< Class > | getClasses ()
| Returns a list of all declared classes in the namespace. More...
Constant | getConstant (string name)
| Returns the given constant or throws an exception if the constant is not defined. More...
list< Constant > | getConstants ()
| Returns a list of all declared constants in the namespace. More...
Function | getFunction (string name)
| Returns the given direct child function declared in this namespace or throws an exception if the function is not defined. More...
list< Function > | getFunctions ()
| Returns a list of all declared functions in the namespace. More...
GlobalVar | getGlobalVar (string name)
| Returns the given direct child global variable declared in this namespace or throws an exception if the global variable is not defined. More...
list< GlobalVar > | getGlobalVars ()
| Returns a list of all declared global variables in the namespace. More...
list< string > | getModifierList ()
| returns a list of strings of modifiers describing the namespace More...
int | getModifiers ()
| returns a bitfield of modifiers describing the namespace More...
*string | getModuleName ()
| Returns the module name providing the namespace or NOTHING if the namespace was not provided by a module. More...
string | getName ()
| returns the namespace's name More...
Namespace | getNamespace (string name)
| Returns the given direct child namespace or throws an exception if the namespace is not defined. More...
list< Namespace > | getNamespaces ()
| Returns a list of all declared namespaces in the namespace. More...
*Namespace | getParentNamespace ()
| Returns the parent namespace, if any (the root namespace has no parent); if the Namespace has no parent, then NOTHING is returned. More...
string | getPathName ()
| returns the namespace's full namespace-justified path name More...
TypedHash | getTypedHash (string name)
| Returns the given direct child typed hash (hashdecl) declared in this namespace or throws an exception if the global variable is not defined. More...
list< TypedHash > | getTypedHashes ()
| Returns a list of all declared typed hashes (hashdecls) in the namespace. More...
FunctionVariant | getVariant (string name,...)
| Returns the given direct child function variant declared in this namespace or throws an exception if the function variant is not defined. More...
FunctionVariant | getVariantArgs (string name, softlist< Type > argv)
| Returns the given direct child function variant declared in this namespace or throws an exception if the function variant is not defined. More...
list< FunctionVariant > | getVariants ()
| Returns a list of all declared function variants in the namespace. More...
bool | isBuiltin ()
| returns True if the namespace is a builtin namespace More...
bool | isEqual (Namespace ns)
| Returns True if the Namespace object passed as an argument is equal to the current object; False if not. More...
bool | isImported ()
| returns True if the namespace has been imported from another Program object More...
bool | isModulePublic ()
| returns True if the namespace has the module public flag set More...
bool | isRoot ()
| returns True if the namespace is the root namespace More...
bool | isUser ()
| returns True if the namespace is a user namespace More...

## Static Public Member Functions

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

## Detailed Description

This namespace provides information about Qore namespaces.

Restrictions:
  Qore::PO_NO_REFLECTION

Since
  Qore 0.9

## Member Function Documentation

## constructor()

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

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

Example:
  Namespace ns("Qore::Thread");

Parameters

  path | the namespace name or namespace-justified path as a string; the root namespace is returned with an empty string or `"::"` argument

Exceptions

  UNKNOWN-NAMESPACE | cannot find a namespace 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< Namespace > Qore::Reflection::Namespace::findAllRegex | ( | Program | pgm,
|  | string | pattern,
|  | *int | re_opts
| ) |  |

static

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

Code Flags:
  RET_VALUE_ONLY

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

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 namespaces matching the regular expression pattern argument or an empty list if no namespaces match

## findAllRegex() [2/2]

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

static

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

Code Flags:
  RET_VALUE_ONLY

Example:
  # return all accessible namespaces that start with the letter "g"
  list<Namespace> l = Namespace::findAllRegex("^g");

Parameters

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

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

## forName() [1/2]

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

static

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

Code Flags:
  RET_VALUE_ONLY

Example:
  Namespace n = Namespace::forName(pgm, "Thread::Mutex");

Parameters

  pgm | the Program object to search
  path | the namespace name or namespace-justified path as a string; the root namespace is returned with an empty string or `"::"` argument

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

Exceptions

  UNKNOWN-NAMESPACE | cannot find a namespace 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 Namespace Qore::Reflection::Namespace::forName | ( | string | path | ) |

static

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

Code Flags:
  RET_VALUE_ONLY

Example:
  Namespace n = Namespace::forName("Thread::Mutex");

Parameters

  path | the namespace name or namespace-justified path as a string; the root namespace is returned with an empty string or `"::"` argument

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

Exceptions

  UNKNOWN-NAMESPACE | cannot find a namespace 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()

Class Qore::Reflection::Namespace::getClass | ( | string | name | ) |

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

Code Flags:
  RET_VALUE_ONLY

Example:
  Class cls = n.getClass(name);

Returns
  given class or throws an exception if the class is not defined in this namespace

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace has been destroyed
  UNKNOWN-CLASS | thrown if the class 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

## getClasses()

list< Class > Qore::Reflection::Namespace::getClasses | ( |  | ) |

Returns a list of all declared classes in the namespace.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<Class> l = n.getClasses();

Returns
  a list of all declared classes in the namespace

Exceptions

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

## getConstant()

Constant Qore::Reflection::Namespace::getConstant | ( | string | name | ) |

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

Code Flags:
  RET_VALUE_ONLY

Example:
  Constant con = n.getConstant(name);

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

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace 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< Constant > Qore::Reflection::Namespace::getConstants | ( |  | ) |

Returns a list of all declared constants in the namespace.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<Constant> l = n.getConstants();

Returns
  a list of all declared constants in the namespace

Exceptions

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

## getFunction()

Function Qore::Reflection::Namespace::getFunction | ( | string | name | ) |

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

Code Flags:
  RET_VALUE_ONLY

Example:
  Function f = n.getFunction(name);

Parameters

  name | the name of the function to find

Returns
  given function or throws an exception if the function is not defined in this namespace

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace has been destroyed
  UNKNOWN-FUNCTION | thrown if the function 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

## getFunctions()

list< Function > Qore::Reflection::Namespace::getFunctions | ( |  | ) |

Returns a list of all declared functions in the namespace.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<Function> l = n.getFunctions();

Returns
  a list of all declared functions in the namespace

Exceptions

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

## getGlobalVar()

GlobalVar Qore::Reflection::Namespace::getGlobalVar | ( | string | name | ) |

Returns the given direct child global variable declared in this namespace or throws an exception if the global variable is not defined.

Code Flags:
  RET_VALUE_ONLY

Example:
  GlobalVar cls = n.getGlobalVar(name);

Returns
  given global variable or throws an exception if the global variable is not defined in this namespace

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace has been destroyed
  UNKNOWN-GLOBAL-VAR | thrown if the global variable 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

## getGlobalVars()

list< GlobalVar > Qore::Reflection::Namespace::getGlobalVars | ( |  | ) |

Returns a list of all declared global variables in the namespace.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<GlobalVar> l = n.getGlobalVars();

Returns
  a list of all declared global variables in the namespace

Exceptions

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

## getModifierList()

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

returns a list of strings of modifiers describing the namespace

Code Flags:
  RET_VALUE_ONLY

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

Returns
  list of strings of modifiers describing the namespace; possible values are:
  - `"public"`: the namespace has the module public flag set

Exceptions

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

See also
  getModifiers()

## getModifiers()

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

returns a bitfield of modifiers describing the namespace

Code Flags:
  RET_VALUE_ONLY

Example:
  int i = n.getModifiers();

Returns
  a bitfield of modifiers describing the namespace; possible values are:
  - MC_PUBLIC: the namespace has the module public flag set

Exceptions

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

See also
  getModifierList()

## getModuleName()

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

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

Code Flags:
  RET_VALUE_ONLY

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

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

Since
  Qore 0.9.5

## getName()

string Qore::Reflection::Namespace::getName | ( |  | ) |

returns the namespace's name

Code Flags:
  RET_VALUE_ONLY

Example:
  string name = ns.getName();

Returns
  the namespace's name

Exceptions

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

See also
  getPathName()

## getNamespace()

Namespace Qore::Reflection::Namespace::getNamespace | ( | string | name | ) |

Returns the given direct child namespace or throws an exception if the namespace is not defined.

Code Flags:
  RET_VALUE_ONLY

Example:
  Namespace con = n.getNamespace(name);

Returns
  given namespace or throws an exception if the namespace is not defined

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace has been destroyed
  UNKNOWN-NAMESPACE | thrown if the namespace 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

## getNamespaces()

list< Namespace > Qore::Reflection::Namespace::getNamespaces | ( |  | ) |

Returns a list of all declared namespaces in the namespace.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<Namespace> l = n.getNamespaces();

Returns
  a list of all declared namespaces in the namespace

Exceptions

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

## getParentNamespace()

*Namespace Qore::Reflection::Namespace::getParentNamespace | ( |  | ) |

Returns the parent namespace, if any (the root namespace has no parent); if the Namespace has no parent, then NOTHING is returned.

Code Flags:
  RET_VALUE_ONLY

Example:
  *Namespace parent = n.getParentNamespace();

Returns
  the parent namespace, if any (the root namespace has no parent); if the Namespace has no parent, then NOTHING is returned

Exceptions

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

## getPathName()

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

returns the namespace's full namespace-justified path name

Code Flags:
  RET_VALUE_ONLY

Example:
  string name = n.getPathName();

Returns
  the namespace's full namespace-justified path name

Exceptions

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

See also
  getName()

## getTypedHash()

TypedHash Qore::Reflection::Namespace::getTypedHash | ( | string | name | ) |

Returns the given direct child typed hash (hashdecl) declared in this namespace or throws an exception if the global variable is not defined.

Code Flags:
  RET_VALUE_ONLY

Example:
  TypedHash th = n.getTypedHash(name);

Returns
  given typed hash (hashdecl) or throws an exception if the typed hash (hashdecl) is not defined in this namespace

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace has been destroyed
  UNKNOWN-TYPED-HASH | thrown if the typed hash (hashdecl) 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

## getTypedHashes()

list< TypedHash > Qore::Reflection::Namespace::getTypedHashes | ( |  | ) |

Returns a list of all declared typed hashes (hashdecls) in the namespace.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<TypedHash> l = n.getTypedHashes();

Returns
  a list of all declared typed hashes (hashdecls) in the namespace

Exceptions

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

## getVariant()

FunctionVariant Qore::Reflection::Namespace::getVariant | ( | string | name,
|  |  | ...
| ) |  |

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

Code Flags:
  RET_VALUE_ONLY

Example:
  FunctionVariant v = n.getVariant(name, IntType, StringType);

Parameters

  name | the name of the function variant to find
  ... | 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 namespace

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace has been destroyed
  UNKNOWN-FUNCTION | thrown if the function cannot be found
  VARIANT-MATCH-ERROR | thrown if the function variant cannot be matched to the given arguments
  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
  - getVariantArgs()
  - getExactVariant()
  - getExactVariantArgs()

## getVariantArgs()

FunctionVariant Qore::Reflection::Namespace::getVariantArgs | ( | string | name,
|  | softlist< Type > | argv
| ) |  |

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

Code Flags:
  RET_VALUE_ONLY

Example:
  FunctionVariant v = n.getVariantArgs(name, (IntType, StringType));

Parameters

  name | the name of the function variant to find
  argv | 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 namespace

Exceptions

  PROGRAM-ERROR | thrown if the Program object holding the namespace has been destroyed
  UNKNOWN-FUNCTION | thrown if the function cannot be found
  VARIANT-MATCH-ERROR | thrown if the function variant cannot be matched to the given arguments
  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
  - getVariant()
  - getExactVariant()
  - getExactVariantArgs()

## getVariants()

list< FunctionVariant > Qore::Reflection::Namespace::getVariants | ( |  | ) |

Returns a list of all declared function variants in the namespace.

Code Flags:
  RET_VALUE_ONLY

Example:
  list<FunctionVariant> l = n.getVariants();

Returns
  a list of all declared function variants in the namespace

Exceptions

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

## isBuiltin()

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

returns True if the namespace is a builtin namespace

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = n.isBuiltin();

Exceptions

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

## isEqual()

bool Qore::Reflection::Namespace::isEqual | ( | Namespace | ns | ) |

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

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = n1.isEqual(n2);

Parameters

  ns | the namespace to check with the current object for equality

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

Exceptions

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

## isImported()

bool Qore::Reflection::Namespace::isImported | ( |  | ) |

returns True if the namespace has been imported from another Program object

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = n.isImported();

Returns
  True if the namespace has been imported from another Program object

Exceptions

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

## isModulePublic()

bool Qore::Reflection::Namespace::isModulePublic | ( |  | ) |

returns True if the namespace has the module public flag set

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = n.isModulePublic();

Exceptions

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

## isRoot()

bool Qore::Reflection::Namespace::isRoot | ( |  | ) |

returns True if the namespace is the root namespace

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = n.isRoot();

Returns
  True if the namespace is the root namespace

Exceptions

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

## isUser()

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

returns True if the namespace is a user namespace

Code Flags:
  RET_VALUE_ONLY

Example:
  bool b = n.isUser();

Exceptions

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

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

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