All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreNamespace Class Reference

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

`#include <QoreNamespace.h>`

Inheritance diagram for QoreNamespace:
[legend]

## Public Member Functions

DLLEXPORT | QoreNamespace (const char *n)
| creates a namespace with the given name
DLLEXPORT | ~QoreNamespace ()
| destroys the object and frees all associated memory
DLLEXPORT void | addConstant (const char *name, AbstractQoreNode *value)
| adds a constant definition to the namespace
DLLEXPORT void | addConstant (const char *name, AbstractQoreNode *value, const QoreTypeInfo *typeInfo)
| adds a constant definition to the namespace with type information
DLLEXPORT void | addSystemClass (QoreClass *oc)
| adds a class to a namespace
DLLEXPORT QoreNamespace * | copy (int po) const
| returns a deep copy of the namespace; DEPRECATED: use copy(int64) instead
DLLEXPORT QoreNamespace * | copy (int64 po=PO_DEFAULT) const
| returns a deep copy 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 lists of strings giving the method names
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
DLLEXPORT QoreHashNode * | getInfo () const
| returns a hash giving information about the definitions in the namespace
DLLEXPORT const char * | getName () const
| returns the name of the namespace
DLLEXPORT void | addNamespace (QoreNamespace *ns)
| adds a namespace to the namespace tree
DLLEXPORT void | addInitialNamespace (QoreNamespace *ns)
| adds a subnamespace to the namespace
DLLEXPORT QoreNamespace * | findCreateNamespacePath (const char *nspath)
| finds a Namespace based on the argument; creates it (or the whole path) if necessary
DLLEXPORT QoreClass * | findLocalClass (const char *cname) const
| finds a class in this namespace, does not search child namespaces
DLLEXPORT QoreNamespace * | findLocalNamespace (const char *nsname) const
| finds a subnamespace in this namespace, does not search child namespaces
DLLEXPORT void | setClassHandler (q_ns_class_handler_t class_handler)
| sets the namespace class handler
DLLEXPORT const QoreNamespace * | getParent () const
| returns a pointer to the parent namespace or 0 if there is no parent
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

## Friends

class | RootQoreNamespace

## Detailed Description

contains constants, classes, and subnamespaces in QoreProgram objects

## Constructor & Destructor Documentation

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

  n | the name of the namespace

## Member Function Documentation

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

adds a constant definition to the namespace

use addConstant(const char *name, AbstractQoreNode *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

  name | the name of the constant to add
  value | the value of the constant

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

adds a constant definition to the namespace with type information

Parameters

  name | the name of the constant to add
  value | the value of the constant
  typeInfo | the type of the constant

See Also
  QoreTypeInfoHelper

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

  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

Parameters

  ns | the namespace to add, memory is now owned by parent namespace

DLLEXPORT void QoreNamespace::addSystemClass | ( | QoreClass * | oc | ) |

adds a class to a namespace

Parameters

  oc | the class to add to the namespace

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

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

Parameters

  po | parse options to use when copying the namespace

Returns
  a deep copy of the namespace

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

returns a deep copy of the namespace

Parameters

  po | parse options to use when copying the namespace

Returns
  a deep copy of 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

Parameters

  nspath | must 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

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

  cname | the class name to find in this namespace, must be unqualified (without a namespace path)

Returns
  the class found or 0 if not present

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

  nsname | the subnamespace name to find in this namespace, must be unqualified (without a namespace path)

Returns
  the namespace found or 0 if not present

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

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

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

DLLEXPORT const char* QoreNamespace::getName | ( |  | ) | const

returns the name of the namespace

Returns
  the name of the namespace

DLLEXPORT const QoreNamespace* QoreNamespace::getParent | ( |  | ) | const

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

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

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_handler | pointer to the class handler function

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

- include/qore/QoreNamespace.h (5431)