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