Qore Programming Language  0.9.3
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...
 
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 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 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 addSystemClass (QoreClass *oc)
 adds a class 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 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 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 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 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 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 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 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 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 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 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 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()

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/2]

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/2]

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()

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()

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()

DLLEXPORT void QoreNamespace::addSystemClass ( QoreClass oc)

adds a class to a namespace

Parameters
octhe class to add to the namespace

◆ addSystemHashDecl()

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

◆ clear()

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/2]

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/2]

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

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()

DLLEXPORT const char* QoreNamespace::getName ( ) const

returns the name of the namespace

Returns
the name of the namespace

◆ getParent()

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()

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()

DLLEXPORT bool QoreNamespace::isBuiltin ( ) const

returns true if the namespace is builtin

Since
Qore 0.9

◆ isImported()

DLLEXPORT bool QoreNamespace::isImported ( ) const

returns true if the namespace was imported from another program object

Since
Qore 0.9

◆ isModulePublic()

DLLEXPORT bool QoreNamespace::isModulePublic ( ) const

returns true if the namespace has its module public flag set

Since
Qore 0.9

◆ isRoot()

DLLEXPORT bool QoreNamespace::isRoot ( ) const

returns true if the namespace is the root namespace

Since
Qore 0.9

◆ setClassHandler()

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: