Qore reflection Module  1.7.0
Qore::Reflection::Namespace Class Reference

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

Public Member Methods

 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< ClassgetClasses ()
 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< ConstantgetConstants ()
 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< FunctiongetFunctions ()
 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< GlobalVargetGlobalVars ()
 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< NamespacegetNamespaces ()
 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< TypedHashgetTypedHashes ()
 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< FunctionVariantgetVariants ()
 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 Methods

static list< NamespacefindAllRegex (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< NamespacefindAllRegex (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
paththe namespace name or namespace-justified path as a string; the root namespace is returned with an empty string or "::" argument
Exceptions
UNKNOWN-NAMESPACEcannot find a namespace 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<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
pgmthe Program object to search
patternthe regular expression pattern to match
re_optssee regex_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
patternthe regular expression pattern to match
re_optssee regex_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
pgmthe Program object to search
paththe 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-NAMESPACEcannot find a namespace 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 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
paththe 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-NAMESPACEcannot find a namespace 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

◆ 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-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-CLASSthrown if the class cannot be found
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

◆ 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-ERRORthrown 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-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-CONSTANTthrown if the constant cannot be found
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

◆ 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-ERRORthrown 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
namethe name of the function to find
Returns
given function or throws an exception if the function is not defined in this namespace
Exceptions
PROGRAM-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-FUNCTIONthrown if the function cannot be found
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

◆ 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-ERRORthrown 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-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-GLOBAL-VARthrown if the global variable cannot be found
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

◆ 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-NAMESPACEthrown if the namespace cannot be found
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

◆ 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-TYPED-HASHthrown if the typed hash (hashdecl) cannot be found
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

◆ 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-ERRORthrown 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
namethe 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-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-FUNCTIONthrown if the function cannot be found
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::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
namethe name of the function variant to find
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 namespace
Exceptions
PROGRAM-ERRORthrown if the Program object holding the namespace has been destroyed
UNKNOWN-FUNCTIONthrown if the function cannot be found
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::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-ERRORthrown 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-ERRORthrown 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
nsthe 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown 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-ERRORthrown if the Program object holding the namespace has been destroyed

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