Qore Programming Language 1.19.5
Loading...
Searching...
No Matches
QoreObject.h
1/* -*- mode: c++; indent-tabs-mode: nil -*- */
2/*
3 QoreObject.h
4
5 thread-safe object definition
6
7 Qore Programming Language
8
9 Copyright (C) 2003 - 2023 Qore Technologies, s.r.o.
10
11 Permission is hereby granted, free of charge, to any person obtaining a
12 copy of this software and associated documentation files (the "Software"),
13 to deal in the Software without restriction, including without limitation
14 the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 and/or sell copies of the Software, and to permit persons to whom the
16 Software is furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28
29 Note that the Qore library is released under a choice of three open-source
30 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
31 information.
32*/
33
34#ifndef _QORE_QOREOBJECT_H
35
36#define _QORE_QOREOBJECT_H
37
38class AutoVLock;
39class VRMutex;
40class BuiltinCopy;
41class BuiltinNormalMethodVariantBase;
42class BuiltinCopyVariantBase;
44class QoreProgram;
45class ReferenceNode;
47
49
63 friend class qore_object_private;
64 friend class ObjectRSetHelper;
65 friend class ObjectRSet;
66 friend class qore_object_dereference_helper;
67
68public:
70
74 DLLEXPORT QoreObject(const QoreClass* oc, QoreProgram* p);
75
77
82 DLLEXPORT QoreObject(const QoreClass* oc, QoreProgram* p, AbstractPrivateData* data);
83
85 DLLEXPORT bool hasMember(const char* mem, ExceptionSink* xsink) const;
86
88
90 DLLEXPORT virtual bool getAsBoolImpl() const;
91
93
99 DLLEXPORT virtual int getAsString(QoreString &str, int foff, ExceptionSink* xsink) const;
100
102
109 DLLEXPORT virtual QoreString* getAsString(bool& del, int foff, ExceptionSink* xsink) const;
110
112 DLLEXPORT virtual AbstractQoreNode* realCopy() const;
113
115
119 DLLEXPORT virtual bool is_equal_soft(const AbstractQoreNode* v, ExceptionSink* xsink) const;
120
122
126 DLLEXPORT virtual bool is_equal_hard(const AbstractQoreNode* v, ExceptionSink* xsink) const;
127
129 DLLEXPORT virtual const char* getTypeName() const;
130
132 DLLLOCAL static const char* getStaticTypeName() {
133 return "object";
134 }
135
137 DLLLOCAL static qore_type_t getStaticTypeCode() {
138 return NT_OBJECT;
139 }
140
142
146 DLLEXPORT bool validInstanceOf(qore_classid_t cid) const;
147
149
151 DLLEXPORT bool validInstanceOf(const QoreClass& qc) const;
152
154
158 DLLEXPORT bool validInstanceOfStrict(const QoreClass& qc) const;
159
161
166 DLLEXPORT void setValue(const char* key, QoreValue val, ExceptionSink* xsink);
167
169
172 DLLEXPORT QoreListNode* getMemberList(ExceptionSink* xsink) const;
173
175
179 DLLEXPORT void deleteMemberValue(const QoreString* key, ExceptionSink* xsink);
180
182
186 DLLEXPORT void deleteMemberValue(const char* key, ExceptionSink* xsink);
187
189
193 DLLEXPORT void removeMember(const QoreString* key, ExceptionSink* xsink);
194
196
200 DLLEXPORT void removeMember(const char* key, ExceptionSink* xsink);
201
203
208 DLLEXPORT QoreValue takeMember(const QoreString* key, ExceptionSink* xsink);
209
211
216 DLLEXPORT QoreValue takeMember(const char* key, ExceptionSink* xsink);
217
219
222 DLLEXPORT int size(ExceptionSink* xsink) const;
223
225
229 DLLEXPORT bool compareSoft(const QoreObject* obj, ExceptionSink* xsink) const;
230
232
236 DLLEXPORT bool compareHard(const QoreObject* obj, ExceptionSink* xsink) const;
237
239
244 DLLEXPORT QoreValue getReferencedMemberNoMethod(const char* mem, ExceptionSink* xsink) const;
245
247
253 DLLEXPORT ReferenceNode* getReferenceToMember(const char* mem, ExceptionSink* xsink);
254
256
262 DLLEXPORT int64 getMemberAsBigInt(const char* mem, bool& found, ExceptionSink* xsink) const;
263
265
268 DLLEXPORT QoreHashNode* copyData(ExceptionSink* xsink) const;
269
271
276
278
283
285
290 template <class T>
293 assert(!rv || dynamic_cast<T*>(rv));
294 return reinterpret_cast<T*>(rv);
295 }
296
298
305
307
313 template <class T>
316 assert(!rv || dynamic_cast<T*>(rv));
317 return reinterpret_cast<T*>(rv);
318 }
319
321
326 DLLEXPORT QoreValue evalMethod(const QoreString* name, const QoreListNode* args, ExceptionSink* xsink);
327
329
334 DLLEXPORT QoreValue evalMethod(const char* name, const QoreListNode* args, ExceptionSink* xsink);
335
337
342 DLLEXPORT QoreValue evalMethod(const QoreMethod& method, const QoreListNode* args, ExceptionSink* xsink);
343
345
356 DLLEXPORT QoreValue evalMethod(const char* name, const QoreClass* class_ctx, const QoreListNode* args,
357 ExceptionSink* xsink);
358
360
370 DLLEXPORT QoreValue evalMethod(const QoreMethod& method, const QoreClass* class_ctx, const QoreListNode* args, ExceptionSink* xsink);
371
373
376 DLLEXPORT void doDelete(ExceptionSink* xsink);
377
379
383 DLLEXPORT const QoreClass* getClass(qore_classid_t cid) const;
384
386
393 DLLEXPORT const QoreClass* getClass(qore_classid_t cid, bool& priv) const;
394
396
402 DLLEXPORT ClassAccess getClassAccess(const QoreClass& cls) const;
403
405
408 DLLEXPORT const QoreClass* getClass() const;
409
411
414 DLLEXPORT const char* getClassName() const;
415
417
424 DLLEXPORT const QoreClass* getSurfaceClass() const;
425
427
434 DLLEXPORT const char* getSurfaceClassName() const;
435
437
440 DLLEXPORT bool isValid() const;
441
443
446 DLLEXPORT QoreProgram* getProgram() const;
447
449
452 DLLEXPORT bool isSystemObject() const;
453
455
460 DLLEXPORT void tRef() const;
461
463
466 DLLEXPORT void tDeref();
467
469 DLLEXPORT void realRef();
470
472 DLLEXPORT void realDeref(ExceptionSink* xsink);
473
475
483 DLLEXPORT QoreValue getMemberValueNoMethod(const QoreString* key, AutoVLock* vl, ExceptionSink* xsink) const;
484
486
492 DLLEXPORT QoreValue getMemberValueNoMethod(const char* key, AutoVLock* vl, ExceptionSink* xsink) const;
493
495
504 DLLEXPORT QoreValue getMemberValueNoMethod(const char* key, const QoreClass* cls, AutoVLock* vl,
505 ExceptionSink* xsink) const;
506
508
517 DLLEXPORT int editMemberValue(const char* key, const QoreClass* cls, QoreTypeSafeReferenceHelper& ref, bool for_remove = false) const;
518
520
526 DLLEXPORT QoreValue getReferencedMemberNoMethod(const char* key, const QoreClass* cls, ExceptionSink* xsink) const;
527
529
538 DLLEXPORT int setMemberValue(const char* key, const QoreClass* cls, const QoreValue val, ExceptionSink* xsink);
539
541
550 DLLEXPORT int setMemberValue(const char* key, const QoreClass* cls, const QoreValue val,
552
554
558 DLLEXPORT void externalDelete(qore_classid_t key, ExceptionSink* xsink);
559
561 DLLEXPORT QoreValue evalMethodVariant(const QoreMethod& method, const QoreExternalMethodVariant* variant,
562 const QoreListNode* args, ExceptionSink* xsink);
563
565
567 DLLEXPORT QoreValue evalMethodVariant(const QoreMethod& method, const QoreClass* class_ctx,
568 const QoreExternalMethodVariant* variant, const QoreListNode* args, ExceptionSink* xsink);
569
571
573 DLLEXPORT static QoreValue evalStaticMethod(const QoreMethod& method, const QoreListNode* args, ExceptionSink* xsink);
574
576
578 DLLEXPORT static QoreValue evalStaticMethod(const QoreMethod& method, const QoreClass* class_ctx,
579 const QoreListNode* args, ExceptionSink* xsink);
580
582
584 DLLEXPORT static QoreValue evalStaticMethodVariant(const QoreMethod& method,
585 const QoreExternalMethodVariant* variant, const QoreListNode* args, ExceptionSink* xsink);
586
588
590 DLLEXPORT static QoreValue evalStaticMethodVariant(const QoreMethod& method, const QoreClass* class_ctx,
591 const QoreExternalMethodVariant* variant, const QoreListNode* args, ExceptionSink* xsink);
592
594
600 DLLEXPORT QoreValue evalMember(const QoreString* member, ExceptionSink* xsink);
601
603
610 DLLEXPORT QoreValue evalMember(const char* member, ExceptionSink* xsink);
611
613
615 DLLLOCAL QoreObject* objectRefSelf() const {
616 ref();
617 return const_cast<QoreObject*>(this);
618 }
619
620 DLLLOCAL int getStatus() const;
621
622 DLLLOCAL class KeyNode* getReferencedPrivateDataNode(qore_classid_t key);
623
625
630
632
639 const BuiltinNormalMethodVariantBase* meth, const QoreListNode* args, ExceptionSink* xsink);
640
642 DLLLOCAL void evalCopyMethodWithPrivateData(const QoreClass &thisclass, const BuiltinCopyVariantBase* meth,
643 QoreObject* self, ExceptionSink* xsink);
644
646
650 DLLLOCAL void addPrivateDataToString(QoreString* str, ExceptionSink* xsink) const;
651
653
656 DLLLOCAL void obliterate(ExceptionSink* xsink);
657
659
664
665 // returns a new hash consisting of just the members of value_list
666 DLLLOCAL QoreHashNode* getSlice(const QoreListNode* value_list, ExceptionSink* xsink) const;
667
669 DLLLOCAL QoreObject(const QoreClass* oc, QoreProgram* p, QoreHashNode* d);
670
672 DLLLOCAL bool hasMemberNotification() const;
673
675 DLLLOCAL void execMemberNotification(const char* member, ExceptionSink* xsink);
676
677protected:
679
683 DLLEXPORT virtual bool derefImpl(ExceptionSink* xsink);
684
686
688 DLLLOCAL virtual QoreValue evalImpl(bool& needs_deref, ExceptionSink* xsink) const;
689
691 DLLLOCAL virtual void customRef() const;
692
694 DLLLOCAL virtual void customDeref(ExceptionSink* xsink);
695
697 DLLLOCAL virtual ~QoreObject();
698
699private:
701 class qore_object_private* priv;
702
704 DLLLOCAL QoreObject(const QoreObject&);
705
707 DLLLOCAL QoreObject& operator=(const QoreObject&);
708};
709
711
714public:
715 DLLLOCAL QoreObjectWeakRefHolder() {
716 }
717
718 DLLLOCAL QoreObjectWeakRefHolder(QoreObject* obj) : obj(obj) {
719 if (obj) {
720 obj->tRef();
721 }
722 }
723
724 DLLLOCAL ~QoreObjectWeakRefHolder() {
725 discard();
726 }
727
728 DLLLOCAL QoreObject* release() {
729 QoreObject* rv = obj;
730 obj = nullptr;
731 return rv;
732 }
733
734 DLLLOCAL void reset(QoreObject* obj = nullptr) {
735 discard();
736 this->obj = obj;
737 }
738
739 DLLLOCAL QoreObject* operator*() {
740 return obj;
741 }
742
743 DLLLOCAL const QoreObject* operator*() const {
744 return obj;
745 }
746
747 DLLLOCAL QoreObject* operator->() {
748 return obj;
749 }
750
751 DLLLOCAL const QoreObject* operator->() const {
752 return obj;
753 }
754
755 DLLLOCAL operator bool() {
756 return (bool)obj;
757 }
758
759 DLLLOCAL operator bool() const {
760 return (bool)obj;
761 }
762
763private:
764 QoreObject* obj = nullptr;
765
766 DLLLOCAL void discard() {
767 if (obj) {
768 obj->tDeref();
769 }
770 }
771
772 void* operator new(size_t) = delete;
774 QoreObjectWeakRefHolder& operator=(QoreObjectWeakRefHolder& orig) = delete;
775};
776
778template <class T>
780public:
781 DLLLOCAL PrivateDataRefHolder(ExceptionSink* xsink) : ReferenceHolder<T>(xsink) {
782 }
783
784 DLLLOCAL PrivateDataRefHolder(const QoreObject* o, qore_classid_t cid, ExceptionSink* xsink) : ReferenceHolder<T>(reinterpret_cast<T*>(o->getReferencedPrivateData(cid, xsink)), xsink) {
785 }
786
788 DLLLOCAL void operator=(T *nv) {
789 if (this->p)
790 this->p->deref(this->xsink);
791 this->p = nv;
792 }
793};
794
796template <class T>
798public:
799 DLLLOCAL TryPrivateDataRefHolder(const QoreObject* o, qore_classid_t cid, ExceptionSink* xsink) : ReferenceHolder<T>(reinterpret_cast<T*>(o->tryGetReferencedPrivateData(cid, xsink)), xsink) {
800 }
801
803 DLLLOCAL void operator=(T *nv) {
804 if (this->p)
805 this->p->deref(this->xsink);
806 this->p = nv;
807 }
808};
809
810class QorePrivateObjectAccessHelper {
811public:
812 DLLLOCAL QorePrivateObjectAccessHelper(ExceptionSink* xs) : xsink(xs), ptr(0) {
813 }
814
815 DLLLOCAL operator bool() const {
816 return (bool)ptr;
817 }
818
819private:
820 DLLLOCAL QorePrivateObjectAccessHelper(const QorePrivateObjectAccessHelper&) = delete;
821 DLLLOCAL QorePrivateObjectAccessHelper& operator=(const QorePrivateObjectAccessHelper&) = delete;
822 DLLLOCAL void* operator new(size_t) = delete;
823
824protected:
825 ExceptionSink* xsink;
826 void* ptr;
827};
828
829#endif
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:57
DLLEXPORT void ref() const
increments the reference count
AutoVLock is a container for safely managing global variable and object lock handovers,...
Definition: AutoVLock.h:80
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
convenience class for holding AbstractPrivateData references
Definition: QoreObject.h:779
DLLLOCAL void operator=(T *nv)
assigns a new pointer to the holder, dereferences the current pointer if any
Definition: QoreObject.h:788
defines a Qore-language class
Definition: QoreClass.h:257
external wrapper class for method variants
Definition: QoreReflection.h:90
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:52
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
a method in a QoreClass
Definition: QoreClass.h:143
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:62
DLLLOCAL QoreObject(const QoreClass *oc, QoreProgram *p, QoreHashNode *d)
creates the object with the initial data passed as "d", used by the copy constructor
DLLEXPORT int editMemberValue(const char *key, const QoreClass *cls, QoreTypeSafeReferenceHelper &ref, bool for_remove=false) const
Sets the reference helper for editing the member and leaves the object locked.
virtual DLLEXPORT bool derefImpl(ExceptionSink *xsink)
runs the destructor if necessary and dereferences all members
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,...
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 va...
DLLLOCAL bool hasMemberNotification() const
returns true if the class has a memberNotification method
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 ...
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 inje...
DLLLOCAL T * getReferencedPrivateData(qore_classid_t key, ExceptionSink *xsink) const
returns the private data corresponding to the class ID passed with an incremented reference count,...
Definition: QoreObject.h:291
DLLEXPORT void tRef() const
increments the existence reference count
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 ...
DLLLOCAL QoreObject * objectRefSelf() const
Returns the object with the reference count increased.
Definition: QoreObject.h:615
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
DLLEXPORT bool compareSoft(const QoreObject *obj, ExceptionSink *xsink) const
tests for equality ("deep compare" including all contained values) with possible type conversion of c...
DLLEXPORT QoreValue getMemberValueNoMethod(const char *key, const QoreClass *cls, AutoVLock *vl, ExceptionSink *xsink) const
returns the pointer to the value of the member
virtual DLLLOCAL void customRef() const
custom reference handler
DLLEXPORT QoreValue evalMember(const QoreString *member, ExceptionSink *xsink)
returns the value of the member with an incremented reference count, or executes the memberGate() met...
virtual DLLLOCAL void customDeref(ExceptionSink *xsink)
custom dereference handler - with delete
DLLEXPORT void tDeref()
decrements the existence reference count, when it reaches 0 the C++ object ("this") will be deleted
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 exis...
DLLEXPORT QoreValue evalMethod(const QoreString *name, const QoreListNode *args, ExceptionSink *xsink)
evaluates the given method with the arguments passed and returns the return value,...
DLLEXPORT bool isValid() const
returns true if the object is valid
DLLEXPORT bool isSystemObject() const
returns true if the object is a system object (created with the system constructor)
DLLEXPORT void removeMember(const QoreString *key, ExceptionSink *xsink)
removes a member from the object without explicitly calling destructors; the value is only dereferenc...
DLLEXPORT void realDeref(ExceptionSink *xsink)
decrements the standard reference count of the object for references that cannot be part of a recursi...
DLLEXPORT void removeMember(const char *key, ExceptionSink *xsink)
removes a member from the object without explicitly calling destructors; the value is only dereferenc...
DLLEXPORT bool compareHard(const QoreObject *obj, ExceptionSink *xsink) const
tests for equality ("deep compare" including all contained values) with possible type conversion of c...
DLLEXPORT int size(ExceptionSink *xsink) const
returns the number of members of the object
virtual DLLLOCAL ~QoreObject()
destructor
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 (destructo...
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
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 ret...
DLLLOCAL void defaultSystemDestructor(qore_classid_t classID, ExceptionSink *xsink)
runs the destructor for system objects
DLLEXPORT const QoreClass * getClass() const
returns a pointer to the QoreClass of this object
DLLEXPORT void setValue(const char *key, QoreValue val, ExceptionSink *xsink)
sets the value of the given member to the given value
static DLLLOCAL const char * getStaticTypeName()
returns the type name (useful in templates)
Definition: QoreObject.h:132
static DLLLOCAL qore_type_t getStaticTypeCode()
returns the type code (useful in templates)
Definition: QoreObject.h:137
DLLLOCAL void addPrivateDataToString(QoreString *str, ExceptionSink *xsink) const
concatenates info about private data to a string
DLLLOCAL void execMemberNotification(const char *member, ExceptionSink *xsink)
executes the member notification on the object the given member
DLLEXPORT QoreValue getMemberValueNoMethod(const QoreString *key, AutoVLock *vl, ExceptionSink *xsink) const
returns the pointer to the value of the member
static DLLEXPORT QoreValue evalStaticMethodVariant(const QoreMethod &method, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink)
executes a static method variant
DLLEXPORT bool validInstanceOf(const QoreClass &qc) const
returns true if this object is a valid instance of the classid passed
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 (destructo...
DLLEXPORT QoreValue takeMember(const char *key, ExceptionSink *xsink)
removes a member from the object without explicitly calling destructors and returns the value removed...
DLLEXPORT QoreValue evalMethodVariant(const QoreMethod &method, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink)
executes a normal object method variant
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" (n...
DLLLOCAL void obliterate(ExceptionSink *xsink)
destroys all members and dereferences all private data structures
DLLEXPORT void doDelete(ExceptionSink *xsink)
runs the destructor on the object (if it hasn't already been deleted)
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 refer...
DLLEXPORT QoreValue evalMember(const char *member, ExceptionSink *xsink)
returns the value of the member with an incremented reference count, or executes the memberGate() met...
DLLLOCAL AbstractPrivateData * getAndClearPrivateData(qore_classid_t key, ExceptionSink *xsink)
retrieves the private data pointer and clears it from the object's private data store,...
DLLEXPORT bool validInstanceOf(qore_classid_t cid) const
returns true if this object is a valid instance of the classid passed
DLLEXPORT void externalDelete(qore_classid_t key, ExceptionSink *xsink)
call this function when an object's private data is deleted externally
static DLLEXPORT QoreValue evalStaticMethod(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink)
executes a static method
DLLEXPORT QoreValue getMemberValueNoMethod(const char *key, AutoVLock *vl, ExceptionSink *xsink) const
returns the pointer to the value of the member
DLLEXPORT ClassAccess getClassAccess(const QoreClass &cls) const
returns the accessibility of the class in the object's hierachy or Inaccessible the object does not i...
DLLLOCAL T * tryGetReferencedPrivateData(qore_classid_t key, ExceptionSink *xsink) const
returns the private data corresponding to the class ID passed with an incremented reference count if ...
Definition: QoreObject.h:314
virtual DLLEXPORT const char * getTypeName() const
returns the type name as a c string
DLLEXPORT QoreListNode * getMemberList(ExceptionSink *xsink) const
returns the list of members, caller owns the list returned
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...
DLLEXPORT QoreValue evalMethodVariant(const QoreMethod &method, const QoreClass *class_ctx, const QoreExternalMethodVariant *variant, const QoreListNode *args, ExceptionSink *xsink)
executes a normal object method variant
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 com...
DLLEXPORT QoreProgram * getProgram() const
returns the QoreProgram object associated with this object
DLLEXPORT QoreHashNode * copyData(ExceptionSink *xsink) const
retuns all member data of the object (or 0 if there's an exception), caller owns the QoreHashNode ref...
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 v...
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 co...
DLLEXPORT int64 getMemberAsBigInt(const char *mem, bool &found, ExceptionSink *xsink) const
returns the value of the given member as an int64
DLLEXPORT QoreValue evalMethod(const char *name, 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 v...
DLLEXPORT QoreValue evalMethod(const char *name, const QoreListNode *args, ExceptionSink *xsink)
evaluates the given method with the arguments passed and returns the return value,...
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 ...
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
DLLEXPORT QoreValue evalMethod(const QoreMethod &method, const QoreListNode *args, ExceptionSink *xsink)
evaluates the given method with the arguments passed and returns the return value,...
DLLEXPORT QoreValue takeMember(const QoreString *key, ExceptionSink *xsink)
removes a member from the object without explicitly calling destructors and returns the value removed...
DLLEXPORT const QoreClass * getSurfaceClass() const
returns a pointer to the QoreClass of this object or to the injection target class in case the class ...
virtual DLLEXPORT AbstractQoreNode * realCopy() const
performs a the same object with its reference count increased
DLLEXPORT void realRef()
increments the standard reference count of the object for references that cannot be part of a recursi...
DLLEXPORT ReferenceNode * getReferenceToMember(const char *mem, ExceptionSink *xsink)
Returns a reference to the given member, if the member is valid and accessible.
DLLEXPORT QoreObject(const QoreClass *oc, QoreProgram *p)
creates an object as belonging to the given class, the QoreProgram object is referenced for the life ...
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 (sof...
DLLEXPORT const char * getClassName() const
returns the name of the class
DLLEXPORT int setMemberValue(const char *key, const QoreClass *cls, const QoreValue val, QoreTypeSafeReferenceHelper &ref)
sets the value of the given member as accessed from the given class and leaves the object locked
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
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)
virtual DLLLOCAL QoreValue evalImpl(bool &needs_deref, ExceptionSink *xsink) const
should never be called, does nothing
virtual DLLEXPORT bool getAsBoolImpl() const
returns false unless perl-boolean-evaluation is enabled, in which case it returns false only when emp...
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
Convenience class for holding temporary / weak references to objects.
Definition: QoreObject.h:713
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:128
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
helper class to manage variable references passed to functions and class methods, stack only,...
Definition: QoreTypeSafeReferenceHelper.h:57
a templated class to manage a reference count of an object that can throw a Qore-language exception w...
Definition: ReferenceHolder.h:52
parse type: reference to a lvalue expression
Definition: ReferenceNode.h:45
convenience class for holding AbstractPrivateData references
Definition: QoreObject.h:797
DLLLOCAL void operator=(T *nv)
assigns a new pointer to the holder, dereferences the current pointer if any
Definition: QoreObject.h:803
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition: common.h:70
unsigned qore_classid_t
used for the unique class ID for QoreClass objects
Definition: common.h:79
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
const qore_type_t NT_OBJECT
type value for QoreObject
Definition: node_types.h:52
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:279