Qore Programming Language  0.9.2
QoreNamespace Class Reference

contains constants, classes, and subnamespaces in QoreProgram objects More...

#include <QoreNamespace.h>

Inheritance diagram for QoreNamespace:

Public Member Methods

DLLEXPORT QoreNamespace (const char *n)
 creates a namespace with the given name More...
 
DLLEXPORT QoreNamespace (const char *n)
 creates a namespace with the given name More...
 
virtual DLLEXPORT ~QoreNamespace ()
 destroys the object and frees memory
 
virtual DLLEXPORT ~QoreNamespace ()
 destroys the object and frees memory
 
DLLEXPORT void addBuiltinVariant (const char *name, q_func_n_t f, int64 code_flags=QCF_NO_FLAGS, int64 functional_domain=QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo=0, unsigned num_params=0,...)
 adds a function variant
 
DLLEXPORT void addBuiltinVariant (const char *name, q_func_n_t f, int64 code_flags=QCF_NO_FLAGS, int64 functional_domain=QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo=0, unsigned num_params=0,...)
 adds a function variant
 
DLLEXPORT void addConstant (const char *name, QoreValue value)
 adds a constant definition to the namespace More...
 
DLLEXPORT void addConstant (const char *name, QoreValue value)
 adds a constant definition to the namespace More...
 
DLLEXPORT void addConstant (const char *name, QoreValue value, const QoreTypeInfo *typeInfo)
 adds a constant definition to the namespace with type information More...
 
DLLEXPORT void addConstant (const char *name, QoreValue value, const QoreTypeInfo *typeInfo)
 adds a constant definition to the namespace with type information More...
 
DLLEXPORT void addInitialNamespace (QoreNamespace *ns)
 adds a subnamespace to the namespace More...
 
DLLEXPORT void addInitialNamespace (QoreNamespace *ns)
 adds a subnamespace to the namespace More...
 
DLLEXPORT void addNamespace (QoreNamespace *ns)
 adds a namespace to the namespace tree More...
 
DLLEXPORT void addNamespace (QoreNamespace *ns)
 adds a namespace to the namespace tree More...
 
DLLEXPORT void addSystemClass (QoreClass *oc)
 adds a class to a namespace More...
 
DLLEXPORT void addSystemClass (QoreClass *oc)
 adds a class to a namespace More...
 
DLLEXPORT void addSystemHashDecl (TypedHashDecl *hashdecl)
 adds a hashdecl to a namespace More...
 
DLLEXPORT void addSystemHashDecl (TypedHashDecl *hashdecl)
 adds a hashdecl to a namespace More...
 
DLLEXPORT void clear (ExceptionSink *xsink)
 clears the contents of the namespace before deleting More...
 
DLLEXPORT void clear (ExceptionSink *xsink)
 clears the contents of the namespace before deleting More...
 
DLLEXPORT QoreNamespacecopy (int po) const
 returns a deep copy of the namespace; DEPRECATED: use copy(int64) instead More...
 
DLLEXPORT QoreNamespacecopy (int po) const
 returns a deep copy of the namespace; DEPRECATED: use copy(int64) instead More...
 
DLLEXPORT QoreNamespacecopy (int64 po=PO_DEFAULT) const
 returns a deep copy of the namespace More...
 
DLLEXPORT QoreNamespacecopy (int64 po=PO_DEFAULT) const
 returns a deep copy of the namespace More...
 
DLLEXPORT void deleteData (ExceptionSink *xsink)
 this function must be called before the QoreNamespace object is deleted or a crash could result due if constants and/or class static vars contain objects
 
DLLEXPORT void deleteData (ExceptionSink *xsink)
 this function must be called before the QoreNamespace object is deleted or a crash could result due if constants and/or class static vars contain objects
 
DLLEXPORT QoreNamespacefindCreateNamespacePath (const char *nspath)
 finds a Namespace based on the argument; creates it (or the whole path) if necessary More...
 
DLLEXPORT QoreNamespacefindCreateNamespacePath (const char *nspath)
 finds a Namespace based on the argument; creates it (or the whole path) if necessary More...
 
