]> git.lyx.org Git - features.git/blob - src/mathed/math_iterator.h
deep iterators for math insets;
[features.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(MathInset * p);
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         MathInset * par() const;
30         
31 private:
32         /// write access to top most item
33         MathXArray const & xcell() const;
34         /// write access to top most item
35         MathInset * nextInset() const;
36         /// own level down
37         void push(MathInset *);
38         /// own level up
39         void pop();
40
41         /// current position
42         MathCursor::cursor_type cursor_;
43 };
44
45 ///
46 bool operator==(MathIterator const &, MathIterator const &);
47 ///
48 bool operator!=(MathIterator const &, MathIterator const &);
49
50
51 #endif