]> git.lyx.org Git - lyx.git/blob - src/mathed/math_iterator.h
Georg Baum's vspace change
[lyx.git] / src / mathed / math_iterator.h
1 // -*- C++ -*-
2 /**
3  * \file math_iterator.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_ITERATOR_H
13 #define MATH_ITERATOR_H
14
15 #include "math_pos.h"
16
17 #include <vector>
18
19
20 // this is used for traversing math insets
21
22 class MathIterator : private std::vector<CursorPos> {
23 public:
24         // re-use inherited stuff
25         typedef std::vector<CursorPos> base_type;
26         using base_type::clear;
27         using base_type::size;
28         using base_type::push_back;
29         using base_type::pop_back;
30         using base_type::back;
31         using base_type::begin;
32         using base_type::end;
33         using base_type::erase;
34         using base_type::operator[];
35         using base_type::size_type;
36         using base_type::difference_type;
37         using base_type::const_iterator;
38         friend bool operator!=(MathIterator const &, MathIterator const &);
39         friend bool operator==(MathIterator const &, MathIterator const &);
40
41         /// default constructor
42         MathIterator();
43         /// start with given inset
44         explicit MathIterator(MathInset * p);
45         ///
46         CursorPos const & operator*() const;
47         ///
48         CursorPos const & operator->() const;
49         /// move on one step
50         void operator++();
51         /// move on several steps
52         void jump(difference_type);
53         /// read access to top most inset
54         MathInset const * inset() const;
55         /// read access to top most inset
56         MathInset * inset();
57         /// helper for iend
58         void goEnd();
59         /// read access to top most item
60         MathArray const & cell() const;
61         /// is this a non-end position
62         bool normal() const;
63         /// shrinks to at most i levels
64         void shrink(size_type i);
65
66 private:
67         /// own level down
68         void push(MathInset *);
69         /// own level up
70         void pop();
71 };
72
73 ///
74 bool operator==(MathIterator const &, MathIterator const &);
75 ///
76 bool operator!=(MathIterator const &, MathIterator const &);
77
78 ///
79 MathIterator ibegin(MathInset * p);
80 ///
81 MathIterator iend(MathInset * p);
82
83 #endif