32 #ifndef _QORE_ABSTRACTITERATORHELPER_H
34 #define _QORE_ABSTRACTITERATORHELPER_H
36 #include "qore/intern/QoreClassIntern.h"
38 class AbstractIteratorHelper {
47 DLLLOCAL AbstractIteratorHelper(
ExceptionSink* xsink,
const char* op,
QoreObject* o,
bool fwd =
true,
bool get_value =
true) {
53 const qore_class_private* class_ctx = runtime_get_class();
54 if (class_ctx && !qore_class_private::runtimeCheckPrivateClassAccess(*o->
getClass(), class_ctx))
59 nextMethod = qore_class_private::get(*o->
getClass())->runtimeFindCommittedMethod(fwd ?
"next" :
"prev", access, class_ctx);
62 nextVariant = getCheckVariant(xsink, op, nextMethod);
66 getValueMethod = qore_class_private::get(*o->
getClass())->runtimeFindCommittedMethod(
"getValue", access, class_ctx);
68 assert(getValueMethod);
69 getValueVariant = getCheckVariant(xsink, op, getValueMethod);
76 DLLLOCAL
operator bool()
const {
83 ValueHolder rv(qore_method_private::evalNormalVariant(*nextMethod, xsink, obj, nextVariant, 0), xsink);
84 return rv->getAsBool();
88 assert(getValueMethod);
89 assert(getValueVariant);
90 return qore_method_private::evalNormalVariant(*getValueMethod, xsink, obj, getValueVariant, 0);
95 const qore_class_private* class_ctx = runtime_get_class();
96 const MethodVariantBase* variant =
reinterpret_cast<const MethodVariantBase*
>(
97 qore_method_private::get(*m)->getFunction()->runtimeFindVariant(xsink, (
QoreListNode*)
nullptr,
false, class_ctx)
105 if (variant->isPrivate()) {
107 if (!qore_class_private::runtimeCheckPrivateClassAccess(*(variant->method()->getClass()), class_ctx)) {
110 opstr.concat(
"-ITERATOR-ERROR");
111 xsink->
raiseException(opstr.getBuffer(),
"cannot access private %s::%s() iterator method with the %s",
112 variant->method()->getClass()->getName(), m->
getName(), op);