$darkmode
Qore Programming Language - C/C++ Library 1.19.2
QoreClass.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreClass.h
4 
5  Qore Programming Language
6 
7  Copyright (C) 2003 - 2023 Qore Technologies, s.r.o.
8 
9  Permission is hereby granted, free of charge, to any person obtaining a
10  copy of this software and associated documentation files (the "Software"),
11  to deal in the Software without restriction, including without limitation
12  the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  and/or sell copies of the Software, and to permit persons to whom the
14  Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  DEALINGS IN THE SOFTWARE.
26 
27  Note that the Qore library is released under a choice of three open-source
28  licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29  information.
30 */
31 
32 #ifndef _QORE_QORECLASS_H
33 
34 #define _QORE_QORECLASS_H
35 
36 #include <cstdarg>
37 #include <memory>
38 #include <string>
39 
40 // all qore class IDs
41 DLLEXPORT extern qore_classid_t CID_AUTOGATE;
42 DLLEXPORT extern qore_classid_t CID_AUTOLOCK;
43 DLLEXPORT extern qore_classid_t CID_AUTOREADLOCK;
44 DLLEXPORT extern qore_classid_t CID_AUTOWRITELOCK;
45 DLLEXPORT extern qore_classid_t CID_CONDITION;
46 DLLEXPORT extern qore_classid_t CID_COUNTER;
47 DLLEXPORT extern qore_classid_t CID_DATASOURCE;
48 DLLEXPORT extern qore_classid_t CID_DATASOURCEPOOL;
49 DLLEXPORT extern qore_classid_t CID_FILE;
50 DLLEXPORT extern qore_classid_t CID_FTPCLIENT;
51 DLLEXPORT extern qore_classid_t CID_GATE;
52 DLLEXPORT extern qore_classid_t CID_GETOPT;
53 DLLEXPORT extern qore_classid_t CID_HTTPCLIENT;
54 DLLEXPORT extern qore_classid_t CID_MUTEX;
55 DLLEXPORT extern qore_classid_t CID_PROGRAM;
56 DLLEXPORT extern qore_classid_t CID_PROGRAMDEBUG;
57 DLLEXPORT extern qore_classid_t CID_QUEUE;
58 DLLEXPORT extern qore_classid_t CID_RWLOCK;
59 DLLEXPORT extern qore_classid_t CID_SSLCERTIFICATE;
60 DLLEXPORT extern qore_classid_t CID_SSLPRIVATEKEY;
61 DLLEXPORT extern qore_classid_t CID_SEQUENCE;
62 DLLEXPORT extern qore_classid_t CID_SOCKET;
63 DLLEXPORT extern qore_classid_t CID_TERMIOS;
64 DLLEXPORT extern qore_classid_t CID_INPUTSTREAM;
65 DLLEXPORT extern qore_classid_t CID_OUTPUTSTREAM;
66 DLLEXPORT extern qore_classid_t CID_INPUTSTREAMBASE;
67 DLLEXPORT extern qore_classid_t CID_OUTPUTSTREAMBASE;
68 DLLEXPORT extern qore_classid_t CID_PROGRAM;
69 DLLEXPORT extern qore_classid_t CID_SERIALIZABLE;
70 DLLEXPORT extern qore_classid_t CID_ABSTRACTPOLLABLEIOOBJECT;
71 DLLEXPORT extern qore_classid_t CID_ABSTRACTPOLLABLEIOOBJECTBASE;
72 DLLEXPORT extern qore_classid_t CID_ABSTRACTPOLLOPERATION;
73 DLLEXPORT extern qore_classid_t CID_SOCKETPOLLOPERATIONBASE;
74 DLLEXPORT extern qore_classid_t CID_SOCKETPOLLOPERATION;
75 DLLEXPORT extern qore_classid_t CID_FILEPOLLOPERATIONBASE;
76 DLLEXPORT extern qore_classid_t CID_FILEPOLLOPERATION;
77 
78 DLLEXPORT extern QoreClass* QC_QUEUE;
79 DLLEXPORT extern QoreClass* QC_HTTPCLIENT;
80 DLLEXPORT extern QoreClass* QC_SSLCERTIFICATE;
81 DLLEXPORT extern QoreClass* QC_SSLPRIVATEKEY;
82 DLLEXPORT extern QoreClass* QC_PROGRAM;
83 DLLEXPORT extern QoreClass* QC_SERIALIZABLE;
84 DLLEXPORT extern QoreClass* QC_ABSTRACTPOLLABLEIOOBJECT;
85 DLLEXPORT extern QoreClass* QC_ABSTRACTPOLLABLEIOOBJECTBASE;
86 DLLEXPORT extern QoreClass* QC_ABSTRACTPOLLOPERATION;
87 DLLEXPORT extern QoreClass* QC_SOCKETPOLLOPERATIONBASE;
88 DLLEXPORT extern QoreClass* QC_SOCKETPOLLOPERATION;
89 DLLEXPORT extern QoreClass* QC_FILEPOLLOPERATIONBASE;
90 DLLEXPORT extern QoreClass* QC_FILEPOLLOPERATION;
91 
92 class BCList;
93 class BCSMList;
94 class BCAList;
95 class QoreObject;
96 class QoreClass;
97 class BCEAList;
98 class ParamList;
99 class QoreMemberInfo;
100 class BuiltinMethod;
101 class AbstractQoreFunctionVariant;
102 class AbstractFunctionSignature;
103 class UserMethod;
104 class BCANode;
105 class qore_method_private;
106 class MethodFunctionBase;
107 class NamedScope;
108 class ConstantList;
109 class MethodVariantBase;
110 
111 class QoreExternalVariant;
116 class QoreExternalMethodFunction;
121 
123 
125 enum method_type_e {
126  MT_None = 0, // not a method function/variant
127  MT_Normal = 1,
128  MT_Static = 2,
129  MT_Constructor = 3,
130  MT_Destructor = 4,
131  MT_Copy = 5,
132  MT_Pseudo = 6,
133 };
134 
136 
139 class QoreMethod {
140  friend class StaticMethodCallNode;
141  friend class QoreObject;
142  friend class qore_class_private;
143  friend class qore_method_private;
144  friend class BCList;
145 
146 private:
148  class qore_method_private* priv;
149 
151  DLLLOCAL QoreMethod(const QoreMethod&);
152 
154  DLLLOCAL QoreMethod& operator=(const QoreMethod&);
155 
156 public:
158 
160  DLLEXPORT bool isUser() const;
161 
163 
165  DLLEXPORT bool isBuiltin() const;
166 
168 
170  DLLEXPORT bool isPrivate() const;
171 
173  DLLEXPORT ClassAccess getAccess() const;
174 
176 
179  DLLEXPORT bool isStatic() const;
180 
182 
185  DLLEXPORT const char* getName() const;
186 
188 
191  DLLEXPORT const std::string& getNameStr() const;
192 
194  DLLEXPORT const QoreClass* getClass() const;
195 
197  DLLEXPORT const char* getClassName() const;
198 
200  DLLEXPORT bool existsVariant(const type_vec_t& paramTypeInfo) const;
201 
202  /* returns the return type information for the method if it is available and if
203  there is only one return type (there can be more return types if the method is
204  overloaded)
205  */
206  DLLEXPORT const QoreTypeInfo* getUniqueReturnTypeInfo() const;
207 
209 
213  DLLEXPORT QoreValue execManaged(QoreObject* self, const QoreListNode* args, ExceptionSink* xsink) const;
214 
216 
218  DLLEXPORT method_type_e getMethodType() const;
219 
221 
223  DLLEXPORT const QoreExternalMethodFunction* getFunction() const;
224 
225  DLLLOCAL QoreMethod(const QoreClass* p_class, MethodFunctionBase* n_func, bool n_static = false);
226 
227  DLLLOCAL bool inMethod(const QoreObject* self) const;
228  DLLLOCAL QoreMethod* copy(const QoreClass* p_class) const;
229  DLLLOCAL void assign_class(const QoreClass* p_class);
230  // non-exported destructor
231  DLLLOCAL ~QoreMethod();
232 };
233 
235 
238 public:
239  DLLEXPORT virtual ~AbstractQoreClassUserData();
240 
242  virtual AbstractQoreClassUserData* copy() const = 0;
243 
245  virtual void doDeref() = 0;
246 };
247 
249 
253 class QoreClass {
254  friend class BCList;
255  friend class BCNode;
256  friend class BCSMList;
257  friend class qore_object_private;
258  friend class qore_class_private;
259  friend class QoreObject;
260  friend class BCANode;
261  friend class qore_method_private;
262  friend class QoreMethodIterator;
263  friend class QoreStaticMethodIterator;
264  friend class ConstructorMethodFunction;
265  friend class QoreBuiltinClass;
266  friend class QoreParseClass;
267 
268 public:
270 
278  DLLEXPORT QoreClass(std::string&& n_name, std::string&& ns_path, int64 n_domain = QDOM_DEFAULT);
279 
281 
289  DLLEXPORT QoreClass(const char* n_name, const char* ns_path, int64 n_domain = QDOM_DEFAULT);
290 
292 
307  DLLEXPORT QoreClass(const char* n_name, const char* ns_path, int64 n_domain, const QoreTypeInfo* n_typeInfo);
308 
310 
312  DLLEXPORT QoreClass(const QoreClass& old);
313 
315 
317  DLLEXPORT virtual QoreClass* copyImport();
318 
320 
322  DLLEXPORT virtual QoreClass* copy();
323 
325 
327  DLLEXPORT QoreProgram* getProgram() const;
328 
330 
359  DLLEXPORT void addMethod(const char* n_name, q_method_n_t meth, ClassAccess access = Public, int64 n_flags = QCF_NO_FLAGS, int64 n_domain = QDOM_DEFAULT, const QoreTypeInfo* returnTypeInfo = 0, unsigned num_params = 0, ...);
360 
362 
396  DLLEXPORT void addMethod(const void* ptr, const char* n_name, q_external_method_t meth, ClassAccess access = Public, int64 n_flags = QCF_NO_FLAGS, int64 n_domain = QDOM_DEFAULT, const QoreTypeInfo* returnTypeInfo = 0, const type_vec_t& n_typeList = type_vec_t(), const arg_vec_t& defaultArgList = arg_vec_t(), const name_vec_t& n_names = name_vec_t());
397 
399  DLLEXPORT void addStaticMethod(const char* n_name, q_func_n_t meth, ClassAccess access = Public, int64 n_flags = QCF_NO_FLAGS, int64 n_domain = QDOM_DEFAULT, const QoreTypeInfo* returnTypeInfo = 0, unsigned num_params = 0, ...);
400 
402 
404  DLLEXPORT void addStaticMethod(const void* ptr, const char* n_name, q_external_static_method_t meth, ClassAccess access = Public, int64 n_flags = QCF_NO_FLAGS, int64 n_domain = QDOM_DEFAULT, const QoreTypeInfo* returnTypeInfo = 0, const type_vec_t& n_typeList = type_vec_t(), const arg_vec_t& defaultArgList = arg_vec_t(), const name_vec_t& n_names = name_vec_t());
405 
407  DLLEXPORT void addAbstractMethod(const char* n_name, ClassAccess access = Public, int64 n_flags = QCF_NO_FLAGS, const QoreTypeInfo* returnTypeInfo = 0, unsigned num_params = 0, ...);
408 
410  DLLEXPORT void addAbstractMethod(const char* n_name, ClassAccess access, int64 n_flags, const QoreTypeInfo* returnTypeInfo, const type_vec_t& n_typeList, const arg_vec_t& defaultArgList = arg_vec_t(), const name_vec_t& n_names = name_vec_t());
411 
413 
424  DLLEXPORT void setDestructor(q_destructor_t m);
425 
427 
439  DLLEXPORT void setDestructor(const void* ptr, q_external_destructor_t m);
440 
442  DLLEXPORT void addConstructor(q_constructor_n_t meth, ClassAccess access = Public, int64 n_flags = QCF_NO_FLAGS, int64 n_domain = QDOM_DEFAULT, unsigned num_params = 0, ...);
443 
445 
447  DLLEXPORT void addConstructor(const void* ptr, q_external_constructor_t meth, ClassAccess access = Public, int64 n_flags = QCF_NO_FLAGS, int64 n_domain = QDOM_DEFAULT, const type_vec_t& n_typeList = type_vec_t(), const arg_vec_t& defaultArgList = arg_vec_t(), const name_vec_t& n_names = name_vec_t());
448 
450 
454 
456 
467  DLLEXPORT void setCopy(q_copy_t m);
468 
470 
482  DLLEXPORT void setCopy(const void* ptr, q_external_copy_t m);
483 
485 
489  DLLEXPORT void setSerializer(q_serializer_t m);
490 
492 
497 
499 
501  DLLEXPORT q_serializer_t getSerializer() const;
502 
504 
507 
509  DLLEXPORT void setFinal();
510 
512 
516  DLLEXPORT bool isPrivateMember(const char* str) const;
517 
519 
524  DLLEXPORT bool isPublicOrPrivateMember(const char* str, bool& priv) const;
525 
527 
533  DLLEXPORT QoreObject* execConstructor(const QoreListNode* args, ExceptionSink* xsink) const;
534 
536 
549  DLLEXPORT QoreObject* execConstructor(const QoreClass& obj_cls, const QoreListNode* args, bool allow_abstract,
550  ExceptionSink* xsink) const;
551 
553 
561 
563 
567  DLLEXPORT QoreObject* execSystemConstructor(int code = 0, ...) const;
568 
570 
574  DLLEXPORT QoreObject* execCopy(QoreObject* old, ExceptionSink* xsink) const;
575 
577 
580  DLLEXPORT QoreListNode* getMethodList() const;
581 
583 
586  DLLEXPORT QoreListNode* getStaticMethodList() const;
587 
589 
598  DLLEXPORT const QoreClass* getClass(qore_classid_t cid) const;
599 
601 
610  DLLEXPORT const QoreClass* getClass(qore_classid_t cid, bool& priv) const;
611 
613 
622  DLLEXPORT const QoreClass* getClass(const QoreClass& qc, bool& priv) const;
623 
625  DLLEXPORT int numMethods() const;
626 
628  DLLEXPORT int numStaticMethods() const;
629 
631  DLLEXPORT int numUserMethods() const;
632 
634  DLLEXPORT int numStaticUserMethods() const;
635 
637  DLLEXPORT bool hasCopy() const;
638 
640  DLLEXPORT qore_classid_t getID() const;
641 
643  DLLEXPORT bool isSystem() const;
644 
646 
648  DLLEXPORT bool isModulePublic() const;
649 
651 
653  DLLEXPORT bool isAbstract() const;
654 
656 
658  DLLEXPORT bool isFinal() const;
659 
661 
663  DLLEXPORT bool isInjected() const;
664 
666 
668  DLLEXPORT bool isPseudoClass() const;
669 
671 
676 
678 
682  DLLEXPORT const QoreClass* getInjectedAsClass() const;
683 
685 
689  DLLEXPORT qore_type_t getPseudoClassType() const;
690 
692 
696  DLLEXPORT QoreValue evalPseudoMethod(const QoreValue n, const char* nme, const QoreListNode* args, ExceptionSink* xsink) const;
697 
699 
713  DLLEXPORT QoreValue evalPseudoMethod(const QoreMethod* m, const QoreExternalMethodVariant* variant, const QoreValue n, const QoreListNode* args, ExceptionSink* xsink) const;
714 
716  DLLEXPORT void setSystem();
717 
719  DLLEXPORT bool hasMemberGate() const;
720 
722  DLLEXPORT bool hasMethodGate() const;
723 
725  DLLEXPORT bool hasMemberNotification() const;
726 
728 
730  DLLEXPORT int64 getDomain() const;
731 
733  DLLEXPORT const char* getName() const;
734 
736 
740  DLLEXPORT const QoreMethod* findMethod(const char* nme) const;
741 
743 
747  DLLEXPORT const QoreMethod* findStaticMethod(const char* nme) const;
748 
750 
754  DLLEXPORT const QoreMethod* findMethod(const char* nme, ClassAccess& access) const;
755 
757 
761  DLLEXPORT const QoreMethod* findStaticMethod(const char* nme, ClassAccess& access) const;
762 
764 
768  DLLEXPORT const QoreMethod* findLocalMethod(const char* name) const;
769 
771 
775  DLLEXPORT const QoreMethod* findLocalStaticMethod(const char* name) const;
776 
778 
781  DLLEXPORT void addBuiltinBaseClass(QoreClass* qc);
782 
784 
789 
791 
798 
800 
805  DLLEXPORT void addBaseClass(QoreClass* qc, bool virt = false);
806 
808 
810  DLLEXPORT void setSynchronousClass();
811 
813 
816  DLLEXPORT const QoreMethod* getConstructor() const;
817 
819 
822  DLLEXPORT const QoreMethod* getSystemConstructor() const;
823 
825 
828  DLLEXPORT const QoreMethod* getDestructor() const;
829 
831 
834  DLLEXPORT const QoreMethod* getCopyMethod() const;
835 
837 
840  DLLEXPORT const QoreMethod* getMemberGateMethod() const;
841 
843 
846  DLLEXPORT const QoreMethod* getMethodGate() const;
847 
849 
852  DLLEXPORT const QoreMethod* getMemberNotificationMethod() const;
853 
855  DLLEXPORT const QoreTypeInfo* getTypeInfo() const;
856 
858  DLLEXPORT const QoreTypeInfo* getOrNothingTypeInfo() const;
859 
861  DLLEXPORT void addMember(const char* mem, ClassAccess access, const QoreTypeInfo* n_typeInfo, QoreValue initial_value = QoreValue());
862 
864 
866  DLLEXPORT void setUserData(const void* ptr);
867 
869 
871  DLLEXPORT const void* getUserData() const;
872 
874 
877 
879 
882 
884 
886  template <typename T>
887  DLLLOCAL T* getManagedUserData() const {
888  return static_cast<T*>(getManagedUserData());
889  }
890 
893 
895 
897  DLLEXPORT const QoreExternalMethodVariant* findUserMethodVariant(const char* name, const QoreMethod*& method, const type_vec_t& argTypeList) const;
898 
900 
905  DLLEXPORT void addBuiltinConstant(const char* name, QoreValue value, ClassAccess access = Public, const QoreTypeInfo* typeInfo = nullptr);
906 
908 
913  DLLEXPORT void addBuiltinStaticVar(const char* name, QoreValue value, ClassAccess access = Public, const QoreTypeInfo* typeInfo = nullptr);
914 
916 
922  DLLEXPORT void rescanParents();
923 
925 
927  DLLEXPORT void setPublicMemberFlag();
928 
930 
932  DLLEXPORT void setGateAccessFlag();
933 
935 
937  DLLEXPORT void setLanguage(const char* lang);
938 
940 
944  DLLEXPORT const char* getLanguage() const;
945 
947 
951  DLLEXPORT void setRelaxedAbstractMatch();
952 
954 
960  DLLEXPORT bool getRelaxedAbstractMatch() const;
961 
963 
965  DLLEXPORT const QoreExternalNormalMember* findLocalMember(const char* name) const;
966 
968 
970  DLLEXPORT const QoreExternalStaticMember* findLocalStaticMember(const char* name) const;
971 
973 
977  DLLEXPORT std::string getNamespacePath(bool anchored = false) const;
978 
980 
984  DLLEXPORT const char* getPath() const;
985 
987 
989  DLLEXPORT bool isEqual(const QoreClass& cls) const;
990 
992 
994  DLLEXPORT BinaryNode* getBinaryHash() const;
995 
997 
999  DLLEXPORT int runtimeCheckInstantiateClass(ExceptionSink* xsink) const;
1000 
1002 
1004  DLLEXPORT const QoreExternalConstant* findConstant(const char* name) const;
1005 
1007 
1009  DLLEXPORT const QoreNamespace* getNamespace() const;
1010 
1012 
1014  DLLEXPORT bool inHierarchy(const QoreClass& cls, ClassAccess& n_access) const;
1015 
1017 
1019  DLLEXPORT bool inHierarchyStrict(const QoreClass& cls, ClassAccess& n_access) const;
1020 
1022 
1024  DLLEXPORT bool hasTransientMember() const;
1025 
1027 
1029  DLLEXPORT const char* getModuleName() const;
1030 
1032 
1041  DLLEXPORT QoreValue setKeyValue(const std::string& key, QoreValue val);
1042 
1044 
1055  DLLEXPORT QoreValue setKeyValueIfNotSet(const std::string& key, QoreValue val);
1056 
1058 
1067  DLLEXPORT bool setKeyValueIfNotSet(const std::string& key, const char* str);
1068 
1070 
1078  DLLEXPORT QoreValue getReferencedKeyValue(const std::string& key) const;
1079 
1081 
1089  DLLEXPORT QoreValue getReferencedKeyValue(const char* key) const;
1090 
1092  DLLEXPORT bool hasParentClass() const;
1093 
1095  DLLEXPORT bool hasPublicMembersInHierarchy() const;
1096 
1097 protected:
1099  DLLEXPORT virtual ~QoreClass();
1100 
1102  DLLEXPORT QoreClass();
1103 
1104 private:
1105  QoreClass& operator=(const QoreClass&) = delete;
1106 
1108  class qore_class_private* priv;
1109 };
1110 
1113 private:
1114  void* priv;
1115 
1116 public:
1117  DLLEXPORT QoreMethodIterator(const QoreClass& qc);
1118  DLLEXPORT ~QoreMethodIterator();
1119  DLLEXPORT bool next();
1120  DLLEXPORT const QoreMethod* getMethod() const;
1121 };
1122 
1125 private:
1126  void* priv;
1127 
1128 public:
1129  DLLEXPORT QoreStaticMethodIterator(const QoreClass& qc);
1130  DLLEXPORT ~QoreStaticMethodIterator();
1131  DLLEXPORT bool next();
1132  DLLEXPORT const QoreMethod* getMethod() const;
1133 };
1134 
1136 
1139 public:
1141  DLLLOCAL QoreClassHolder(QoreClass* c) : c(c) {
1142  }
1143 
1145  DLLEXPORT ~QoreClassHolder();
1146 
1148  DLLLOCAL operator QoreClass*() const {
1149  return c;
1150  }
1151 
1153  DLLLOCAL QoreClass* release() {
1154  auto rv = c;
1155  c = 0;
1156  return rv;
1157  }
1158 
1159 private:
1161  QoreClass* c;
1162 };
1163 
1165 class QoreBuiltinClass : public QoreClass {
1166 public:
1168 
1173  DLLEXPORT QoreBuiltinClass(QoreProgram* pgm, const char* name, const char* path, int64 n_domain = QDOM_DEFAULT);
1174 
1176  DLLEXPORT QoreBuiltinClass(const char* name, const char* path, int64 n_domain = QDOM_DEFAULT);
1177 
1179  DLLEXPORT QoreBuiltinClass(const QoreBuiltinClass& old);
1180 
1181 protected:
1183  DLLEXPORT QoreBuiltinClass();
1184 };
1185 
1187 
1190 public:
1192  DLLEXPORT QoreParentClassIterator(const QoreClass& cls);
1193 
1196 
1198  DLLEXPORT bool next();
1199 
1201  DLLEXPORT bool valid() const;
1202 
1204  DLLEXPORT const QoreClass& getParentClass() const;
1205 
1207  DLLEXPORT ClassAccess getAccess() const;
1208 
1209 private:
1210  std::unique_ptr<class qore_parent_class_iterator_private> priv;
1211 };
1212 
1214 
1217 public:
1219  DLLEXPORT QoreClassMemberIterator(const QoreClass& cls);
1220 
1223 
1225  DLLEXPORT bool next();
1226 
1228  DLLEXPORT bool valid() const;
1229 
1231  DLLEXPORT const QoreExternalNormalMember& getMember() const;
1232 
1234  DLLEXPORT const char* getName() const;
1235 
1236 private:
1237  std::unique_ptr<class qore_class_member_iterator_private> priv;
1238 };
1239 
1241 
1244 public:
1247 
1250 
1252  DLLEXPORT bool next();
1253 
1255  DLLEXPORT bool valid() const;
1256 
1258  DLLEXPORT const QoreExternalStaticMember& getMember() const;
1259 
1261  DLLEXPORT const char* getName() const;
1262 
1263 private:
1264  std::unique_ptr<class qore_class_static_member_iterator_private> priv;
1265 };
1266 
1268 
1271 public:
1273  DLLEXPORT QoreClassConstantIterator(const QoreClass& cls);
1274 
1277 
1279  DLLEXPORT bool next();
1280 
1282  DLLEXPORT bool valid() const;
1283 
1285  DLLEXPORT const QoreExternalConstant& get() const;
1286 
1287 private:
1288  std::unique_ptr<class qore_class_constant_iterator> priv;
1289 };
1290 
1292 
1297 public:
1299  DLLEXPORT QoreClassHierarchyIterator(const QoreClass& cls);
1300 
1303 
1305  DLLEXPORT bool next();
1306 
1308  DLLEXPORT bool valid() const;
1309 
1311  DLLEXPORT const QoreClass& get() const;
1312 
1314 
1316  DLLEXPORT bool isVirtual() const;
1317 
1318 private:
1319  std::unique_ptr<class qore_class_hierarchy_iterator> priv;
1320 };
1321 
1323 
1328 public:
1331 
1334 
1336  DLLEXPORT bool next();
1337 
1339  DLLEXPORT bool valid() const;
1340 
1342  DLLEXPORT const QoreClass* get() const;
1343 
1345 
1347  DLLEXPORT bool isVirtual() const;
1348 
1349 private:
1350  class qore_class_destructor_hierarchy_iterator* priv;
1351 };
1352 
1353 DLLEXPORT const char* get_access_string(ClassAccess access);
1354 
1355 #endif // _QORE_QORECLASS_H
#define QDOM_DEFAULT
the default domain (no domain)
Definition: Restrictions.h:170
an abstract class for class-specific external user data
Definition: QoreClass.h:237
virtual AbstractQoreClassUserData * copy() const =0
for reference-counted classes, returns the same object with the reference count incremented
virtual void doDeref()=0
for non-reference counted classes, deletes the object immediately
holds arbitrary binary data
Definition: BinaryNode.h:41
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
creates a builtin class
Definition: QoreClass.h:1165
DLLEXPORT QoreBuiltinClass()
for use with QoreClass::copyImport()
iterates class constants
Definition: QoreClass.h:1270
DLLEXPORT bool next()
returns advances to the next element (or to the first element if starting to iterate) and returns tru...
DLLEXPORT bool valid() const
returns true if the iterator is pointing at a valid element
DLLEXPORT QoreClassConstantIterator(const QoreClass &cls)
creates the iterator; call next() to start iterating
DLLEXPORT const QoreExternalConstant & get() const
returns the
DLLEXPORT ~QoreClassConstantIterator()
destroys the object
iterates the class hierarchy in the order of destructor execution
Definition: QoreClass.h:1327
DLLEXPORT ~QoreClassDestructorHierarchyIterator()
destroys the object
DLLEXPORT bool next()
returns advances to the next element (or to the first element if starting to iterate) and returns tru...
DLLEXPORT bool isVirtual() const
returns true if the class has virtual inheritance, meaning that it is a builtin class without its own...
DLLEXPORT bool valid() const
returns true if the iterator is pointing at a valid element
DLLEXPORT const QoreClass * get() const
returns the parent class
DLLEXPORT QoreClassDestructorHierarchyIterator(const QoreClass *cls)
creates the iterator; call next() to start iterating
iterates the class hierarchy in the order of constructor execution
Definition: QoreClass.h:1296
DLLEXPORT QoreClassHierarchyIterator(const QoreClass &cls)
creates the iterator; call next() to start iterating
DLLEXPORT bool isVirtual() const
returns true if the class has virtual inheritance, meaning that it is a builtin class without its own...
DLLEXPORT bool valid() const
returns true if the iterator is pointing at a valid element
DLLEXPORT const QoreClass & get() const
returns the parent class
DLLEXPORT ~QoreClassHierarchyIterator()
destroys the object
DLLEXPORT bool next()
returns advances to the next element (or to the first element if starting to iterate) and returns tru...
allows for temporary storage of a QoreClass pointer
Definition: QoreClass.h:1138
DLLLOCAL QoreClassHolder(QoreClass *c)
creates the object
Definition: QoreClass.h:1141
DLLLOCAL QoreClass * release()
releases the QoreClass*
Definition: QoreClass.h:1153
DLLEXPORT ~QoreClassHolder()
deletes the QoreClass object if still managed
defines a Qore-language class
Definition: QoreClass.h:253
DLLEXPORT bool isPseudoClass() const
returns true if the class is a pseudo class
DLLEXPORT const QoreMethod * findStaticMethod(const char *nme) const
finds a static method in the class hierarchy
DLLEXPORT const QoreExternalStaticMember * findLocalStaticMember(const char *name) const
Finds the given local static member or returns nullptr.
DLLEXPORT const QoreMethod * getMethodGate() const
returns a const pointer to the QoreMethod object of the methodGate method, if any is set
DLLEXPORT QoreValue setKeyValueIfNotSet(const std::string &key, QoreValue val)
Sets a key value in the class's key-value store only if no value exists for the given key.
DLLEXPORT void setDestructor(q_destructor_t m)
sets the builtin destructor method for the class
virtual DLLEXPORT ~QoreClass()
Deletes the object and frees all memory.
DLLEXPORT const QoreNamespace * getNamespace() const
Returns the namespace that owns this class.
DLLEXPORT void setLanguage(const char *lang)
Sets the language for classes imported from another programming language.
DLLEXPORT bool hasTransientMember() const
Returns true if the class has at least one locally-declared transient member.
DLLEXPORT int64 getDomain() const
returns the functional domain of the class
DLLEXPORT void addBuiltinVirtualBaseClass(QoreClass *qc)
sets "virtual" base class for a class, meaning that the base class data is appropriate for use in the...
DLLEXPORT const QoreExternalNormalMember * findLocalMember(const char *name) const
Finds the given local member or returns nullptr.
DLLEXPORT void addBuiltinConstant(const char *name, QoreValue value, ClassAccess access=Public, const QoreTypeInfo *typeInfo=nullptr)
adds a class constant to the class
DLLEXPORT bool getRelaxedAbstractMatch() const
Returns the relaxed abstract matching flag.
DLLEXPORT bool inHierarchy(const QoreClass &cls, ClassAccess &n_access) const
Returns true if the class passed as an argument is present in the current class's hierachy,...
DLLEXPORT bool hasPublicMembersInHierarchy() const
returns true if the class has any publicly-declared members
DLLEXPORT void addAbstractMethod(const char *n_name, ClassAccess access=Public, int64 n_flags=QCF_NO_FLAGS, const QoreTypeInfo *returnTypeInfo=0, unsigned num_params=0,...)
adds an unimplemented abstract method variant to the class with extended information; with return and...
DLLEXPORT void setSerializer(q_serializer_t m)
sets the serializer method for builtin classes
DLLEXPORT bool isAbstract() const
returns true if the class has at least one unimplemented abstract method variant
DLLEXPORT bool isPublicOrPrivateMember(const char *str, bool &priv) const
returns true if the member is private or public
DLLEXPORT QoreListNode * getMethodList() const
returns a list strings of all non-static methods in the class, the caller owns the reference count re...
DLLEXPORT void setManagedUserData(AbstractQoreClassUserData *cud)
sets a pointer to user-specific data in the class
DLLEXPORT const QoreClass * getClass(qore_classid_t cid) const
returns a pointer to the QoreClass object representing the class ID passed if it exists in the class ...
DLLEXPORT bool isPrivateMember(const char *str) const
returns true if the member is private
DLLEXPORT QoreValue getReferencedKeyValue(const std::string &key) const
Returns a referenced key value from the class's key-value store.
DLLEXPORT QoreProgram * getProgram() const
Returns the owning QoreProgram object (if not the static system namespace)
virtual DLLEXPORT QoreClass * copy()
Called when a class is copied.
DLLEXPORT void addDefaultBuiltinBaseClass(QoreClass *qc)
make a builtin class a child of another builtin class and ensures that the given class's private data...
DLLEXPORT QoreClass()
For use with QoreClass::copyImport()
DLLEXPORT bool inHierarchyStrict(const QoreClass &cls, ClassAccess &n_access) const
Returns true if the class passed as an argument is present in the current class's hierachy,...
DLLEXPORT void setRelaxedAbstractMatch()
Sets relaxed abstract matching.
DLLEXPORT QoreObject * execSystemConstructor(int code=0,...) const
creates a new "system" object for use as the value of a constant, executes the system constructor on ...
DLLEXPORT bool isEqual(const QoreClass &cls) const
returns true if the classes are equal
DLLEXPORT int numUserMethods() const
returns the number of non-static user methods in this class
DLLEXPORT void setDeserializer(q_deserializer_t m)
sets the deserializer method for builtin classes
DLLEXPORT QoreObject * execCopy(QoreObject *old, ExceptionSink *xsink) const
executes a class's "copy" method on an object and returns the new object (or 0 in the case of an exce...
DLLEXPORT void setUserData(const void *ptr)
sets a pointer to user-specific data in the class
DLLEXPORT int runtimeCheckInstantiateClass(ExceptionSink *xsink) const
Throws a Qore-language exception if the class cannot be instantiated.
DLLEXPORT void rescanParents()
rescan builtin parent classes in a class hierarchy; to be used with out-of-order class hierarchy cons...
DLLEXPORT QoreListNode * getStaticMethodList() const
returns a list strings of all static methods in the class, the caller owns the reference count return...
DLLEXPORT void setFinal()
sets the final flag of the class
DLLEXPORT const QoreExternalConstant * findConstant(const char *name) const
Finds the given constant or returns nullptr if not found.
DLLEXPORT const QoreMethod * getConstructor() const
returns a const pointer to the QoreMethod object of the constuctor method, if any is set
DLLEXPORT void setSystem()
marks the class as a builtin class
DLLEXPORT void setGateAccessFlag()
sets the class's gate access flag so that memberGate() and methodGate() methods will be called with a...
DLLEXPORT int numStaticUserMethods() const
returns the number of static user methods in this class
DLLEXPORT const QoreMethod * getCopyMethod() const
returns a const pointer to the QoreMethod object of the destructor method, if any is set
DLLEXPORT const QoreMethod * findMethod(const char *nme) const
finds a normal (non-static) method in the class hierarchy
DLLEXPORT const QoreMethod * getMemberGateMethod() const
returns a const pointer to the QoreMethod object of the memberGate method, if any is set
DLLEXPORT const QoreMethod * findLocalMethod(const char *name) const
finds a normal (non-static) method in the class hierarchy
DLLEXPORT QoreObject * execConstructor(const QoreListNode *args, ExceptionSink *xsink) const
creates a new object and executes the constructor on it and returns the new object
DLLEXPORT QoreObject * execConstructorVariant(const QoreExternalMethodVariant *mv, const QoreListNode *args, ExceptionSink *xsink) const
creates a new object and executes the constructor on it and returns the new object
DLLEXPORT bool isModulePublic() const
returns true if the class has its module public flag set
DLLEXPORT QoreClass * getInjectedAsClass()
returns the class pointer for any injection target class if this class was injected,...
DLLEXPORT void addBuiltinStaticVar(const char *name, QoreValue value, ClassAccess access=Public, const QoreTypeInfo *typeInfo=nullptr)
adds a static variable to the class
DLLEXPORT void recheckBuiltinMethodHierarchy()
rechecks for inherited methods in base classes when adding builtin classes
DLLEXPORT qore_classid_t getID() const
returns the class ID of this class
DLLEXPORT bool hasMemberGate() const
returns true if the class implements a "memberGate" method
DLLEXPORT BinaryNode * getBinaryHash() const
returns a binary hash for the class's API
DLLEXPORT int numMethods() const
returns the number of non-static methods in this class (user and builtin)
DLLEXPORT const void * getUserData() const
retrieves the user-specific data pointer
DLLEXPORT void addMember(const char *mem, ClassAccess access, const QoreTypeInfo *n_typeInfo, QoreValue initial_value=QoreValue())
adds a member
DLLEXPORT qore_type_t getPseudoClassType() const
returns a pseudo-classes base type
DLLEXPORT bool hasCopy() const
returns true if the class implements a copy method
DLLEXPORT bool hasMethodGate() const
returns true if the class implements a "methodGate" method
DLLEXPORT const QoreTypeInfo * getTypeInfo() const
returns the type information structure for this class
DLLEXPORT q_deserializer_t getDeserializer() const
returns the deserializer method or nullptr if not present
DLLEXPORT void addBuiltinBaseClass(QoreClass *qc)
make a builtin class a child of another builtin class
DLLEXPORT void addBaseClass(QoreClass *qc, bool virt=false)
Adds a base class to the current class.
DLLEXPORT void setPublicMemberFlag()
sets the class's public member flag so that undeclared member references will fail
DLLEXPORT const char * getPath() const
Returns the root-justified namespace path of the class including the class name.
DLLEXPORT QoreValue setKeyValue(const std::string &key, QoreValue val)
Sets a key value in the class's key-value store unconditionally.
DLLEXPORT AbstractQoreClassUserData * getManagedUserData() const
retrieves the user-specific data pointer
DLLEXPORT bool isSystem() const
returns true if the class is a builtin class
virtual DLLEXPORT QoreClass * copyImport()
Called when a class is copied for import.
DLLEXPORT int numStaticMethods() const
returns the number of static methods in this class (user and builtin)
DLLEXPORT const QoreMethod * findLocalStaticMethod(const char *name) const
finds a static method in the class hierarchy
DLLEXPORT bool hasMemberNotification() const
returns true if the class implements a "memberNotification" method
DLLEXPORT void addMethod(const char *n_name, q_method_n_t meth, ClassAccess access=Public, int64 n_flags=QCF_NO_FLAGS, int64 n_domain=QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo=0, unsigned num_params=0,...)
adds a builtin method variant to a class
DLLEXPORT const QoreTypeInfo * getOrNothingTypeInfo() const
returns the "or nothing" type information structure for this class
DLLEXPORT const char * getModuleName() const
Returns the module name the class was loaded from or nullptr if it is a builtin class.
DLLEXPORT q_serializer_t getSerializer() const
returns the serializer method or nullptr if not present
DLLEXPORT QoreValue evalPseudoMethod(const QoreValue n, const char *nme, const QoreListNode *args, ExceptionSink *xsink) const
evaluates a pseudo-method on a pseudo-class
DLLEXPORT const char * getLanguage() const
Returns the language this class is written in.
DLLEXPORT bool isInjected() const
returns true if the class has been injected as a dependency injection
DLLEXPORT const char * getName() const
returns the class name
DLLEXPORT void setCopy(q_copy_t m)
sets the builtin copy method for the class
DLLEXPORT void addConstructor(q_constructor_n_t meth, ClassAccess access=Public, int64 n_flags=QCF_NO_FLAGS, int64 n_domain=QDOM_DEFAULT, unsigned num_params=0,...)
adds a constructor method variant with the access specifier, additional functional domain info,...
DLLEXPORT const QoreMethod * getSystemConstructor() const
returns a const pointer to the QoreMethod object of the constuctor method, if any is set
DLLEXPORT const QoreMethod * getMemberNotificationMethod() const
returns a const pointer to the QoreMethod object of the memberNotification method,...
DLLEXPORT std::string getNamespacePath(bool anchored=false) const
returns the full namespace path of the class
DLLEXPORT const QoreExternalMethodVariant * findUserMethodVariant(const char *name, const QoreMethod *&method, const type_vec_t &argTypeList) const
returns the user variant for the given non-static method and argument types
DLLEXPORT bool hasParentClass() const
returns true if the class has one or more parent classes
DLLEXPORT void setSystemConstructor(q_system_constructor_t m)
sets the builtin constructor for system objects (ex: used as constant values)
DLLEXPORT bool isFinal() const
returns true if the class is final
DLLEXPORT const QoreMethod * getDestructor() const
returns a const pointer to the QoreMethod object of the constructor method, if any is set
DLLEXPORT void setSynchronousClass()
call this function if your builtin class requires *all* methods (except the constructor) to be run in...
DLLEXPORT void addStaticMethod(const char *n_name, q_func_n_t meth, ClassAccess access=Public, int64 n_flags=QCF_NO_FLAGS, int64 n_domain=QDOM_DEFAULT, const QoreTypeInfo *returnTypeInfo=0, unsigned num_params=0,...)
adds a builtin static method with extended information; additional functional domain info,...
iterates normal (non-static) members of a class
Definition: QoreClass.h:1216
DLLEXPORT const QoreExternalNormalMember & getMember() const
returns the member
DLLEXPORT const char * getName() const
returns the member's name
DLLEXPORT ~QoreClassMemberIterator()
destroys the object
DLLEXPORT bool next()
returns advances to the next element (or to the first element if starting to iterate) and returns tru...
DLLEXPORT bool valid() const
returns true if the iterator is pointing at a valid element
DLLEXPORT QoreClassMemberIterator(const QoreClass &cls)
creates the iterator; call next() to start iterating
iterates static members of a class
Definition: QoreClass.h:1243
DLLEXPORT bool next()
returns advances to the next element (or to the first element if starting to iterate) and returns tru...
DLLEXPORT bool valid() const
returns true if the iterator is pointing at a valid element
DLLEXPORT const char * getName() const
returns the member's name
DLLEXPORT QoreClassStaticMemberIterator(const QoreClass &cls)
creates the iterator; call next() to start iterating
DLLEXPORT const QoreExternalStaticMember & getMember() const
returns the member
DLLEXPORT ~QoreClassStaticMemberIterator()
destroys the object
external wrapper class for constants
Definition: QoreReflection.h:200
external wrapper base class for class members
Definition: QoreReflection.h:137
external wrapper class for method variants
Definition: QoreReflection.h:90
external wrapper base class for class normal members
Definition: QoreReflection.h:174
external wrapper class for source code location information
Definition: QoreReflection.h:187
external wrapper base class for class static members
Definition: QoreReflection.h:153
external wrapper class for function and call variants
Definition: QoreReflection.h:38
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:139
DLLEXPORT QoreValue execManaged(QoreObject *self, const QoreListNode *args, ExceptionSink *xsink) const
evaluates the method and returns the value, does not reference the object for the call
DLLEXPORT bool isBuiltin() const
returns true if all variants of the method are builtin variants
DLLEXPORT bool existsVariant(const type_vec_t &paramTypeInfo) const
returns true if a variant with the given parameter signature already exists in the method
DLLEXPORT bool isStatic() const
returns true if the method is static
DLLEXPORT const QoreExternalMethodFunction * getFunction() const
returns the function for the method
DLLEXPORT bool isUser() const
returns true if all variants of the method are user variants
DLLEXPORT ClassAccess getAccess() const
returns the lowest access code of all variants in the method
DLLEXPORT const std::string & getNameStr() const
returns the method's name
DLLEXPORT bool isPrivate() const
returns true if all overloaded variants of a methods are private or class internal,...
DLLEXPORT const char * getClassName() const
returns the class name for the method
DLLEXPORT const char * getName() const
returns the method's name
DLLEXPORT method_type_e getMethodType() const
returns the type of method
DLLEXPORT const QoreClass * getClass() const
returns a pointer to the parent class
To be used to iterate through a class's normal (non-static) methods.
Definition: QoreClass.h:1112
contains constants, classes, and subnamespaces in QoreProgram objects
Definition: QoreNamespace.h:65
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:60
iterates parent classes for a class with inheritance access information
Definition: QoreClass.h:1189
DLLEXPORT const QoreClass & getParentClass() const
returns the parent class
DLLEXPORT ~QoreParentClassIterator()
destroys the object
DLLEXPORT bool valid() const
returns true if the iterator is pointing at a valid element
DLLEXPORT bool next()
returns advances to the next element (or to the first element if starting to iterate) and returns tru...
DLLEXPORT QoreParentClassIterator(const QoreClass &cls)
creates the iterator; call next() to start iterating
DLLEXPORT ClassAccess getAccess() const
returns the access of the parent class
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:128
To be used to iterate through a class's static methods.
Definition: QoreClass.h:1124
QoreValue(* q_external_method_t)(const QoreMethod &method, const void *ptr, QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, q_rt_flags_t flags, ExceptionSink *xsink)
the type used for builtin QoreClass method signatures
Definition: common.h:345
QoreHashNode *(* q_serializer_t)(const QoreObject &self, const AbstractPrivateData &data, QoreSerializationContext &context, ExceptionSink *xsink)
the type used for builtin QoreClass serializer method signatures
Definition: common.h:438
void(* q_external_destructor_t)(const QoreClass &thisclass, const void *ptr, QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink)
the type used for builtin QoreClass destructor signatures with the new generic calling convention and...
Definition: common.h:408
int16_t qore_type_t
used to identify unique Qore data and parse types (descendents of AbstractQoreNode)
Definition: common.h:70
QoreValue(* q_external_static_method_t)(const QoreMethod &method, const void *ptr, const QoreListNode *args, q_rt_flags_t flags, ExceptionSink *xsink)
the type used for external static methods
Definition: common.h:358
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:307
void(* q_copy_t)(QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink)
the type used for builtin QoreClass copy signatures
Definition: common.h:417
void(* q_system_constructor_t)(QoreObject *self, int code, va_list args)
the type used for builtin QoreClass system constructor method signatures
Definition: common.h:390
QoreValue(* q_method_n_t)(QoreObject *self, AbstractPrivateData *private_data, const QoreListNode *args, q_rt_flags_t flags, ExceptionSink *xsink)
the type used for builtin QoreClass method signatures
Definition: common.h:330
void(* q_external_constructor_t)(const QoreMethod &method, const void *ptr, QoreObject *self, const QoreListNode *args, q_rt_flags_t rtflags, ExceptionSink *xsink)
the type used for builtin QoreClass constructor method signatures
Definition: common.h:378
std::vector< const QoreTypeInfo * > type_vec_t
vector of type information for parameter lists
Definition: common.h:251
void(* q_destructor_t)(QoreObject *self, AbstractPrivateData *private_data, ExceptionSink *xsink)
the type used for builtin QoreClass destructor signatures
Definition: common.h:398
void(* q_external_copy_t)(const QoreClass &thisclass, const void *ptr, QoreObject *self, QoreObject *old, AbstractPrivateData *private_data, ExceptionSink *xsink)
the type used for builtin QoreClass copy signatures with the new generic calling convention
Definition: common.h:428
unsigned qore_classid_t
used for the unique class ID for QoreClass objects
Definition: common.h:79
std::vector< std::string > name_vec_t
vector of parameter names for parameter lists
Definition: common.h:257
void(* q_deserializer_t)(QoreObject &self, const QoreHashNode *sdata, QoreDeserializationContext &context, ExceptionSink *xsink)
the type used for builtin QoreClass deserializer method signatures
Definition: common.h:450
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
void(* q_constructor_n_t)(QoreObject *self, const QoreListNode *args, q_rt_flags_t rtflags, ExceptionSink *xsink)
the type used for builtin QoreClass constructor method signatures
Definition: common.h:366
std::vector< QoreValue > arg_vec_t
vector of value information for default argument lists
Definition: common.h:254
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:276