]> git.lyx.org Git - lyx.git/blob - src/mathed/math_iterator.h
move things around
[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::operator[];
22         using base_type::size_type;
23         using base_type::difference_type;
24         using base_type::const_iterator;
25         friend bool operator!=(MathIterator const &, MathIterator const &);
26         friend bool operator==(MathIterator const &, MathIterator const &);
27
28         /// default constructor
29         MathIterator();
30         /// start with given inset
31         explicit MathIterator(MathInset * p);
32         ///
33         MathCursorPos const & operator*() const;
34         ///
35         MathCursorPos const & operator->() const;
36         /// move on one step
37         void operator++();
38         /// move on several steps
39         void jump(difference_type);
40         /// read access to top most inset
41         MathInset const * par() const;
42         /// read access to top most inset
43         MathInset * par();
44         /// helper for iend
45         void goEnd();
46         /// read access to top most item
47         MathArray const & cell() const;
48
49 private:
50         /// own level down
51         void push(MathInset *);
52         /// own level up
53         void pop();
54 };
55
56 ///
57 bool operator==(MathIterator const &, MathIterator const &);
58 ///
59 bool operator!=(MathIterator const &, MathIterator const &);
60
61 ///
62 MathIterator ibegin(MathInset * p);
63 ///
64 MathIterator iend(MathInset * p);
65
66 #endif