32 #ifndef _QORE_ABSTRACTITERATORHELPER_H 34 #define _QORE_ABSTRACTITERATORHELPER_H 36 #include "qore/intern/QoreClassIntern.h" 38 class AbstractIteratorHelper {
41 const qore_class_private* class_ctx = runtime_get_class();
42 const MethodVariantBase* variant =
reinterpret_cast<const MethodVariantBase*
>(qore_method_private::get(*m)->getFunction()->runtimeFindVariant(xsink, (
QoreListNode*)0,
false, class_ctx));
49 if (variant->isPrivate()) {
51 if (!qore_class_private::runtimeCheckPrivateClassAccess(*(variant->method()->getClass()), class_ctx)) {
54 opstr.concat(
"-ITERATOR-ERROR");
55 xsink->
raiseException(opstr.getBuffer(),
"cannot access private %s::next() iterator method with the %s", variant->method()->getClass()->getName(), op);
70 DLLLOCAL AbstractIteratorHelper(
ExceptionSink* xsink,
const char* op,
QoreObject* o,
bool fwd =
true,
bool get_value =
true) : obj(0), nextMethod(0), nextVariant(0), getValueMethod(0), getValueVariant(0), valid(false) {
76 const qore_class_private* class_ctx = runtime_get_class();
77 if (class_ctx && !qore_class_private::runtimeCheckPrivateClassAccess(*o->
getClass(), class_ctx))
82 nextMethod = qore_class_private::get(*o->
getClass())->runtimeFindCommittedMethod(fwd ?
"next" :
"prev", access, class_ctx);
85 nextVariant = getCheckVariant(op, nextMethod, xsink);
89 getValueMethod = qore_class_private::get(*o->
getClass())->runtimeFindCommittedMethod(
"getValue", access, class_ctx);
91 assert(getValueMethod);
92 getValueVariant = getCheckVariant(op, getValueMethod, xsink);
99 DLLLOCAL
operator bool()
const {
106 ValueHolder rv(qore_method_private::evalNormalVariant(*nextMethod, xsink, obj, nextVariant, 0), xsink);
107 return rv->getAsBool();
111 assert(getValueMethod);
112 assert(getValueVariant);
113 return qore_method_private::evalNormalVariant(*getValueMethod, xsink, obj, getValueVariant, 0);
DLLEXPORT 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 AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
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 ...
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:81
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
defines a Qore-language class
Definition: QoreClass.h:239
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
the implementation of Qore's object data type, reference counted, dynamically-allocated only ...
Definition: QoreObject.h:61
external wrapper class for method variants
Definition: QoreReflection.h:90
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
a method in a QoreClass
Definition: QoreClass.h:125
holds an object and dereferences it in the destructor
Definition: QoreValue.h:452