baseiterator.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * $Id$
4  *
5  *
6  * Copyright (C) 1997-2015 by Dimitri van Heesch.
7  *
8  * Permission to use, copy, modify, and distribute this software and its
9  * documentation under the terms of the GNU General Public License is hereby
10  * granted. No representations are made about the suitability of this software
11  * for any purpose. It is provided "as is" without express or implied warranty.
12  * See the GNU General Public License for more details.
13  *
14  */
15 #ifndef BASEITERATOR_H
16 #define BASEITERATOR_H
17 
18 #include <qlist.h>
19 #include <doxmlintf.h>
20 
21 template<class Intf,class ElemIntf,class ElemImpl> class BaseIterator :
22  public Intf, public QListIterator<ElemImpl>
23 {
24  public:
25  BaseIterator(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {}
26  virtual ~BaseIterator() {}
27  virtual ElemIntf *toFirst() { return QListIterator<ElemImpl>::toFirst(); }
28  virtual ElemIntf *toLast() { return QListIterator<ElemImpl>::toLast(); }
29  virtual ElemIntf *toNext() { return QListIterator<ElemImpl>::operator++(); }
30  virtual ElemIntf *toPrev() { return QListIterator<ElemImpl>::operator--(); }
31  virtual ElemIntf *current() const { return QListIterator<ElemImpl>::current(); }
32  virtual void release() { delete this; }
33 };
34 
35 template<class Intf,class ElemIntf,class ElemImpl,class Intermediate>
36  class BaseIteratorVia :
37  public Intf, public QListIterator<ElemImpl>
38 {
39  public:
40  BaseIteratorVia(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {}
41  virtual ~BaseIteratorVia() {}
42  virtual ElemIntf *toFirst() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toFirst()); }
43  virtual ElemIntf *toLast() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toLast()); }
44  virtual ElemIntf *toNext() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator++()); }
45  virtual ElemIntf *toPrev() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator--()); }
46  virtual ElemIntf *current() const { return static_cast<Intermediate *>(QListIterator<ElemImpl>::current()); }
47  virtual void release() { delete this; }
48 };
49 
50 #endif
virtual ElemIntf * toPrev()
Definition: baseiterator.h:45
virtual ElemIntf * toPrev()
Definition: baseiterator.h:30
QGList * list
Definition: qglist.h:234
type * operator++()
Definition: qlist.h:148
BaseIteratorVia(const QList< ElemImpl > &list)
Definition: baseiterator.h:40
virtual ElemIntf * toNext()
Definition: baseiterator.h:29
virtual ElemIntf * toLast()
Definition: baseiterator.h:43
virtual ElemIntf * toLast()
Definition: baseiterator.h:28
virtual ElemIntf * current() const
Definition: baseiterator.h:46
virtual ElemIntf * toFirst()
Definition: baseiterator.h:42
BaseIterator(const QList< ElemImpl > &list)
Definition: baseiterator.h:25
virtual ~BaseIterator()
Definition: baseiterator.h:26
type * current() const
Definition: qlist.h:146
virtual void release()
Definition: baseiterator.h:32
virtual ElemIntf * toNext()
Definition: baseiterator.h:44
virtual ~BaseIteratorVia()
Definition: baseiterator.h:41
virtual void release()
Definition: baseiterator.h:47
virtual ElemIntf * current() const
Definition: baseiterator.h:31
type * operator--()
Definition: qlist.h:150
type * toLast()
Definition: qlist.h:136
virtual ElemIntf * toFirst()
Definition: baseiterator.h:27
The interface to the object model provided by the XML parser library.
Definition: qlist.h:54
type * toFirst()
Definition: qlist.h:135