32 #ifndef _QORE_QOREMAPOPERATORNODE_H
34 #define _QORE_QOREMAPOPERATORNODE_H
36 #include "qore/intern/AbstractIteratorHelper.h"
37 #include "qore/intern/FunctionalOperator.h"
38 #include "qore/intern/FunctionalOperatorInterface.h"
40 class QoreMapOperatorNode :
public QoreBinaryOperatorNode<>,
public FunctionalOperator {
41 friend class QoreFunctionalMapListOperator;
42 friend class QoreFunctionalMapSingleValueOperator;
43 friend class QoreFunctionalMapIteratorOperator;
44 friend class QoreFunctionalMapOperator;
47 DLLLOCAL QoreMapOperatorNode(
const QoreProgramLocation* loc,
QoreValue l,
QoreValue r) : QoreBinaryOperatorNode<>(loc, l, r), returnTypeInfo(nullptr), iterator_func(nullptr) {
54 DLLLOCAL
virtual const char* getTypeName()
const {
55 return map_str.getBuffer();
58 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
59 QoreMapOperatorNode* rv = copyBackgroundExplicit<QoreMapOperatorNode>(xsink);
60 rv->iterator_func =
dynamic_cast<FunctionalOperator*
>(rv->right.getInternalNode());
64 DLLLOCAL
static const QoreTypeInfo* setReturnTypeInfo(
const QoreTypeInfo*& returnTypeInfo,
const QoreTypeInfo* expTypeInfo,
const QoreTypeInfo* iteratorTypeInfo);
66 DLLLOCAL
virtual bool hasEffectAsRoot()
const {
71 const QoreTypeInfo* returnTypeInfo;
72 const QoreTypeInfo* expTypeInfo =
nullptr;
73 FunctionalOperator* iterator_func;
81 DLLLOCAL
virtual ~QoreMapOperatorNode() {
84 DLLLOCAL
virtual void parseInitImpl(
QoreValue& val, LocalVar* oflag,
int pflag,
int& lvids,
const QoreTypeInfo*& typeInfo);
86 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
87 return returnTypeInfo;
92 DLLLOCAL
virtual FunctionalOperatorInterface* getFunctionalIteratorImpl(FunctionalValueType& value_type,
ExceptionSink* xsink)
const;
95 class QoreFunctionalMapListOperator :
public FunctionalOperatorInterface,
public ConstListIterator {
100 DLLLOCAL
virtual ~QoreFunctionalMapListOperator() {
104 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
106 return map->expTypeInfo;
112 const QoreMapOperatorNode* map;
116 class QoreFunctionalMapSingleValueOperator :
public FunctionalOperatorInterface {
118 DLLLOCAL QoreFunctionalMapSingleValueOperator(
const QoreMapOperatorNode* m,
QoreValue n,
ExceptionSink* xs) : map(m), v(n), xsink(xs) {
121 DLLLOCAL
virtual ~QoreFunctionalMapSingleValueOperator() {
127 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
128 return v.getTypeInfo();
132 const QoreMapOperatorNode* map;
138 class QoreFunctionalMapIteratorOperator :
public FunctionalOperatorInterface {
140 DLLLOCAL QoreFunctionalMapIteratorOperator(
const QoreMapOperatorNode* m,
bool t, AbstractIteratorHelper n_h,
144 DLLLOCAL ~QoreFunctionalMapIteratorOperator() {
151 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
156 const QoreMapOperatorNode* map;
158 AbstractIteratorHelper h;
163 class QoreFunctionalMapOperator :
public FunctionalOperatorInterface {
165 DLLLOCAL QoreFunctionalMapOperator(
const QoreMapOperatorNode* m, FunctionalOperatorInterface* n_f) : map(m), f(n_f) {
168 DLLLOCAL ~QoreFunctionalMapOperator() {
172 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
173 return map->expTypeInfo;
179 const QoreMapOperatorNode* map;
180 FunctionalOperatorInterface* f;