]> git.donarmstrong.com Git - lilypond.git/blob - flower/pcursor.hh
release: 0.0.9
[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 : public Cursor<void *> {
15
16     /// make cursor with #no# items back
17     PCursor<T> operator -( int no) const {
18         return PCursor<T> (Cursor<void*>::operator-(no));
19     }
20     int operator -(PCursor<T> op) const {
21         return Cursor<void*>::operator-(op);
22     }
23     /// make cursor with #no# items further
24     PCursor<T> operator +( int no) const {
25         return PCursor<T> (Cursor<void*>::operator+(no));
26     }
27     
28     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
41 private:
42 //    Cursor<void*>::operator void*;
43     // sigh
44 };
45 /**
46   don't create PointerList<void*>'s.
47   This cursor is just an interface class for Cursor. It takes care of the
48   appropriate type casts
49  */
50
51
52 template<class T>
53 inline  int pcursor_compare(PCursor<T> a,PCursor<T>b)
54 {
55     return cursor_compare(Cursor<void*>(a),Cursor<void*> (b));
56 }
57
58 #include "compare.hh"
59 template_instantiate_compare(PCursor<T>, pcursor_compare, template<class T>);
60
61 #endif