Qore Programming Language 1.19.2
Loading...
Searching...
No Matches
QoreObjectIterator.h
1/* -*- mode: c++; indent-tabs-mode: nil -*- */
2/*
3 QoreHashIterator.h
4
5 Qore Programming Language
6
7 Copyright (C) 2003 - 2023 Qore Technologies, s.r.o.
8
9 Permission is hereby granted, free of charge, to any person obtaining a
10 copy of this software and associated documentation files (the "Software"),
11 to deal in the Software without restriction, including without limitation
12 the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 DEALINGS IN THE SOFTWARE.
26
27 Note that the Qore library is released under a choice of three open-source
28 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
29 information.
30*/
31
32#ifndef _QORE_QOREOBJECTITERATOR_H
33
34#define _QORE_QOREOBJECTITERATOR_H
35
36#include "qore/intern/QoreHashIterator.h"
37#include "qore/intern/QoreObjectIntern.h"
38
39extern QoreClass* QC_OBJECTITERATOR;
40extern QoreClass* QC_OBJECTKEYITERATOR;
41extern QoreClass* QC_OBJECTPAIRITERATOR;
42extern QoreClass* QC_OBJECTREVERSEITERATOR;
43
44// the c++ object
45class QoreObjectIterator : public QoreHashIterator {
46public:
47 DLLLOCAL QoreObjectIterator(const QoreObject* o) : QoreHashIterator(qore_object_private::get(*o)->getRuntimeMemberHash(0)) {
48 }
49
50 DLLLOCAL QoreObjectIterator() {
51 }
52
53 DLLLOCAL QoreObjectIterator(const QoreObjectIterator& old) : QoreHashIterator(old) {
54 }
55
56 DLLLOCAL virtual const char* getName() const { return "ObjectIterator"; }
57};
58
59// internal reverse iterator class implementation only for the getName() function - the iterators remain
60// forwards and are used in the reverse sense by the Qore language class implementation below
61class QoreObjectReverseIterator : public QoreObjectIterator {
62public:
63 DLLLOCAL QoreObjectReverseIterator(const QoreObject* o) : QoreObjectIterator(o) {
64 }
65
66 DLLLOCAL QoreObjectReverseIterator() {
67 }
68
69 DLLLOCAL QoreObjectReverseIterator(const QoreObjectReverseIterator& old) : QoreObjectIterator(old) {
70 }
71
72 DLLLOCAL virtual const char* getName() const {
73 return "ObjectReverseIterator";
74 }
75};
76
77#endif // _QORE_QOREOBJECTITERATOR_H
DLLEXPORT const QoreValue get() const
returns the value of the current key
defines a Qore-language class
Definition: QoreClass.h:253
the implementation of Qore's object data type, reference counted, dynamically-allocated only
Definition: QoreObject.h:60