DLLEXPORT QoreClassfindLocalClass (const char *cname) const
 finds a class in this namespace, does not search child namespaces More...
 
DLLEXPORT QoreClassfindLocalClass (const char *cname) const
 finds a class in this namespace, does not search child namespaces More...
 
DLLEXPORT const QoreExternalConstantfindLocalConstant (const char *name) const
 find a constant in the current namespace; returns nullptr if not found More...
 
DLLEXPORT const QoreExternalConstantfindLocalConstant (const char *name) const
 find a constant in the current namespace; returns nullptr if not found More...
 
DLLEXPORT const QoreExternalFunction * findLocalFunction (const char *name) const
 find a function in the current namespace; returns nullptr if not found More...
 
DLLEXPORT const QoreExternalFunction * findLocalFunction (const char *name) const
 find a function in the current namespace; returns nullptr if not found More...
 
DLLEXPORT const QoreExternalGlobalVar * findLocalGlobalVar (const char *name) const
 find a global variable in the current namespace; returns nullptr if not found More...
 
DLLEXPORT const QoreExternalGlobalVar * findLocalGlobalVar (const char *name) const
 find a global variable in the current namespace; returns nullptr if not found More...
 
DLLEXPORT QoreNamespacefindLocalNamespace (const char *nsname) const
 finds a subnamespace in this namespace, does not search child namespaces More...
 
DLLEXPORT QoreNamespacefindLocalNamespace (const char *nsname) const
 finds a subnamespace in this namespace, does not search child namespaces More...
 
DLLEXPORT const TypedHashDeclfindLocalTypedHash (const char *name) const
 find a typed hash (hashdecl) in the current namespace; returns nullptr if not found More...
 
DLLEXPORT const TypedHashDeclfindLocalTypedHash (const char *name) const
 find a typed hash (hashdecl) in the current namespace; returns nullptr if not found More...
 
DLLEXPORT QoreHashNodegetClassInfo () const
 gets a hash of all classes in the namespace, the hash keys are the class names and the values are lists of strings giving the method names More...
 
DLLEXPORT QoreHashNodegetClassInfo () const
 gets a hash of all classes in the namespace, the hash keys are the class names and the values are lists of strings giving the method names More...
 
DLLEXPORT QoreHashNodegetConstantInfo () const
 a hash of all constants in the namespace, the hash keys are the constant names and the values are the values of the constants More...
 
DLLEXPORT QoreHashNodegetConstantInfo () const
 a hash of all constants in the namespace, the hash keys are the constant names and the values are the values of the constants More...
 
DLLEXPORT QoreHashNodegetInfo () const
 returns a hash giving information about the definitions in the namespace More...
 
DLLEXPORT QoreHashNodegetInfo () const
 returns a hash giving information about the definitions in the namespace More...
 
DLLEXPORT const char * getName () const
 returns the name of the namespace More...
 
DLLEXPORT const char * getName () const
 returns the name of the namespace More...
 
DLLEXPORT const QoreNamespacegetParent () const
 returns a pointer to the parent namespace or nullptr if there is no parent More...
 
DLLEXPORT const QoreNamespacegetParent () const
 returns a pointer to the parent namespace or nullptr if there is no parent More...
 
DLLEXPORT std::string getPath (bool anchored=false) const
 returns the path for the namespace More...
 
DLLEXPORT std::string getPath (bool anchored=false) const
 returns the path for the namespace More...
 
DLLEXPORT bool isBuiltin () const
 returns true if the namespace is builtin More...
 
DLLEXPORT bool isBuiltin () const
 returns true if the namespace is builtin More...
 
DLLEXPORT bool isImported () const
 returns true if the namespace was imported from another program object More...
 
DLLEXPORT bool isImported () const
 returns true if the namespace was imported from another program object More...
 
DLLEXPORT bool isModulePublic () const
 returns true if the namespace has its module public flag set More...
 
DLLEXPORT bool isModulePublic () const
 returns true if the namespace has its module public flag set More...
 
