]> git.lyx.org Git - lyx.git/blob - src/mathed/math_iterator.h
enable direct input of #1...#9; some whitespace changes
[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 inset
14         explicit MathIterator(MathInset * p);
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         /// move on one step
22         void operator++();
23         /// move on several steps
24         void jump(MathInset::difference_type);
25         /// read access to top most item
26         MathCursorPos const & position() const;
27         /// write access to top most item
28         MathCursorPos & position();
29         /// read access to full path
30         MathCursor::cursor_type const & cursor() const;
31         /// read access to top most inset
32         MathInset const * par() const;
33         /// read access to top most inset
34         MathInset * par();
35         /// helper for iend
36         void goEnd();
37         /// read access to top most item
38         MathArray const & cell() const;
39
40 private:        
41         /// read access to top most item
42         MathXArray const & xcell() const;
43         /// write access to top most item
44         MathInset * nextInset() const;
45         /// own level down
46         void push(MathInset *);
47         /// own level up
48         void pop();
49
50         /// current position
51         MathCursor::cursor_type cursor_;
52 };
53
54 ///
55 bool operator==(MathIterator const &, MathIterator const &);
56 ///
57 bool operator!=(MathIterator const &, MathIterator const &);
58
59 ///
60 MathIterator ibegin(MathInset * p);
61 ///
62 MathIterator iend(MathInset * p);
63
64 #endif