summaryrefslogtreecommitdiffstats
path: root/addon/doxmlparser/src/baseiterator.h
blob: 06a9a116543e0536f7e62fe2df98be5f45b5e633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/******************************************************************************
 *
 * $Id$
 *
 *
 * Copyright (C) 1997-2005 by Dimitri van Heesch.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation under the terms of the GNU General Public License is hereby 
 * granted. No representations are made about the suitability of this software 
 * for any purpose. It is provided "as is" without express or implied warranty.
 * See the GNU General Public License for more details.
 *
 */
#ifndef BASEITERATOR_H
#define BASEITERATOR_H

#include <qlist.h>
#include <doxmlintf.h>

template<class Intf,class ElemIntf,class ElemImpl> class BaseIterator : 
        public Intf, public QListIterator<ElemImpl>
{
  public:
    BaseIterator(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {}
    virtual ~BaseIterator() {}
    virtual ElemIntf *toFirst() { return QListIterator<ElemImpl>::toFirst(); }
    virtual ElemIntf *toLast()  { return QListIterator<ElemImpl>::toLast(); }
    virtual ElemIntf *toNext()  { return QListIterator<ElemImpl>::operator++(); }
    virtual ElemIntf *toPrev()  { return QListIterator<ElemImpl>::operator--(); }
    virtual ElemIntf *current() const { return QListIterator<ElemImpl>::current(); }
    virtual void release() { delete this; }
};

template<class Intf,class ElemIntf,class ElemImpl,class Intermediate> 
        class BaseIteratorVia : 
        public Intf, public QListIterator<ElemImpl>
{
  public:
    BaseIteratorVia(const QList<ElemImpl> &list) : QListIterator<ElemImpl>(list) {}
    virtual ~BaseIteratorVia() {}
    virtual ElemIntf *toFirst() { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toFirst()); }
    virtual ElemIntf *toLast()  { return static_cast<Intermediate *>(QListIterator<ElemImpl>::toLast()); }
    virtual ElemIntf *toNext()  { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator++()); }
    virtual ElemIntf *toPrev()  { return static_cast<Intermediate *>(QListIterator<ElemImpl>::operator--()); }
    virtual ElemIntf *current() const { return static_cast<Intermediate *>(QListIterator<ElemImpl>::current()); }
    virtual void release() { delete this; }
};

#endif