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;
48 : QoreBinaryOperatorNode<>(loc, l, r), returnTypeInfo(nullptr), iterator_func(nullptr) {
55 DLLLOCAL
virtual const char* getTypeName()
const {
56 return map_str.getBuffer();
59 DLLLOCAL
virtual QoreOperatorNode* copyBackground(
ExceptionSink *xsink)
const {
60 QoreMapOperatorNode* rv = copyBackgroundExplicit<QoreMapOperatorNode>(xsink);
61 rv->iterator_func =
dynamic_cast<FunctionalOperator*
>(rv->right.getInternalNode());
65 DLLLOCAL
static const QoreTypeInfo* setReturnTypeInfo(
const QoreTypeInfo*& returnTypeInfo,
66 const QoreTypeInfo* expTypeInfo,
const QoreTypeInfo* iteratorTypeInfo);
68 DLLLOCAL
virtual bool hasEffectAsRoot()
const {
73 const QoreTypeInfo* returnTypeInfo;
74 const QoreTypeInfo* expTypeInfo =
nullptr;
75 FunctionalOperator* iterator_func;
83 DLLLOCAL
virtual ~QoreMapOperatorNode() {
86 DLLLOCAL
virtual int parseInitImpl(
QoreValue& val, QoreParseContext& parse_context);
88 DLLLOCAL
virtual const QoreTypeInfo* getTypeInfo()
const {
89 return returnTypeInfo;
94 DLLLOCAL
virtual FunctionalOperatorInterface* getFunctionalIteratorImpl(FunctionalValueType& value_type,
98 class QoreFunctionalMapListOperator :
public FunctionalOperatorInterface,
public ConstListIterator {
104 DLLLOCAL
virtual ~QoreFunctionalMapListOperator() {
108 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
110 return map->expTypeInfo;
116 const QoreMapOperatorNode* map;
120 class QoreFunctionalMapSingleValueOperator :
public FunctionalOperatorInterface {
122 DLLLOCAL QoreFunctionalMapSingleValueOperator(
const QoreMapOperatorNode* m,
QoreValue n,
ExceptionSink* xs)
123 : map(m), v(n), xsink(xs) {
126 DLLLOCAL
virtual ~QoreFunctionalMapSingleValueOperator() {
132 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
133 return v.getTypeInfo();
137 const QoreMapOperatorNode* map;
143 class QoreFunctionalMapIteratorOperator :
public FunctionalOperatorInterface {
145 DLLLOCAL QoreFunctionalMapIteratorOperator(
const QoreMapOperatorNode* m,
bool t, AbstractIteratorHelper n_h,
149 DLLLOCAL ~QoreFunctionalMapIteratorOperator() {
156 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
161 const QoreMapOperatorNode* map;
163 AbstractIteratorHelper h;
168 class QoreFunctionalMapOperator :
public FunctionalOperatorInterface {
170 DLLLOCAL QoreFunctionalMapOperator(
const QoreMapOperatorNode* m, FunctionalOperatorInterface* n_f) : map(m), f(n_f) {
173 DLLLOCAL ~QoreFunctionalMapOperator() {
177 DLLLOCAL
virtual const QoreTypeInfo* getValueTypeImpl()
const {
178 return map->expTypeInfo;
184 const QoreMapOperatorNode* map;
185 FunctionalOperatorInterface* f;
For use on the stack only: iterates through elements of a const QoreListNode.
Definition: QoreListNode.h:563
DLLLOCAL const QoreListNode * getList() const
returns the list
Definition: QoreListNode.h:627
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
This is the list container type in Qore, dynamically allocated only, reference counted.
Definition: QoreListNode.h:52
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
allows storing a value and setting a boolean flag that indicates if the value should be dereference i...
Definition: QoreValue.h:509
The main value class in Qore, designed to be passed by value.
Definition: QoreValue.h:275