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,
ExceptionSink* xs) : map(m), temp(t), h(n_h), xsink(xs) {
143 DLLLOCAL ~QoreFunctionalMapIteratorOperator() {
150 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
155 const QoreMapOperatorNode* map;
157 AbstractIteratorHelper h;
162 class QoreFunctionalMapOperator :
public FunctionalOperatorInterface {
164 DLLLOCAL QoreFunctionalMapOperator(
const QoreMapOperatorNode* m, FunctionalOperatorInterface* n_f) : map(m), f(n_f) {
167 DLLLOCAL ~QoreFunctionalMapOperator() {
171 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
172 return f->getValueType();
178 const QoreMapOperatorNode* map;
179 FunctionalOperatorInterface* f;
allows storing a value and setting a boolean flag that indicates if the value should be dereference i...
Definition: QoreValue.h:485
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
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:262
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:46
For use on the stack only: iterates through elements of a const QoreListNode.
Definition: QoreListNode.h:566