]> git.lyx.org Git - lyx.git/blob - src/mathed/math_iterator.h
perhaps a fix for the latest crashes
[lyx.git] / src / mathed / math_iterator.h
1 #ifndef MATH_ITERATOR_H
2 #define MATH_ITERATOR_H
3
4 #include "math_cursor.h"
5
6 // this helper struct is used for traversing math insets
7
8 class MathIterator {
9 public:
10         /// default constructor, used for end of range
11         //MathIterator();
12         /// start with given formula
13         explicit MathIterator(MathAtom & t);
14         /// start with given position
15         explicit MathIterator(MathCursor::cursor_type const & cursor);
16         ///
17         MathCursorPos const & operator*() const;
18         ///
19         MathCursorPos const & operator->() const;
20         ///
21         void operator++();
22         /// read access to top most item
23         MathCursorPos const & position() const;
24         /// write access to top most item
25         MathCursorPos & position();
26         /// read access to full path
27         MathCursor::cursor_type const & cursor() const;
28         /// read access to top most inset
29         MathAtom const & par() const;
30         /// read access to top most inset
31         MathAtom & par();
32         /// helper for iend
33         void goEnd();
34         
35 private:
36         /// write access to top most item
37         MathXArray const & xcell() const;
38         /// write access to top most item
39         MathAtom * nextInset() const;
40         /// own level down
41         void push(MathAtom &);
42         /// own level up
43         void pop();
44
45         /// current position
46         MathCursor::cursor_type cursor_;
47 };
48
49 ///
50 bool operator==(MathIterator const &, MathIterator const &);
51 ///
52 bool operator!=(MathIterator const &, MathIterator const &);
53
54 ///
55 MathIterator ibegin(MathAtom & p);
56 ///
57 MathIterator iend(MathAtom & p);
58
59 #endif