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