Qore Programming Language
1.9.1
|
contains constants, classes, and subnamespaces in QoreProgram objects More...
#include <QoreNamespace.h>
Public Member Methods | |
DLLEXPORT | QoreNamespace (const char *n) |
creates a namespace with the given name More... | |
DLLEXPORT | QoreNamespace (const QoreNamespace &old, int64 po) |
copies the namespace and assigns new parse options to the new namespace 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 | addBuiltinVariant (void *ptr, const char *name, q_external_func_t f, int64 code_flags=QCF_NO_FLAGS, int64 functional_domain=QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo=nullptr, unsigned num_params=0,...) |
adds a function variant 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 | 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 QoreNamespace * | copy (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 QoreNamespace * | findCreateNamespacePath (const char *nspath) |
finds a Namespace based on the argument; creates it (or the whole path) if necessary More... | |
DLLEXPORT QoreNamespace * | findCreateNamespacePathAll (const char *nspath) |
finds a Namespace based on the argument; creates it (or the whole path) if necessary More... | |
DLLEXPORT QoreClass * | findLoadLocalClass (const char *cname) |
finds a class in this namespace, does not search child namespaces More... | |
DLLEXPORT QoreClass * | findLocalClass (const char *cname) const |
finds a class in this namespace, does not search child namespaces More... | |
DLLEXPORT const QoreExternalConstant * | findLocalConstant (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 QoreNamespace * | findLocalNamespace (const char *nsname) const |
finds a subnamespace in this namespace, does not search child namespaces More... | |
DLLEXPORT const TypedHashDecl * | findLocalTypedHash (const char *name) const |
find a typed hash (hashdecl) in the current namespace; returns nullptr if not found More... | |
DLLEXPORT QoreHashNode * | 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 More... | |
DLLEXPORT QoreHashNode * | 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 More... | |
DLLEXPORT QoreHashNode * | getInfo () const |
returns a hash giving information about the definitions in the namespace More... | |
DLLEXPORT const char * | getModuleName () const |
Returns the module name the namespace was loaded from or nullptr if it is a builtin namespace. More... | |
DLLEXPORT const char * | getName () const |
returns the name of the namespace More... | |
DLLEXPORT const QoreNamespace * | getParent () 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 QoreProgram * | getProgram () const |
Returns the owning QoreProgram object (if not the static system namespace) More... | |
DLLEXPORT QoreValue | getReferencedKeyValue (const char *key) const |
Returns a referenced key value from the namespace's key-value store. More... | |
DLLEXPORT QoreValue | getReferencedKeyValue (const std::string &key) const |
Returns a referenced key value from the namespace's key-value store. 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... | |
DLLEXPORT QoreValue | setKeyValue (const std::string &key, QoreValue val) |
Sets a key value in the namespace's key-value store unconditionally. More... | |
DLLEXPORT bool | setKeyValueIfNotSet (const std::string &key, const char *str) |
Sets a key value in the namespace's key-value store only if no value exists for the given key. More... | |
DLLEXPORT QoreValue | setKeyValueIfNotSet (const std::string &key, QoreValue val) |
Sets a key value in the namespace's key-value store only if no value exists for the given key. More... | |
Friends | |
class | RootQoreNamespace |
contains constants, classes, and subnamespaces in QoreProgram objects
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
n | the name of the namespace |
DLLEXPORT QoreNamespace::QoreNamespace | ( | const QoreNamespace & | old, |
int64 | po | ||
) |
copies the namespace and assigns new parse options to the new namespace
old | the old namespace to copy |
po | new parse options for the new namespace |
DLLEXPORT void QoreNamespace::addBuiltinVariant | ( | void * | ptr, |
const char * | name, | ||
q_external_func_t | f, | ||
int64 | code_flags = QCF_NO_FLAGS , |
||
int64 | functional_domain = QDOM_DEFAULT , |
||
const QoreTypeInfo * | returnTypeInfo = nullptr , |
||
unsigned | num_params = 0 , |
||
... | |||
) |
adds a function variant
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
name | the name of the constant to add |
value | the value of the constant |
DLLEXPORT void QoreNamespace::addConstant | ( | const char * | name, |
QoreValue | value, | ||
const QoreTypeInfo * | typeInfo | ||
) |
adds a constant definition to the namespace with type information
name | the name of the constant to add |
value | the value of the constant |
typeInfo | the type of the constant |
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)
ns | the subnamespace to add to the namespace |
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
ns | the namespace to add, memory is now owned by parent namespace |
DLLEXPORT void QoreNamespace::addSystemClass | ( | QoreClass * | oc | ) |
adds a class to a namespace
oc | the class to add to the namespace |
DLLEXPORT void QoreNamespace::addSystemHashDecl | ( | TypedHashDecl * | hashdecl | ) |
adds a hashdecl to a namespace
hashdecl | the hashdecl to add to the namespace |
DLLEXPORT void QoreNamespace::clear | ( | ExceptionSink * | xsink | ) |
clears the contents of the namespace before deleting
use if the namespace could contain objects
DLLEXPORT QoreNamespace* QoreNamespace::copy | ( | int64 | po = PO_DEFAULT | ) | const |
returns a deep copy of the namespace
po | parse options to use when copying the namespace |
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
nspath | must be a complete path ("ns1::ns2[::ns3...]" to a namespace, which will be found or created in this namespace; the last element of the path is ignored |
DLLEXPORT QoreNamespace* QoreNamespace::findCreateNamespacePathAll | ( | 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
nspath | must be a complete path ("ns1::ns2[::ns3...]" to a namespace, which will be found or created in this namespace; the last element of the path is not ignored and the final namespace is created with this name |
DLLEXPORT QoreClass* QoreNamespace::findLoadLocalClass | ( | const char * | cname | ) |
finds a class in this namespace, does not search child namespaces
can only be called in the parse lock; does call the class handler
cname | the class name to find in this namespace, must be unqualified (without a namespace path) |
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
cname | the class name to find in this namespace, must be unqualified (without a namespace path) |
DLLEXPORT const QoreExternalConstant* QoreNamespace::findLocalConstant | ( | const char * | name | ) | const |
find a constant in the current namespace; returns nullptr if not found
DLLEXPORT const QoreExternalFunction* QoreNamespace::findLocalFunction | ( | const char * | name | ) | const |
find a function in the current namespace; returns nullptr if not found
DLLEXPORT const QoreExternalGlobalVar* QoreNamespace::findLocalGlobalVar | ( | const char * | name | ) | const |
find a global variable in the current namespace; returns nullptr if not found
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
nsname | the subnamespace name to find in this namespace, must be unqualified (without a namespace path) |
DLLEXPORT const TypedHashDecl* QoreNamespace::findLocalTypedHash | ( | const char * | name | ) | const |
find a typed hash (hashdecl) in the current namespace; returns nullptr if not found
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
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
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.
DLLEXPORT const char* QoreNamespace::getModuleName | ( | ) | const |
Returns the module name the namespace was loaded from or nullptr if it is a builtin namespace.
DLLEXPORT const char* QoreNamespace::getName | ( | ) | const |
returns the name of the namespace
DLLEXPORT const QoreNamespace* QoreNamespace::getParent | ( | ) | const |
returns a pointer to the parent namespace or nullptr if there is no parent
DLLEXPORT std::string QoreNamespace::getPath | ( | bool | anchored = false | ) | const |
returns the path for the namespace
anchored | if true then the namespace will be prefixed with "::" for the unnamed root namespace |
DLLEXPORT QoreProgram* QoreNamespace::getProgram | ( | ) | const |
Returns the owning QoreProgram object (if not the static system namespace)
DLLEXPORT QoreValue QoreNamespace::getReferencedKeyValue | ( | const char * | key | ) | const |
Returns a referenced key value from the namespace's key-value store.
key | the key to check |
DLLEXPORT QoreValue QoreNamespace::getReferencedKeyValue | ( | const std::string & | key | ) | const |
Returns a referenced key value from the namespace's key-value store.
key | the key to check |
DLLEXPORT bool QoreNamespace::isBuiltin | ( | ) | const |
returns true if the namespace is builtin
DLLEXPORT bool QoreNamespace::isImported | ( | ) | const |
returns true if the namespace was imported from another program object
DLLEXPORT bool QoreNamespace::isModulePublic | ( | ) | const |
returns true if the namespace has its module public flag set
DLLEXPORT bool QoreNamespace::isRoot | ( | ) | const |
returns true if the namespace is the root namespace
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
class_handler | pointer to the class handler function |
Sets a key value in the namespace's key-value store unconditionally.
key | the key to store |
value | the value to store; must be already referenced for storage |
DLLEXPORT bool QoreNamespace::setKeyValueIfNotSet | ( | const std::string & | key, |
const char * | str | ||
) |
Sets a key value in the namespace's key-value store only if no value exists for the given key.
key | the key to store |
value | the string to store; will be converted to a QoreStringNode if stored |
returns | true if the value was set, false if not (a value is already in place) |
Sets a key value in the namespace's key-value store only if no value exists for the given key.
key | the key to store |
value | the value to store; must be already referenced for storage |