]> git.lyx.org Git - lyx.git/blob - src/mathed/math_iterator.h
the lfun3 patches (overall cleanup and "localizing" dispatch() in mathed)
[lyx.git] / src / mathed / math_iterator.h
1 // -*- C++ -*-
2 #ifndef MATH_ITERATOR_H
3 #define MATH_ITERATOR_H
4
5 #include "math_pos.h"
6 #include <vector>
7
8 // this is used for traversing math insets
9
10 class MathIterator : private std::vector<MathCursorPos> {
11 public:
12         // re-use inherited stuff
13         typedef std::vector<MathCursorPos> base_type;
14         using base_type::clear;
15         using base_type::size;
16         using base_type::push_back;
17         using base_type::pop_back;
18         using base_type::back;
19         using base_type::begin;
20         using base_type::end;
21         using base_type::erase;
22         using base_type::operator[];
23         using base_type::size_type;
24         using base_type::difference_type;
25         using base_type::const_iterator;
26         friend bool operator!=(MathIterator const &, MathIterator const &);
27         friend bool operator==(MathIterator const &, MathIterator const &);
28
29         /// default constructor
30         MathIterator();
31         /// start with given inset
32         explicit MathIterator(MathInset * p);
33         ///
34         MathCursorPos const & operator*() const;
35         ///
36         MathCursorPos const & operator->() const;
37         /// move on one step
38         void operator++();
39         /// move on several steps
40         void jump(difference_type);
41         /// read access to top most inset
42         MathInset const * par() const;
43         /// read access to top most inset
44         MathInset * par();
45         /// helper for iend
46         void goEnd();
47         /// read access to top most item
48         MathArray const & cell() const;
49         /// shrinks to at most i levels
50         void shrink(size_type i);
51
52 private:
53         /// own level down
54         void push(MathInset *);
55         /// own level up
56         void pop();
57 };
58
59 ///
60 bool operator==(MathIterator const &, MathIterator const &);
61 ///
62 bool operator!=(MathIterator const &, MathIterator const &);
63
64 ///
65 MathIterator ibegin(MathInset * p);
66 ///
67 MathIterator iend(MathInset * p);
68
69 #endif