DLLEXPORT bool isRoot () const
 returns true if the namespace is the root namespace More...
 
DLLEXPORT bool isRoot () const
 returns true if the namespace is the root namespace More...
 
DLLEXPORT void setClassHandler (q_ns_class_handler_t class_handler)
 sets the namespace class handler More...
 
DLLEXPORT void setClassHandler (q_ns_class_handler_t class_handler)
 sets the namespace class handler More...
 

Friends

class RootQoreNamespace
 

Detailed Description

contains constants, classes, and subnamespaces in QoreProgram objects

Constructor & Destructor Documentation

◆ QoreNamespace() [1/2]

DLLEXPORT QoreNamespace::QoreNamespace ( const char *  n)

creates a namespace with the given name

the name of a subnamespace must be unique in the parent namespace and must not have the same name as a class in the parent namespace either

Parameters
nthe name of the namespace

◆ QoreNamespace() [2/2]

DLLEXPORT QoreNamespace::QoreNamespace ( const char *  n)

creates a namespace with the given name

the name of a subnamespace must be unique in the parent namespace and must not have the same name as a class in the parent namespace either

Parameters
nthe name of the namespace

Member Function Documentation

◆ addConstant() [1/4]

DLLEXPORT void QoreNamespace::addConstant ( const char *  name,
QoreValue  value 
)

adds a constant definition to the namespace

use addConstant(const char* name, QoreValue value, const QoreTypeInfo* typeInfo) when adding constants of externally-defined base (non-class) types; all other types (and all objects) can have their type information automatically added

Parameters
namethe name of the constant to add
valuethe value of the constant

◆ addConstant() [2/4]

DLLEXPORT void QoreNamespace::addConstant ( const char *  name,
QoreValue  value 
)

adds a constant definition to the namespace

use addConstant(const char* name, QoreValue value, const QoreTypeInfo* typeInfo) when adding constants of externally-defined base (non-class) types; all other types (and all objects) can have their type information automatically added

Parameters
namethe name of the constant to add
valuethe value of the constant

◆ addConstant() [3/4]

DLLEXPORT void QoreNamespace::addConstant ( const char *  name,
QoreValue  value,
const QoreTypeInfo *  typeInfo 
)

adds a constant definition to the namespace with type information

Parameters
namethe name of the constant to add
valuethe value of the constant
typeInfothe type of the constant
See also
QoreTypeInfoHelper

◆ addConstant() [4/4]

DLLEXPORT void QoreNamespace::addConstant ( const char *  name,
QoreValue  value,
const QoreTypeInfo *  typeInfo 
)

adds a constant definition to the namespace with type information

Parameters
namethe name of the constant to add
valuethe value of the constant
typeInfothe type of the constant
See also
QoreTypeInfoHelper

◆ addInitialNamespace() [1/2]

DLLEXPORT void QoreNamespace::addInitialNamespace ( QoreNamespace ns)

adds a subnamespace to the namespace

use this function when the QoreNamespace can be added directly to the tree (does not need to be merged with another namespace of the same name and does not contain user code)

Parameters
nsthe subnamespace to add to the namespace

◆ addInitialNamespace() [2/2]

DLLEXPORT void QoreNamespace::addInitialNamespace ( QoreNamespace ns)

adds a subnamespace to the namespace

use this function when the QoreNamespace can be added directly to the tree (does not need to be merged with another namespace of the same name and does not contain user code)

Parameters
nsthe subnamespace to add to the namespace

◆ addNamespace() [1/2]

DLLEXPORT void QoreNamespace::addNamespace ( QoreNamespace ns)

adds a namespace to the namespace tree

the namespace must be unique, must also not clash with a class name in the same parent namespace

Parameters
nsthe namespace to add, memory is now owned by parent namespace

◆ addNamespace() [2/2]

DLLEXPORT void QoreNamespace::addNamespace ( QoreNamespace ns)

adds a namespace to the namespace tree

the namespace must be unique, must also not clash with a class name in the same parent namespace

