42#ifndef _QORE_QORENAMESPACE_H
44#define _QORE_QORENAMESPACE_H
51class QoreExternalFunction;
53class QoreExternalGlobalVar;
66 friend class QoreNamespaceList;
68 friend class qore_ns_private;
69 friend class qore_root_ns_private;
70 friend hashdecl NSOInfoBase;
259 const QoreTypeInfo* returnTypeInfo =
nullptr,
unsigned num_params = 0, ...);
286 DLLEXPORT std::string
getPath(
bool anchored =
false)
const;
386 class qore_ns_private* priv;
398 friend class qore_ns_private;
399 friend class qore_root_ns_private;
400 friend class StaticSystemNamespace;
419 class qore_root_ns_private* rpriv;
431class QorePrivateNamespaceIterator;
471 QorePrivateNamespaceIterator* priv;
504 QorePrivateNamespaceIterator* priv;
531 class qore_namespace_namespace_iterator* priv;
549 DLLEXPORT
const QoreExternalFunction&
get()
const;
558 class qore_namespace_function_iterator* priv;
585 class qore_namespace_constant_iterator* priv;
612 class ConstClassListIterator* priv;
630 DLLEXPORT
const QoreExternalGlobalVar&
get()
const;
639 class qore_namespace_globalvar_iterator* priv;
666 class ConstHashDeclListIterator* priv;
#define QDOM_DEFAULT
the default domain (no domain)
Definition: Restrictions.h:170
#define PO_DEFAULT
no parse options set by default
Definition: Restrictions.h:108
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
defines a Qore-language class
Definition: QoreClass.h:257
external wrapper class for constants
Definition: QoreReflection.h:200
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:52
allows classes in a namespace to be iterated
Definition: QoreNamespace.h:591
virtual DLLEXPORT ~QoreNamespaceClassIterator()
destroys the object
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
DLLEXPORT QoreNamespaceClassIterator(const QoreNamespace &ns)
creates the iterator
DLLEXPORT const QoreClass & get() const
returns the class
allows all namespaces of a namespace to be iterated (including the namespace passed in the constructo...
Definition: QoreNamespace.h:477
virtual DLLEXPORT ~QoreNamespaceConstIterator()
destroys the object
DLLEXPORT const QoreNamespace & get() const
returns the namespace
DLLEXPORT QoreNamespaceConstIterator(const QoreNamespace &ns)
creates the iterator; the namespace given will also be included in the iteration set
DLLEXPORT const QoreNamespace * operator->() const
returns the namespace
DLLEXPORT const QoreNamespace * operator*() const
returns the namespace
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
allows constants in a namespace to be iterated
Definition: QoreNamespace.h:564
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
DLLEXPORT const QoreExternalConstant & get() const
returns the constant
virtual DLLEXPORT ~QoreNamespaceConstantIterator()
destroys the object
DLLEXPORT QoreNamespaceConstantIterator(const QoreNamespace &ns)
creates the iterator
allows functions in a namespace to be iterated
Definition: QoreNamespace.h:537
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
DLLEXPORT const QoreExternalFunction & get() const
returns the function
DLLEXPORT QoreNamespaceFunctionIterator(const QoreNamespace &ns)
creates the iterator
virtual DLLEXPORT ~QoreNamespaceFunctionIterator()
destroys the object
allows global variables in a namespace to be iterated
Definition: QoreNamespace.h:618
DLLEXPORT const QoreExternalGlobalVar & get() const
returns the global variable
DLLEXPORT QoreNamespaceGlobalVarIterator(const QoreNamespace &ns)
creates the iterator
virtual DLLEXPORT ~QoreNamespaceGlobalVarIterator()
destroys the object
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
DLLEXPORT void addNamespace(QoreNamespace *ns)
adds a namespace to the namespace tree
DLLEXPORT QoreNamespace(const QoreNamespace &old, int64 po)
copies the namespace and assigns new parse options to the new namespace
DLLEXPORT bool isRoot() const
returns true if the namespace is the root namespace
DLLEXPORT void addSystemClass(QoreClass *oc)
adds a class to a namespace
DLLEXPORT QoreNamespace * copy(int64 po=PO_DEFAULT) const
returns a deep copy of the namespace
DLLEXPORT QoreValue setKeyValue(const std::string &key, QoreValue val)
Sets a key value in the namespace's key-value store unconditionally.
DLLEXPORT void addConstant(const char *name, QoreValue value, const QoreTypeInfo *typeInfo)
adds a constant definition to the namespace with type information
DLLEXPORT bool isBuiltin() const
returns true if the namespace is builtin
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 deleteData(ExceptionSink *xsink)
this function must be called before the QoreNamespace object is deleted or a crash could result due i...
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.
DLLEXPORT void addConstant(const char *name, QoreValue value)
adds a constant definition to the namespace
DLLEXPORT QoreNamespace * findCreateNamespacePathAll(const char *nspath)
finds a Namespace based on the argument; creates it (or the whole path) if necessary
DLLEXPORT std::string getPath(bool anchored=false) const
returns the path for the namespace
DLLEXPORT QoreValue getReferencedKeyValue(const std::string &key) const
Returns a referenced key value from the namespace's key-value store.
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
DLLEXPORT const QoreExternalFunction * findLocalFunction(const char *name) const
find a function in the current namespace; returns nullptr if not found
DLLEXPORT QoreHashNode * getInfo() const
returns a hash giving information about the definitions in the namespace
DLLEXPORT void addSystemHashDecl(TypedHashDecl *hashdecl)
adds a hashdecl to a namespace
DLLEXPORT void setClassHandler(q_ns_class_handler_t class_handler)
sets the namespace class handler
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.
DLLEXPORT QoreClass * findLoadLocalClass(const char *cname)
finds a class in this namespace, does not search child namespaces
DLLEXPORT QoreClass * findLocalClass(const char *cname) const
finds a class in this namespace, does not search child namespaces
DLLEXPORT const QoreExternalGlobalVar * findLocalGlobalVar(const char *name) const
find a global variable in the current namespace; returns nullptr if not found
DLLEXPORT QoreNamespace(const char *n)
creates a namespace with the given name
DLLEXPORT void clear(ExceptionSink *xsink)
clears the contents of the namespace before deleting
DLLEXPORT QoreProgram * getProgram() const
Returns the owning QoreProgram object (if not the static system namespace)
DLLEXPORT QoreValue getReferencedKeyValue(const char *key) const
Returns a referenced key value from the namespace's key-value store.
DLLEXPORT const char * getModuleName() const
Returns the module name the namespace was loaded from or nullptr if it is a builtin namespace.
virtual DLLEXPORT ~QoreNamespace()
destroys the object and frees memory
DLLEXPORT void addInitialNamespace(QoreNamespace *ns)
adds a subnamespace to the namespace
DLLEXPORT const QoreNamespace * getParent() const
returns a pointer to the parent namespace or nullptr if there is no parent
DLLEXPORT const char * getName() const
returns the name of the namespace
DLLEXPORT QoreHashNode * getClassInfo() const
gets a hash of all classes in the namespace, the hash keys are the class names and the values are lis...
DLLEXPORT const TypedHashDecl * findLocalTypedHash(const char *name) const
find a typed hash (hashdecl) in the current namespace; returns nullptr if not found
DLLEXPORT QoreNamespace * findLocalNamespace(const char *nsname) const
finds a subnamespace in this namespace, does not search child namespaces
DLLEXPORT bool isModulePublic() const
returns true if the namespace has its module public flag set
DLLEXPORT const QoreExternalConstant * findLocalConstant(const char *name) const
find a constant in the current namespace; returns nullptr if not found
DLLEXPORT QoreHashNode * getConstantInfo() const
a hash of all constants in the namespace, the hash keys are the constant names and the values are the...
DLLEXPORT bool isImported() const
returns true if the namespace was imported from another program object
DLLEXPORT QoreNamespace * findCreateNamespacePath(const char *nspath)
finds a Namespace based on the argument; creates it (or the whole path) if necessary
allows all namespaces of a namespace to be iterated (including the namespace passed in the constructo...
Definition: QoreNamespace.h:436
DLLEXPORT const QoreNamespace * operator->() const
returns the namespace
DLLEXPORT const QoreNamespace * operator*() const
returns the namespace
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
DLLEXPORT QoreNamespace * operator->()
returns the namespace
DLLEXPORT QoreNamespace * operator*()
returns the namespace
DLLEXPORT QoreNamespace & get()
returns the namespace
DLLEXPORT const QoreNamespace & get() const
returns the namespace
virtual DLLEXPORT ~QoreNamespaceIterator()
destroys the object
DLLEXPORT QoreNamespaceIterator(QoreNamespace &ns)
creates the iterator; the namespace given will also be included in the iteration set
allows local namespaces to be iterated
Definition: QoreNamespace.h:510
virtual DLLEXPORT ~QoreNamespaceNamespaceIterator()
destroys the object
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
DLLEXPORT QoreNamespaceNamespaceIterator(const QoreNamespace &ns)
creates the iterator
DLLEXPORT const QoreNamespace & get() const
returns the namespace
allows typed hashes (hashdecls) in a namespace to be iterated
Definition: QoreNamespace.h:645
DLLEXPORT const TypedHashDecl & get() const
returns the typed hash (hashdecl)
virtual DLLEXPORT ~QoreNamespaceTypedHashIterator()
destroys the object
DLLEXPORT QoreNamespaceTypedHashIterator(const QoreNamespace &ns)
creates the iterator
DLLEXPORT bool next()
moves to the next position; returns true if on a valid position
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:128
the root namespace of a QoreProgram object
Definition: QoreNamespace.h:397
DLLEXPORT QoreProgram * getProgram() const
Returns the owning QoreProgram object (if not the static system namespace)
DLLEXPORT QoreNamespace * rootGetQoreNamespace() const
returns a pointer to the QoreNamespace for the "Qore" namespace
virtual DLLLOCAL ~RootQoreNamespace()
destructor is not exported in the library's public API
typed hash declaration
Definition: TypedHashDecl.h:44
QoreValue(* q_func_n_t)(const QoreListNode *args, q_rt_flags_t flags, ExceptionSink *xsink)
the type used for builtin function signatures
Definition: common.h:315
long long int64
64bit integer type, cannot use int64_t here since it breaks the API on some 64-bit systems due to equ...
Definition: common.h:260
QoreValue(* q_external_func_t)(const void *ptr, const QoreListNode *args, q_rt_flags_t flags, ExceptionSink *xsink)
the type used for builtin function signatures for external functions
Definition: common.h:327
static unsigned num_params(const QoreListNode *n)
returns the number of arguments passed to the function
Definition: params.h:54
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:279