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