Parameters
nsthe namespace to add, memory is now owned by parent namespace

◆ addSystemClass() [1/2]

DLLEXPORT void QoreNamespace::addSystemClass ( QoreClass oc)

adds a class to a namespace

Parameters
octhe class to add to the namespace

◆ addSystemClass() [2/2]

DLLEXPORT void QoreNamespace::addSystemClass ( QoreClass oc)

adds a class to a namespace

Parameters
octhe class to add to the namespace

◆ addSystemHashDecl() [1/2]

DLLEXPORT void QoreNamespace::addSystemHashDecl ( TypedHashDecl hashdecl)

adds a hashdecl to a namespace

Parameters
hashdeclthe hashdecl to add to the namespace
Since
Qore 0.8.13

◆ addSystemHashDecl() [2/2]

DLLEXPORT void QoreNamespace::addSystemHashDecl ( TypedHashDecl hashdecl)

adds a hashdecl to a namespace

Parameters
hdthe hashdecl to add to the namespace
Since
Qore 0.8.13

◆ clear() [1/2]

DLLEXPORT void QoreNamespace::clear ( ExceptionSink xsink)

clears the contents of the namespace before deleting

use if the namespace could contain objects

Since
Qore 0.8.13

◆ clear() [2/2]

DLLEXPORT void QoreNamespace::clear ( ExceptionSink xsink)

clears the contents of the namespace before deleting

use if the namespace could contain objects

Since
Qore 0.8.13

◆ copy() [1/4]

DLLEXPORT QoreNamespace* QoreNamespace::copy ( int  po) const

returns a deep copy of the namespace; DEPRECATED: use copy(int64) instead

Parameters
poparse options to use when copying the namespace
Returns
a deep copy of the namespace

◆ copy() [2/4]

DLLEXPORT QoreNamespace* QoreNamespace::copy ( int  po) const

returns a deep copy of the namespace; DEPRECATED: use copy(int64) instead

Parameters
poparse options to use when copying the namespace
Returns
a deep copy of the namespace

◆ copy() [3/4]

DLLEXPORT QoreNamespace* QoreNamespace::copy ( int64  po = PO_DEFAULT) const

returns a deep copy of the namespace

Parameters
poparse options to use when copying the namespace
Returns
a deep copy of the namespace

◆ copy() [4/4]

DLLEXPORT QoreNamespace* QoreNamespace::copy ( int64  po = PO_DEFAULT) const

returns a deep copy of the namespace

Parameters
poparse options to use when copying the namespace
Returns
a deep copy of the namespace

◆ findCreateNamespacePath() [1/2]

DLLEXPORT QoreNamespace* QoreNamespace::findCreateNamespacePath ( const char *  nspath)

finds a Namespace based on the argument; creates it (or the whole path) if necessary

can only be called in the parse lock

