| Qore Programming Language - C/C++ Library 1.0.8

Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QoreObject Class Reference

the implementation of Qore's object data type, reference counted, dynamically-allocated only More...

`#include <QoreObject.h>`

Inheritance diagram for QoreObject:
[legend]
Collaboration diagram for QoreObject:
[legend]

## Public Member Functions
DLLEXPORT | QoreObject (const QoreClass *oc, QoreProgram *p)
| creates an object as belonging to the given class, the QoreProgram object is referenced for the life of the object as well More...
DLLEXPORT | QoreObject (const QoreClass *oc, QoreProgram *p, AbstractPrivateData *data)
| creates an object as belonging to the given class, the QoreProgram object is referenced for the life of the object as well, and the private data is stored with the class ID of the class More...
DLLLOCAL | QoreObject (const QoreClass *oc, QoreProgram *p, QoreHashNode *d)
| creates the object with the initial data passed as "d", used by the copy constructor
DLLLOCAL void | addPrivateDataToString (QoreString *str, ExceptionSink *xsink) const
| concatenates info about private data to a string More...
DLLEXPORT bool | compareHard (const QoreObject *obj, ExceptionSink *xsink) const
| tests for equality ("deep compare" including all contained values) with possible type conversion of contained elements (hard compare) More...
DLLEXPORT bool | compareSoft (const QoreObject *obj, ExceptionSink *xsink) const
| tests for equality ("deep compare" including all contained values) with possible type conversion of contained elements (soft compare) More...
DLLEXPORT QoreHashNode * | copyData (ExceptionSink *xsink) const
| retuns all member data of the object (or 0 if there's an exception), caller owns the QoreHashNode reference returned More...
DLLLOCAL void | defaultSystemDestructor (qore_classid_t classID, ExceptionSink *xsink)
| runs the destructor for system objects More...
DLLEXPORT void | deleteMemberValue (const QoreString *key, ExceptionSink *xsink)
| removes a member from the object, if the member's value is an object it is deleted as well (destructor is called) More...
DLLEXPORT void | deleteMemberValue (const char *key, ExceptionSink *xsink)
| removes a member from the object, if the member's value is an object it is deleted as well (destructor is called) More...
DLLEXPORT void | doDelete (ExceptionSink *xsink)
| runs the destructor on the object (if it hasn't already been deleted) More...
DLLLOCAL QoreValue | evalBuiltinMethodWithPrivateData (const QoreMethod &method, const BuiltinNormalMethodVariantBase *meth, const QoreListNode *args, ExceptionSink *xsink)
| called to evaluate a builtin method when private data is available More...
DLLLOCAL void | evalCopyMethodWithPrivateData (const QoreClass &thisclass, const BuiltinCopyVariantBase *meth, QoreObject *self, ExceptionSink *xsink)
| called on the old object (this) to acquire private data, copy method called with pointer to "self" (new copy)
DLLEXPORT QoreValue | evalMember (const QoreString *member, ExceptionSink *xsink)
| returns the value of the member with an incremented reference count, or executes the memberGate() method and returns the value More...
DLLEXPORT QoreValue | evalMember (const char *member, ExceptionSink *xsink)
| returns the value of the member with an incremented reference count, or executes the memberGate() method and returns the value More...
DLLEXPORT QoreValue | evalMethod (const QoreString *name, const QoreListNode *args, ExceptionSink *xsink)
| evaluates the given method with the arguments passed and returns the return value, caller owns any reference returned More...
DLLEXPORT QoreValue | evalMethod (const char *name, const QoreListNode *args, ExceptionSink *xsink)
| evaluates the given method with the arguments passed and returns the return value, caller owns any reference returned More...
DLLEXPORT QoreValue | evalMethod (const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink)
| evaluates the given method with the arguments passed and returns the return value, caller owns the AbstractQoreNode (reference) returned More...
DLLEXPORT QoreValue | evalMethod (const QoreMethod &method, const QoreClass *class_ctx, const QoreListNode *args, ExceptionSink *xsink)
| evaluates the given method with the given class context and arguments passed and returns the return value, caller owns the AbstractQoreNode (reference) returned More...
DLLEXPORT QoreValue | evalMethodVariant (const QoreMethod &method, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink)
| executes a normal object method variant
DLLEXPORT QoreValue | evalMethodVariant (const QoreMethod &method, const QoreClass *class_ctx, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink)
| executes a normal object method variant More...
DLLLOCAL void | execMemberNotification (const char *member, ExceptionSink *xsink)
| executes the member notification on the object the given member
DLLEXPORT void | externalDelete (qore_classid_t key, ExceptionSink *xsink)
| call this function when an object's private data is deleted externally More...
DLLLOCAL AbstractPrivateData * | getAndClearPrivateData (qore_classid_t key, ExceptionSink *xsink)
| retrieves the private data pointer and clears it from the object's private data store, used when executing destructors More...
virtual DLLEXPORT bool | getAsBoolImpl () const
| returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when empty More...
virtual DLLEXPORT int | getAsString (QoreString &str, int foff, ExceptionSink *xsink) const
| concatenate the verbose string representation of the list (including all contained values) to an existing QoreString More...
virtual DLLEXPORT QoreString * | getAsString (bool &del, int foff, ExceptionSink *xsink) const
| returns a QoreString giving the verbose string representation of the List (including all contained values) More...
DLLEXPORT const QoreClass * | getClass (qore_classid_t cid) const
| returns a pointer to a QoreClass object if the class ID passed is a valid class in the hierarchy More...
DLLEXPORT const QoreClass * | getClass (qore_classid_t cid, bool &priv) const
| returns a pointer to the QoreClass object representing the class ID passed if it exists in the class hierarchy and sets a flag indicating if it's privately inherited or not More...
DLLEXPORT const QoreClass * | getClass () const
| returns a pointer to the QoreClass of this object More...
DLLEXPORT ClassAccess | getClassAccess (const QoreClass &cls) const
| returns the accessibility of the class in the object's hierachy or Inaccessible the object does not inherit the class at all More...
DLLEXPORT const char * | getClassName () const
| returns the name of the class More...
DLLEXPORT int64 | getMemberAsBigInt (const char *mem, bool &found, ExceptionSink *xsink) const
| returns the value of the given member as an int64 More...
DLLEXPORT QoreListNode * | getMemberList (ExceptionSink *xsink) const
| returns the list of members, caller owns the list returned More...
DLLEXPORT QoreValue | getMemberValueNoMethod (const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const
| returns the pointer to the value of the member More...
DLLEXPORT QoreValue | getMemberValueNoMethod (const char *key, AutoVLock *vl, ExceptionSink *xsink) const
| returns the pointer to the value of the member More...
DLLEXPORT QoreProgram * | getProgram () const
| returns the QoreProgram object associated with this object More...
DLLEXPORT QoreValue | getReferencedMemberNoMethod (const char *mem, ExceptionSink *xsink) const
| returns the value of the given member with the reference count incremented, the caller owns any reference returned More...
DLLEXPORT QoreValue | getReferencedMemberNoMethod (const char *key, const QoreClass *cls, ExceptionSink *xsink) const
| returns the value of the given member as accessed from the given class; caller owns any reference returned More...
DLLEXPORT AbstractPrivateData * | getReferencedPrivateData (qore_classid_t key, ExceptionSink *xsink) const
| returns the private data corresponding to the class ID passed with an incremented reference count, caller owns the reference More...
DLLEXPORT const QoreClass * | getSurfaceClass () const
| returns a pointer to the QoreClass of this object or to the injection target class in case the class was injected More...
DLLEXPORT const char * | getSurfaceClassName () const
| returns the name of the class or to the name of the injection target class in case the class was injected More...
virtual DLLEXPORT const char * | getTypeName () const
| returns the type name as a c string
DLLEXPORT bool | hasMember (const char *mem, ExceptionSink *xsink) const
| returns true if the object has the given member (note that the member may not have a value)
DLLLOCAL bool | hasMemberNotification () const
| returns true if the class has a memberNotification method
virtual DLLEXPORT bool | is_equal_hard (const AbstractQoreNode *v, ExceptionSink *xsink) const
| tests for equality ("deep compare" including all contained values) without type conversions (hard compare) More...
virtual DLLEXPORT bool | is_equal_soft (const AbstractQoreNode *v, ExceptionSink *xsink) const
| tests for equality ("deep compare" including all contained values) with possible type conversion (soft compare) More...
DLLEXPORT bool | isSystemObject () const
| returns true if the object is a system object (created with the system constructor) More...
DLLEXPORT bool | isValid () const
| returns true if the object is valid More...
DLLLOCAL void | obliterate (ExceptionSink *xsink)
| destroys all members and dereferences all private data structures More...
virtual DLLEXPORT AbstractQoreNode * | realCopy () const
| performs a the same object with its reference count increased
DLLEXPORT void | realDeref (ExceptionSink *xsink)
| decrements the standard reference count of the object for references that cannot be part of a recursive graph
DLLEXPORT void | realRef ()
| increments the standard reference count of the object for references that cannot be part of a recursive graph
DLLEXPORT void | removeMember (const QoreString *key, ExceptionSink *xsink)
| removes a member from the object without explicitly calling destructors; the value is only dereferenced More...
DLLEXPORT void | removeMember (const char *key, ExceptionSink *xsink)
| removes a member from the object without explicitly calling destructors; the value is only dereferenced More...
DLLEXPORT int | setMemberValue (const char *key, const QoreClass *cls, const QoreValue val, ExceptionSink *xsink)
| sets the value of the given member as accessed from the given class More...
DLLEXPORT void | setPrivate (qore_classid_t key, AbstractPrivateData *pd)
| sets private data for the object against the class ID passed, used in C++ functions implementing Qore constructors More...
DLLEXPORT void | setValue (const char *key, QoreValue val, ExceptionSink *xsink)
| sets the value of the given member to the given value More...
DLLEXPORT int | size (ExceptionSink *xsink) const
| returns the number of members of the object More...
DLLEXPORT QoreValue | takeMember (const QoreString *key, ExceptionSink *xsink)
| removes a member from the object without explicitly calling destructors and returns the value removed; the caller owns the reference returned More...
DLLEXPORT QoreValue | takeMember (const char *key, ExceptionSink *xsink)
| removes a member from the object without explicitly calling destructors and returns the value removed; the caller owns the reference returned More...
DLLEXPORT void | tDeref ()
| decrements the existence reference count, when it reaches 0 the C++ object ("this") will be deleted More...
DLLEXPORT void | tRef () const
| increments the existence reference count More...
DLLEXPORT AbstractPrivateData * | tryGetReferencedPrivateData (qore_classid_t key, ExceptionSink *xsink) const
| returns the private data corresponding to the class ID passed with an incremented reference count if it exists, caller owns the reference More...
DLLEXPORT bool | validInstanceOf (qore_classid_t cid) const
| returns true if this object is a valid instance of the classid passed More...
DLLEXPORT bool | validInstanceOf (const QoreClass &qc) const
| returns true if this object is a valid instance of the classid passed More...
DLLEXPORT bool | validInstanceOfStrict (const QoreClass &qc) const
| returns true if this object is a valid instance of the classid passed; does not check for injected compatibility More...
Public Member Functions inherited from AbstractQoreNode
DLLEXPORT | AbstractQoreNode (qore_type_t t, bool n_value, bool n_needs_eval, bool n_there_can_be_only_one=false, bool n_custom_reference_handlers=false)
| constructor takes the type More...
DLLEXPORT | AbstractQoreNode (const AbstractQoreNode &v)
| copy constructor
DLLEXPORT void | deref (ExceptionSink *xsink)
| decrements the reference count and calls derefImpl() if there_can_be_only_one is false, otherwise does nothing More...
DLLEXPORT QoreValue | eval (ExceptionSink *xsink) const
| evaluates the object and returns a value (or 0) More...
DLLEXPORT QoreValue | eval (bool &needs_deref, ExceptionSink *xsink) const
| optionally evaluates the argument More...
DLLEXPORT int64 | getAsBigInt () const
| returns the 64-bit integer value of the object More...
virtual DLLLOCAL int64 | getAsBigIntImpl () const
| default implementation, returns 0 More...
DLLEXPORT bool | getAsBool () const
| returns the boolean value of the object More...
DLLEXPORT double | getAsFloat () const
| returns the float value of the object More...
virtual DLLLOCAL double | getAsFloatImpl () const
| default implementation, returns 0.0 More...
DLLEXPORT int | getAsInt () const
| returns the integer value of the object More...
virtual DLLLOCAL int | getAsIntImpl () const
| default implementation, returns 0 More...
virtual DLLEXPORT class DateTime * | getDateTimeRepresentation (bool &del) const
| returns the DateTime representation of this type (default implementation: returns ZeroDate, del = false) More...
virtual DLLEXPORT void | getDateTimeRepresentation (DateTime &dt) const
| assigns the date representation of a value to the DateTime reference passed, default implementation does nothing More...
virtual DLLEXPORT QoreString * | getStringRepresentation (bool &del) const
| returns the value of the type converted to a string, default implementation: returns the empty string More...
virtual DLLEXPORT void | getStringRepresentation (QoreString &str) const
| concatentates the value of the type to an existing QoreString reference, default implementation does nothing More...
DLLLOCAL qore_type_t | getType () const
| returns the data type More...
DLLLOCAL bool | is_value () const
| returns true if the node represents a value More...
DLLLOCAL bool | isReferenceCounted () const
| returns true if the object is reference-counted
DLLLOCAL bool | needs_eval () const
| returns true if the object needs evaluation to return a value, false if not More...
DLLLOCAL AbstractQoreNode & | operator= (const AbstractQoreNode &)
| this function is not implemented; it is here as a private function in order to prohibit it from being used
virtual DLLLOCAL int | parseInit (QoreValue &val, QoreParseContext &parse_context)
| for use by parse types to initialize them for execution during stage 1 parsing More...
DLLEXPORT void | ref () const
| increments the reference count
DLLEXPORT AbstractQoreNode * | refSelf () const
| returns "this" with an incremented reference count More...
Public Member Functions inherited from QoreReferenceCounter
DLLEXPORT | QoreReferenceCounter ()
| creates the reference counter object
DLLEXPORT | QoreReferenceCounter (const QoreReferenceCounter &old)
| creates a new object with a reference count of 1 More...
DLLEXPORT | ~QoreReferenceCounter ()
| destroys the reference counter object
DLLEXPORT bool | is_unique () const
| returns true if the reference count is 1 More...
DLLEXPORT int | reference_count () const
| gets the reference count More...
DLLEXPORT bool | ROdereference () const
| atomically decrements the reference count More...
DLLEXPORT void | ROreference () const
| atomically increments the reference count

## Static Public Member Functions
static DLLEXPORT QoreValue | evalStaticMethod (const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink)
| executes a static method More...
static DLLEXPORT QoreValue | evalStaticMethod (const QoreMethod &method, const QoreClass *class_ctx, const QoreListNode *args, ExceptionSink *xsink)
| executes a static method with the given class context to access private:internal methods More...
static DLLEXPORT QoreValue | evalStaticMethodVariant (const QoreMethod &method, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink)
| executes a static method variant More...
static DLLEXPORT QoreValue | evalStaticMethodVariant (const QoreMethod &method, const QoreClass *class_ctx, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink)
| executes a static method variant with the given class context to access private:internal methods More...
static DLLLOCAL qore_type_t | getStaticTypeCode ()
| returns the type code (useful in templates)
static DLLLOCAL const char * | getStaticTypeName ()
| returns the type name (useful in templates)

## Protected Member Functions
virtual DLLLOCAL | ~QoreObject ()
| destructor
virtual DLLLOCAL void | customDeref (ExceptionSink *xsink)
| custom dereference handler - with delete
virtual DLLLOCAL void | customRef () const
| custom reference handler
virtual DLLEXPORT bool | derefImpl (ExceptionSink *xsink)
| runs the destructor if necessary and dereferences all members More...
virtual DLLLOCAL QoreValue | evalImpl (bool &needs_deref, ExceptionSink *xsink) const
| should never be called, does nothing More...
Protected Member Functions inherited from AbstractQoreNode
virtual DLLEXPORT | ~AbstractQoreNode ()
| default destructor does nothing More...

## Additional Inherited Members
Protected Attributes inherited from AbstractQoreNode
bool | custom_reference_handlers: 1
| set to one for objects that need custom reference handlers
bool | needs_eval_flag: 1
| if this is true then the type can be evaluated
bool | there_can_be_only_one: 1
| if this is set to true, then reference counting is turned off for objects of this class
qore_type_t | type: 11
| the type of the object More...
bool | value: 1
| this is true for values, if false then either the type needs evaluation to produce a value or is a parse expression

## Detailed Description

the implementation of Qore's object data type, reference counted, dynamically-allocated only

objects in Qore are unique unless copied explicitly (similar to Java) Builtin classes (those classes implemented in C++ as opposed to user classes implemented in the Qore language) can have "private data", which is data that maintains the state of the object per that class. QoreObject objects store this data as well as any member data.

objects have two levels of reference counts - one is for the existence of the c++ object (tRefs below) the other is for the scope of the object (the parent QoreReferenceCounter) - when this reaches 0 the object will have its destructor run (if it hasn't already been deleted). Only when the tRef counter reaches 0, meaning that no more pointers are pointing to this object will the object actually be deleted.

See also
  QoreClass

## Constructor & Destructor Documentation

## ◆ QoreObject() [1/2]

DLLEXPORT QoreObject::QoreObject | ( | const QoreClass * | oc,
|  | QoreProgram * | p
| ) |  |

creates an object as belonging to the given class, the QoreProgram object is referenced for the life of the object as well

Parameters

  oc | the class of the object being created
  p | the QoreProgram object where the object "lives", this QoreProgram object is referenced for the life of the object to ensure that it is not deleted while the object still exists (for example, if the object is exported to a parent QoreProgram object)

## ◆ QoreObject() [2/2]

DLLEXPORT QoreObject::QoreObject | ( | const QoreClass * | oc,
|  | QoreProgram * | p,
|  | AbstractPrivateData * | data
| ) |  |

creates an object as belonging to the given class, the QoreProgram object is referenced for the life of the object as well, and the private data is stored with the class ID of the class

Parameters

  oc | the class of the object being created
  p | the QoreProgram object where the object "lives", this QoreProgram object is referenced for the life of the object to ensure that it is not deleted while the object still exists (for example, if the object is exported to a parent QoreProgram object)
  data | the private data corresponding to the class ID of the class passed

## Member Function Documentation

## ◆ addPrivateDataToString()

DLLLOCAL void QoreObject::addPrivateDataToString | ( | QoreString * | str,
|  | ExceptionSink * | xsink
| ) |  | const

concatenates info about private data to a string

Parameters

  str | the string to concatenate to
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ compareHard()

DLLEXPORT bool QoreObject::compareHard | ( | const QoreObject * | obj,
|  | ExceptionSink * | xsink
| ) |  | const

tests for equality ("deep compare" including all contained values) with possible type conversion of contained elements (hard compare)

Parameters

  obj | the object to compare
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ compareSoft()

DLLEXPORT bool QoreObject::compareSoft | ( | const QoreObject * | obj,
|  | ExceptionSink * | xsink
| ) |  | const

tests for equality ("deep compare" including all contained values) with possible type conversion of contained elements (soft compare)

Parameters

  obj | the object to compare
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ copyData()

DLLEXPORT QoreHashNode* QoreObject::copyData | ( | ExceptionSink * | xsink | ) | const

retuns all member data of the object (or 0 if there's an exception), caller owns the QoreHashNode reference returned

Parameters

  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ defaultSystemDestructor()

DLLLOCAL void QoreObject::defaultSystemDestructor | ( | qore_classid_t | classID,
|  | ExceptionSink * | xsink
| ) |  |

runs the destructor for system objects

Parameters

  classID | the ID of the class
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ deleteMemberValue() [1/2]

DLLEXPORT void QoreObject::deleteMemberValue | ( | const QoreString * | key,
|  | ExceptionSink * | xsink
| ) |  |

removes a member from the object, if the member's value is an object it is deleted as well (destructor is called)

Parameters

  key | the name of the member to delete
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ deleteMemberValue() [2/2]

DLLEXPORT void QoreObject::deleteMemberValue | ( | const char * | key,
|  | ExceptionSink * | xsink
| ) |  |

removes a member from the object, if the member's value is an object it is deleted as well (destructor is called)

Parameters

  key | the name of the member to delete, assumed to be in the default encoding (QCS_DEFAULT)
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ derefImpl()

virtual DLLEXPORT bool QoreObject::derefImpl | ( | ExceptionSink * | xsink | ) |
| protected virtual

runs the destructor if necessary and dereferences all members

Note that other objects could be deleted as well if they are members of this object, any exceptions thrown there will also be added to "xsink"

Parameters

  xsink | if an error occurs, the Qore-language exception information will be added here

Reimplemented from AbstractQoreNode.

## ◆ doDelete()

DLLEXPORT void QoreObject::doDelete | ( | ExceptionSink * | xsink | ) |

runs the destructor on the object (if it hasn't already been deleted)

Parameters

  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ evalBuiltinMethodWithPrivateData()

DLLLOCAL QoreValue QoreObject::evalBuiltinMethodWithPrivateData | ( | const QoreMethod & | method,
|  | const BuiltinNormalMethodVariantBase * | meth,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |

called to evaluate a builtin method when private data is available

Parameters

  method | a constant reference to the QoreMethod object
  meth | the name of the method to evalute
  args | the arguments for the method
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ evalImpl()

virtual DLLLOCAL QoreValue QoreObject::evalImpl | ( | bool & | needs_deref,
|  | ExceptionSink * | xsink
| ) |  | const
| protected virtual

should never be called, does nothing

in debugging builds calls to this function will abort

Implements AbstractQoreNode.

## ◆ evalMember() [1/2]

DLLEXPORT QoreValue QoreObject::evalMember | ( | const QoreString * | member,
|  | ExceptionSink * | xsink
| ) |  |

returns the value of the member with an incremented reference count, or executes the memberGate() method and returns the value

Parameters

  member | the name of the member to get the value for (or evaluate the memberGate() method against)
  xsink | if an error occurs, the Qore-language exception information will be added here

Since
  Qore 0.9.5 part of the public API

## ◆ evalMember() [2/2]

DLLEXPORT QoreValue QoreObject::evalMember | ( | const char * | member,
|  | ExceptionSink * | xsink
| ) |  |

returns the value of the member with an incremented reference count, or executes the memberGate() method and returns the value

Parameters

  member | the name of the member to get the value for (or evaluate the memberGate() method against); must be in the default encoding (normally UTF-8)
  xsink | if an error occurs, the Qore-language exception information will be added here

Since
  Qore 0.9.5

## ◆ evalMethod() [1/4]

DLLEXPORT QoreValue QoreObject::evalMethod | ( | const QoreString * | name,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |

evaluates the given method with the arguments passed and returns the return value, caller owns any reference returned

Parameters

  name | the name of the method to evaluate
  args | the arguments for the method (may be 0)
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ evalMethod() [2/4]

DLLEXPORT QoreValue QoreObject::evalMethod | ( | const char * | name,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |

evaluates the given method with the arguments passed and returns the return value, caller owns any reference returned

Parameters

  name | the name of the method to evaluate, must be in QCS_DEFAULT encoding
  args | the arguments for the method (may be 0)
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ evalMethod() [3/4]

DLLEXPORT QoreValue QoreObject::evalMethod | ( | const QoreMethod & | method,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |

evaluates the given method with the arguments passed and returns the return value, caller owns the AbstractQoreNode (reference) returned

Parameters

  method | the method to evaluate
  args | the arguments for the method (may be 0)
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ evalMethod() [4/4]

DLLEXPORT QoreValue QoreObject::evalMethod | ( | const QoreMethod & | method,
|  | const QoreClass * | class_ctx,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |

evaluates the given method with the given class context and arguments passed and returns the return value, caller owns the AbstractQoreNode (reference) returned

Parameters

  method | the method to evaluate
  class_ctx | the class context for the method evaluation for evaluating private:internal methods
  args | the arguments for the method (may be 0)
  xsink | if an error occurs, the Qore-language exception information will be added here

Returns
  the value returned by the method; the caller owns any reference returned

Since
  Qore 0.9

## ◆ evalMethodVariant()

DLLEXPORT QoreValue QoreObject::evalMethodVariant | ( | const QoreMethod & | method,
|  | const QoreClass * | class_ctx,
|  | const QoreExternalMethodVariant * | variant,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |

executes a normal object method variant

Since
  Qore 0.9

## ◆ evalStaticMethod() [1/2]

static DLLEXPORT QoreValue QoreObject::evalStaticMethod | ( | const QoreMethod & | method,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |
| static

executes a static method

Since
  Qore 0.9

## ◆ evalStaticMethod() [2/2]

static DLLEXPORT QoreValue QoreObject::evalStaticMethod | ( | const QoreMethod & | method,
|  | const QoreClass * | class_ctx,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |
| static

executes a static method with the given class context to access private:internal methods

Since
  Qore 0.9

## ◆ evalStaticMethodVariant() [1/2]

static DLLEXPORT QoreValue QoreObject::evalStaticMethodVariant | ( | const QoreMethod & | method,
|  | const QoreExternalMethodVariant * | variant,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |
| static

executes a static method variant

Since
  Qore 0.9

## ◆ evalStaticMethodVariant() [2/2]

static DLLEXPORT QoreValue QoreObject::evalStaticMethodVariant | ( | const QoreMethod & | method,
|  | const QoreClass * | class_ctx,
|  | const QoreExternalMethodVariant * | variant,
|  | const QoreListNode * | args,
|  | ExceptionSink * | xsink
| ) |  |
| static

executes a static method variant with the given class context to access private:internal methods

Since
  Qore 0.9

## ◆ externalDelete()

DLLEXPORT void QoreObject::externalDelete | ( | qore_classid_t | key,
|  | ExceptionSink * | xsink
| ) |  |

call this function when an object's private data is deleted externally

this function will clear the private data and delete the object

Parameters

  key | the class ID of the class that owns the private data
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ getAndClearPrivateData()

DLLLOCAL AbstractPrivateData* QoreObject::getAndClearPrivateData | ( | qore_classid_t | key,
|  | ExceptionSink * | xsink
| ) |  |

retrieves the private data pointer and clears it from the object's private data store, used when executing destructors

Parameters

  key | the class key to use
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ getAsBoolImpl()

virtual DLLEXPORT bool QoreObject::getAsBoolImpl | ( |  | ) | const
| virtual

returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when empty

Returns
  false unless perl-boolean-evaluation is enabled, in which case it returns false only when empty

Reimplemented from AbstractQoreNode.

## ◆ getAsString() [1/2]

virtual DLLEXPORT int QoreObject::getAsString | ( | QoreString & | str,
|  | int | foff,
|  | ExceptionSink * | xsink
| ) |  | const
| virtual

concatenate the verbose string representation of the list (including all contained values) to an existing QoreString

used for n and N printf formatting

Parameters

  str | the string representation of the type will be concatenated to this QoreString reference
  foff | for multi-line formatting offset, -1 = no line breaks
  xsink | if an error occurs, the Qore-language exception information will be added here

Returns
  -1 for exception raised, 0 = OK

Implements AbstractQoreNode.

## ◆ getAsString() [2/2]

virtual DLLEXPORT QoreString* QoreObject::getAsString | ( | bool & | del,
|  | int | foff,
|  | ExceptionSink * | xsink
| ) |  | const
| virtual

returns a QoreString giving the verbose string representation of the List (including all contained values)

used for n and N printf formatting

Parameters

  del | if this is true when the function returns, then the returned QoreString pointer should be deleted, if false, then it must not be
  foff | for multi-line formatting offset, -1 = no line breaks
  xsink | if an error occurs, the Qore-language exception information will be added here NOTE: Use the QoreNodeAsStringHelper class (defined in QoreStringNode.h) instead of using this function directly

See also
  QoreNodeAsStringHelper

Implements AbstractQoreNode.

## ◆ getClass() [1/3]

DLLEXPORT const QoreClass* QoreObject::getClass | ( | qore_classid_t | cid | ) | const

returns a pointer to a QoreClass object if the class ID passed is a valid class in the hierarchy

Parameters

  cid | the class ID passed

Returns
  a pointer to a QoreClass object if the class ID passed is a valid class in the hierarchy

## ◆ getClass() [2/3]

DLLEXPORT const QoreClass* QoreObject::getClass | ( | qore_classid_t | cid,
|  | bool & | priv
| ) |  | const

returns a pointer to the QoreClass object representing the class ID passed if it exists in the class hierarchy and sets a flag indicating if it's privately inherited or not

if the class ID is equal to the current class or is a base class of the current class, the appropriate QoreClass pointer will be returned.

Parameters

  cid | the class ID of the QoreClass to find
  priv | a flag indicating if the class is privately inherited or not

Returns
  a pointer to the QoreClass object representing the class ID passed if it exists in the class hierarchy

## ◆ getClass() [3/3]

DLLEXPORT const QoreClass* QoreObject::getClass | ( |  | ) | const

returns a pointer to the QoreClass of this object

Returns
  a pointer to the QoreClass of this object

## ◆ getClassAccess()

DLLEXPORT ClassAccess QoreObject::getClassAccess | ( | const QoreClass & | cls | ) | const

returns the accessibility of the class in the object's hierachy or Inaccessible the object does not inherit the class at all

Parameters

  cls | the class to check

Returns
  the accessibility of the class in the object's hierachy or Inaccessible the object does not inherit the class at all

Since
  Qore 0.9

## ◆ getClassName()

DLLEXPORT const char* QoreObject::getClassName | ( |  | ) | const

returns the name of the class

Returns
  the name of the class

## ◆ getMemberAsBigInt()

DLLEXPORT int64 QoreObject::getMemberAsBigInt | ( | const char * | mem,
|  | bool & | found,
|  | ExceptionSink * | xsink
| ) |  | const

returns the value of the given member as an int64

Parameters

  mem | the name member to retrieve the value for
  found | returns true if the member was found, false if not
  xsink | if an error occurs, the Qore-language exception information will be added here

Returns
  the value of the given member as an int64

## ◆ getMemberList()

DLLEXPORT QoreListNode* QoreObject::getMemberList | ( | ExceptionSink * | xsink | ) | const

returns the list of members, caller owns the list returned

Parameters

  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ getMemberValueNoMethod() [1/2]

DLLEXPORT QoreValue QoreObject::getMemberValueNoMethod | ( | const QoreString * | key,
|  | AutoVLock * | vl,
|  | ExceptionSink * | xsink
| ) |  | const

returns the pointer to the value of the member

if the member exists, the lock is held and added to the AutoVLock "vl", otherwise the lock is released an exception will be thrown if the character encoding conversion fails also if the object has a deleted status an exception will be thrown NOTE: the value returned is not referenced by this function, but rather the object is locked

Parameters

  key | the name of the member
  vl | the AutoVLock container for nested locking
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ getMemberValueNoMethod() [2/2]

DLLEXPORT QoreValue QoreObject::getMemberValueNoMethod | ( | const char * | key,
|  | AutoVLock * | vl,
|  | ExceptionSink * | xsink
| ) |  | const

returns the pointer to the value of the member

NOTE: the value returned is not referenced by this function, but rather the object is locked

Parameters

  key | the name of the member, assumed to be in the default encoding (QCS_DEFAULT)
  vl | the AutoVLock container for nested locking
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ getProgram()

DLLEXPORT QoreProgram* QoreObject::getProgram | ( |  | ) | const

returns the QoreProgram object associated with this object

for system objects only (created with the system constructor) this will be 0

Returns
  the QoreProgram object associated with this object

## ◆ getReferencedMemberNoMethod() [1/2]

DLLEXPORT QoreValue QoreObject::getReferencedMemberNoMethod | ( | const char * | mem,
|  | ExceptionSink * | xsink
| ) |  | const

returns the value of the given member with the reference count incremented, the caller owns any reference returned

Parameters

  mem | the name member to retrieve the value for
  xsink | if an error occurs, the Qore-language exception information will be added here

Returns
  the value of the given member with the reference count incremented, the caller owns any reference returned

## ◆ getReferencedMemberNoMethod() [2/2]

DLLEXPORT QoreValue QoreObject::getReferencedMemberNoMethod | ( | const char * | key,
|  | const QoreClass * | cls,
|  | ExceptionSink * | xsink
| ) |  | const

returns the value of the given member as accessed from the given class; caller owns any reference returned

Parameters

  key | the name of the member, assumed to be in the default encoding (QCS_DEFAULT)
  cls | the class context for private:internal members; may be nullptr
  xsink | if an error occurs, the Qore-language exception information will be added here

Since
  Qore 0.9

## ◆ getReferencedPrivateData()

DLLEXPORT AbstractPrivateData* QoreObject::getReferencedPrivateData | ( | qore_classid_t | key,
|  | ExceptionSink * | xsink
| ) |  | const

returns the private data corresponding to the class ID passed with an incremented reference count, caller owns the reference

Parameters

  key | the class ID of the class to get the private data for
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ getSurfaceClass()

DLLEXPORT const QoreClass* QoreObject::getSurfaceClass | ( |  | ) | const

returns a pointer to the QoreClass of this object or to the injection target class in case the class was injected

Returns
  a pointer to the QoreClass of this object or to the injection target class in case the class was injected

If the class was not injected, this this method returns the same value as getClass()

Since
  Qore 1.0.3

## ◆ getSurfaceClassName()

DLLEXPORT const char* QoreObject::getSurfaceClassName | ( |  | ) | const

returns the name of the class or to the name of the injection target class in case the class was injected

Returns
  the name of the class or to the name of the injection target class in case the class was injected

If the class was not injected, this this method returns the same value as getClassName()

Since
  Qore 1.0.3

## ◆ is_equal_hard()

virtual DLLEXPORT bool QoreObject::is_equal_hard | ( | const AbstractQoreNode * | v,
|  | ExceptionSink * | xsink
| ) |  | const
| virtual

tests for equality ("deep compare" including all contained values) without type conversions (hard compare)

Parameters

  v | the value to compare
  xsink | if an error occurs, the Qore-language exception information will be added here

Implements AbstractQoreNode.

## ◆ is_equal_soft()

virtual DLLEXPORT bool QoreObject::is_equal_soft | ( | const AbstractQoreNode * | v,
|  | ExceptionSink * | xsink
| ) |  | const
| virtual

tests for equality ("deep compare" including all contained values) with possible type conversion (soft compare)

Parameters

  v | the value to compare
  xsink | if an error occurs, the Qore-language exception information will be added here

Implements AbstractQoreNode.

## ◆ isSystemObject()

DLLEXPORT bool QoreObject::isSystemObject | ( |  | ) | const

returns true if the object is a system object (created with the system constructor)

Returns
  true if the object is a system object (created with the system constructor)

## ◆ isValid()

DLLEXPORT bool QoreObject::isValid | ( |  | ) | const

returns true if the object is valid

Returns
  true if the object is valid

## ◆ obliterate()

DLLLOCAL void QoreObject::obliterate | ( | ExceptionSink * | xsink | ) |

destroys all members and dereferences all private data structures

Parameters

  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ removeMember() [1/2]

DLLEXPORT void QoreObject::removeMember | ( | const QoreString * | key,
|  | ExceptionSink * | xsink
| ) |  |

removes a member from the object without explicitly calling destructors; the value is only dereferenced

objects will be destructed if they go out of scope, however

Parameters

  key | the name of the member to remove
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ removeMember() [2/2]

DLLEXPORT void QoreObject::removeMember | ( | const char * | key,
|  | ExceptionSink * | xsink
| ) |  |

removes a member from the object without explicitly calling destructors; the value is only dereferenced

objects will be destructed if they go out of scope, however

Parameters

  key | the name of the member to remove, assumed to be in the default encoding (QCS_DEFAULT)
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ setMemberValue()

DLLEXPORT int QoreObject::setMemberValue | ( | const char * | key,
|  | const QoreClass * | cls,
|  | const QoreValue | val,
|  | ExceptionSink * | xsink
| ) |  |

sets the value of the given member as accessed from the given class

Parameters

  key | the name of the member, assumed to be in the default encoding (QCS_DEFAULT)
  cls | the class context for private:internal members; may be nullptr
  val | the value to set
  xsink | if an error occurs, the Qore-language exception information will be added here

Returns
  0 = no errors, -1 = Qore-language exception raised

Since
  Qore 0.9

## ◆ setPrivate()

DLLEXPORT void QoreObject::setPrivate | ( | qore_classid_t | key,
|  | AbstractPrivateData * | pd
| ) |  |

sets private data for the object against the class ID passed, used in C++ functions implementing Qore constructors

Parameters

  key | the class ID of the class to set the private data for
  pd | the private data for the given class ID

## ◆ setValue()

DLLEXPORT void QoreObject::setValue | ( | const char * | key,
|  | QoreValue | val,
|  | ExceptionSink * | xsink
| ) |  |

sets the value of the given member to the given value

the value must be already referenced for the assignment to the object

Parameters

  key | the name of the member
  val | the value to set for the member (must be already referenced for the assignment, 0 is OK too)
  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ size()

DLLEXPORT int QoreObject::size | ( | ExceptionSink * | xsink | ) | const

returns the number of members of the object

Parameters

  xsink | if an error occurs, the Qore-language exception information will be added here

## ◆ takeMember() [1/2]

DLLEXPORT QoreValue QoreObject::takeMember | ( | const QoreString * | key,
|  | ExceptionSink * | xsink
| ) |  |

removes a member from the object without explicitly calling destructors and returns the value removed; the caller owns the reference returned

if a Qore-language exception is raised, the return value is always 0

Parameters

  key | the name of the member to remove
  xsink | if an error occurs, the Qore-language exception information will be added here

Returns
  the value removed from the object; caller owns the reference

## ◆ takeMember() [2/2]

DLLEXPORT QoreValue QoreObject::takeMember | ( | const char * | key,
|  | ExceptionSink * | xsink
| ) |  |

removes a member from the object without explicitly calling destructors and returns the value removed; the caller owns the reference returned

if a Qore-language exception is raised, the return value is always 0

Parameters

  key | the name of the member to remove, assumed to be in the default encoding (QCS_DEFAULT)
  xsink | if an error occurs, the Qore-language exception information will be added here

Returns
  the value removed from the object; caller owns the reference

## ◆ tDeref()

DLLEXPORT void QoreObject::tDeref | ( |  | ) |

decrements the existence reference count, when it reaches 0 the C++ object ("this") will be deleted

To increment the existence reference count, call QoreObject::tRef()

See also
  QoreObject::tRef()

## ◆ tRef()

DLLEXPORT void QoreObject::tRef | ( |  | ) | const

increments the existence reference count

Will not prolong the scope of the object (use QoreObject::ref() to prolong the scope of the object). To derecrement the count, call QoreObject::tDeref()

See also
  QoreObject::tDeref()
  QoreObject::ref()

## ◆ tryGetReferencedPrivateData()

DLLEXPORT AbstractPrivateData* QoreObject::tryGetReferencedPrivateData | ( | qore_classid_t | key,
|  | ExceptionSink * | xsink
| ) |  | const

returns the private data corresponding to the class ID passed with an incremented reference count if it exists, caller owns the reference

Parameters

  key | the class ID of the class to get the private data for
  xsink | if an error occurs (the object has already been deleted), the Qore-language exception information will be added here

Since
  Qore 0.8.13

## ◆ validInstanceOf() [1/2]

DLLEXPORT bool QoreObject::validInstanceOf | ( | qore_classid_t | cid | ) | const

returns true if this object is a valid instance of the classid passed

Parameters

  cid | the class ID to check

Deprecated:
  use validInstanceOf(const QoreClass&) instead

## ◆ validInstanceOf() [2/2]

DLLEXPORT bool QoreObject::validInstanceOf | ( | const QoreClass & | qc | ) | const

returns true if this object is a valid instance of the classid passed

Parameters

  qc | the class to check

## ◆ validInstanceOfStrict()

DLLEXPORT bool QoreObject::validInstanceOfStrict | ( | const QoreClass & | qc | ) | const

returns true if this object is a valid instance of the classid passed; does not check for injected compatibility

Parameters

  qc | the class to check

Since
  Qore 1.0.3

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

- include/qore/QoreObject.h