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