Parameters
nspathmust be a complete path ("ns1::ns2[::ns3...]" to a namespace, which will be found or created in this namespace
Returns
the namespace found or created according to the path
Note
namespaces are created private by default

◆ findCreateNamespacePath() [2/2]

DLLEXPORT QoreNamespace* QoreNamespace::findCreateNamespacePath ( const char *  nspath)

finds a Namespace based on the argument; creates it (or the whole path) if necessary

can only be called in the parse lock

Parameters
nspathmust be a complete path ("ns1::ns2[::ns3...]" to a namespace, which will be found or created in this namespace
Returns
the namespace found or created according to the path
Note
namespaces are created private by default

◆ findLocalClass() [1/2]

DLLEXPORT QoreClass* QoreNamespace::findLocalClass ( const char *  cname) const

finds a class in this namespace, does not search child namespaces

can only be called in the parse lock does not call the class handler

Parameters
cnamethe class name to find in this namespace, must be unqualified (without a namespace path)
Returns
the class found or 0 if not present

◆ findLocalClass() [2/2]

DLLEXPORT QoreClass* QoreNamespace::findLocalClass ( const char *  cname) const

finds a class in this namespace, does not search child namespaces

can only be called in the parse lock does not call the class handler

Parameters
cnamethe class name to find in this namespace, must be unqualified (without a namespace path)
Returns
the class found or 0 if not present

◆ findLocalConstant() [1/2]

DLLEXPORT const QoreExternalConstant* QoreNamespace::findLocalConstant ( const char *  name) const

find a constant in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ findLocalConstant() [2/2]

DLLEXPORT const QoreExternalConstant* QoreNamespace::findLocalConstant ( const char *  name) const

find a constant in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ findLocalFunction() [1/2]

DLLEXPORT const QoreExternalFunction* QoreNamespace::findLocalFunction ( const char *  name) const

find a function in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ findLocalFunction() [2/2]

DLLEXPORT const QoreExternalFunction* QoreNamespace::findLocalFunction ( const char *  name) const

find a function in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ findLocalGlobalVar() [1/2]

DLLEXPORT const QoreExternalGlobalVar* QoreNamespace::findLocalGlobalVar ( const char *  name) const

find a global variable in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ findLocalGlobalVar() [2/2]

DLLEXPORT const QoreExternalGlobalVar* QoreNamespace::findLocalGlobalVar ( const char *  name) const

find a global variable in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ findLocalNamespace() [1/2]

DLLEXPORT QoreNamespace* QoreNamespace::findLocalNamespace ( const char *  nsname) const

finds a subnamespace in this namespace, does not search child namespaces

can only be called in the parse lock

Parameters
nsnamethe subnamespace name to find in this namespace, must be unqualified (without a namespace path)
Returns
the namespace found or 0 if not present

◆ findLocalNamespace() [2/2]

DLLEXPORT QoreNamespace* QoreNamespace::findLocalNamespace ( const char *  nsname) const

finds a subnamespace in this namespace, does not search child namespaces

can only be called in the parse lock

Parameters
nsnamethe subnamespace name to find in this namespace, must be unqualified (without a namespace path)
Returns
the namespace found or 0 if not present

◆ findLocalTypedHash() [1/2]

DLLEXPORT const TypedHashDecl* QoreNamespace::findLocalTypedHash ( const char *  name) const

find a typed hash (hashdecl) in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ findLocalTypedHash() [2/2]

DLLEXPORT const TypedHashDecl* QoreNamespace::findLocalTypedHash ( const char *  name) const

find a typed hash (hashdecl) in the current namespace; returns nullptr if not found

Since
Qore 0.9

◆ getClassInfo() [1/2]

DLLEXPORT QoreHashNode* QoreNamespace::getClassInfo ( ) const

gets a hash of all classes in the namespace, the hash keys are the class names and the values are lists of strings giving the method names

See also
QoreHashNode
QoreListNode
Returns
a hash of all classes in the namespace, the hash keys are the class names and the values are lists of strings giving the method names

◆ getClassInfo() [2/2]

DLLEXPORT QoreHashNode* QoreNamespace::getClassInfo ( ) const

gets a hash of all classes in the namespace, the hash keys are the class names and the values are lists of strings giving the method names

See also
QoreHashNode
QoreListNode
Returns
a hash of all classes in the namespace, the hash keys are the class names and the values are lists of strings giving the method names

◆ getConstantInfo() [1/2]

DLLEXPORT QoreHashNode* QoreNamespace::getConstantInfo ( ) const

a hash of all constants in the namespace, the hash keys are the constant names and the values are the values of the constants

See also
QoreHashNode
QoreListNode
Returns
a hash of all constants in the namespace, the hash keys are the constant names and the values are the values of the constants

◆ getConstantInfo() [2/2]

DLLEXPORT QoreHashNode* QoreNamespace::getConstantInfo ( ) const

a hash of all constants in the namespace, the hash keys are the constant names and the values are the values of the constants

See also
QoreHashNode
QoreListNode
Returns
a hash of all constants in the namespace, the hash keys are the constant names and the values are the values of the constants

◆ getInfo() [1/2]

DLLEXPORT QoreHashNode* QoreNamespace::getInfo ( ) const

returns a hash giving information about the definitions in the namespace

the return value has the following keys: "constants", "classes", and "subnamespaces" having as values the result of calling QoreNamespace::getConstantInfo(), QoreNamespace::getClassInfo(), and a hash of subnamespace names having as values the result of calling this function on each, respectively.

Returns
a hash giving information about the definitions in the namespace

◆ getInfo() [2/2]

DLLEXPORT QoreHashNode* QoreNamespace::getInfo ( ) const

returns a hash giving information about the definitions in the namespace

the return value has the following keys: "constants", "classes", and "subnamespaces" having as values the result of calling QoreNamespace::getConstantInfo(), QoreNamespace::getClassInfo(), and a hash of subnamespace names having as values the result of calling this function on each, respectively.

Returns
a hash giving information about the definitions in the namespace

◆ getName() [1/2]

DLLEXPORT const char* QoreNamespace::getName ( ) const

returns the name of the namespace

Returns
the name of the namespace

◆ getName() [2/2]

DLLEXPORT const char* QoreNamespace::getName ( ) const

returns the name of the namespace

Returns
the name of the namespace

◆ getParent() [1/2]

DLLEXPORT const QoreNamespace* QoreNamespace::getParent ( ) const

returns a pointer to the parent namespace or nullptr if there is no parent

Returns
a pointer to the parent namespace or nullptr if there is no parent

◆ getParent() [2/2]

DLLEXPORT const QoreNamespace* QoreNamespace::getParent ( ) const

returns a pointer to the parent namespace or nullptr if there is no parent

Returns
a pointer to the parent namespace or nullptr if there is no parent

◆ getPath() [1/2]

DLLEXPORT std::string QoreNamespace::getPath ( bool  anchored = false) const

returns the path for the namespace

Parameters
anchoredif true then the namespace will be prefixed with "::" for the unnamed root namespace
Since
Qore 0.9

◆ getPath() [2/2]

DLLEXPORT std::string QoreNamespace::getPath ( bool  anchored = false) const

returns the path for the namespace

Parameters
anchoredif true then the namespace will be prefixed with "::" for the unnamed root namespace
Since
Qore 0.9

◆ isBuiltin() [1/2]

DLLEXPORT bool QoreNamespace::isBuiltin ( ) const

returns true if the namespace is builtin

Since
Qore 0.9

◆ isBuiltin() [2/2]

DLLEXPORT bool QoreNamespace::isBuiltin ( ) const

returns true if the namespace is builtin

Since
Qore 0.9

◆ isImported() [1/2]

DLLEXPORT bool QoreNamespace::isImported ( ) const

returns true if the namespace was imported from another program object

Since
Qore 0.9

◆ isImported() [2/2]

DLLEXPORT bool QoreNamespace::isImported ( ) const

returns true if the namespace was imported from another program object

Since
Qore 0.9

◆ isModulePublic() [1/2]

DLLEXPORT bool QoreNamespace::isModulePublic ( ) const

returns true if the namespace has its module public flag set

Since
Qore 0.9

◆ isModulePublic() [2/2]

DLLEXPORT bool QoreNamespace::isModulePublic ( ) const

returns true if the namespace has its module public flag set

Since
Qore 0.9

◆ isRoot() [1/2]

DLLEXPORT bool QoreNamespace::isRoot ( ) const

returns true if the namespace is the root namespace

Since
Qore 0.9

◆ isRoot() [2/2]

DLLEXPORT bool QoreNamespace::isRoot ( ) const

returns true if the namespace is the root namespace

Since
Qore 0.9

◆ setClassHandler() [1/2]

DLLEXPORT void QoreNamespace::setClassHandler ( q_ns_class_handler_t  class_handler)

sets the namespace class handler

to be called when a class cannot be found in the namespace

Parameters
class_handlerpointer to the class handler function

◆ setClassHandler() [2/2]

DLLEXPORT void QoreNamespace::setClassHandler ( q_ns_class_handler_t  class_handler)

sets the namespace class handler

to be called when a class cannot be found in the namespace

Parameters
class_handlerpointer to the class handler function

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