]> git.donarmstrong.com Git - lilypond.git/blob - flower/pcursor.hh
release: 0.0.15
[lilypond.git] / flower / pcursor.hh
1
2 /*
3   pcursor.hh -- part of flowerlib
4
5   (c) 1996 Han-Wen Nienhuys&Jan Nieuwenhuizen
6 */
7
8 #ifndef PCURSOR_HH
9 #define PCURSOR_HH
10
11
12 /// cursor to go with PointerList
13 template<class T>
14 struct PCursor : private Cursor<void *> {
15     friend class IPointerList<T>;
16 public:
17     Cursor<void*>::ok;
18     Cursor<void*>::del;
19     Cursor<void*>::backspace;
20     
21     PointerList<T> &list() { return (PointerList<T>&)Cursor<void*>::list(); }
22     PCursor<T> operator++(int) { return Cursor<void*>::operator++(0);}
23     PCursor<T> operator--(int) { return Cursor<void*>::operator--(0); }
24     PCursor<T> operator+=(int i) { return Cursor<void*>::operator+=(i);}
25     PCursor<T> operator-=(int i) { return Cursor<void*>::operator-=(i); }    
26     PCursor<T> operator -(int no) const { return Cursor<void*>::operator-(no);}
27     int operator -(PCursor<T> op) const { return Cursor<void*>::operator-(op);}
28     PCursor<T> operator +( int no) const {return Cursor<void*>::operator+(no);}    PCursor(const PointerList<T> & l) : Cursor<void*> (l) {}
29
30     PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { }
31     void* vptr() const { return  * ((Cursor<void*> &) *this); }
32
33     // should return T& ?
34     T ptr() const { return (T) vptr(); }
35     T operator ->() const { return  ptr(); }
36     operator T() { return ptr(); }
37     T operator *() { return ptr(); }
38     void add(const T& p ) { Cursor<void*>::add((void*) p); }
39     void insert(const T& p ) { Cursor<void*>::insert((void*) p);}    
40     static int compare(PCursor<T> a,PCursor<T>b) {
41         return Cursor<void*>::compare(a,b);
42     }
43 };
44 /**
45   don't create PointerList<void*>'s.
46   This cursor is just an interface class for Cursor. It takes care of the
47   appropriate type casts
48  */
49
50
51
52 #include "compare.hh"
53 template_instantiate_compare(PCursor<T>, PCursor<T>::compare, template<class T>);
54
55 #endif