]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_iterator.h
fix #1073
[lyx.git] / src / mathed / math_iterator.h
index 7b484b030b41be4c37166a333024513a6c3c0510..5c76edc6db9be0ae7fd77e61f71770078a8e5a53 100644 (file)
@@ -2,18 +2,35 @@
 #ifndef MATH_ITERATOR_H
 #define MATH_ITERATOR_H
 
-#include "math_cursor.h"
 
-// this helper struct is used for traversing math insets
+#include "math_pos.h"
+#include <vector>
 
-class MathIterator {
+// this is used for traversing math insets
+
+class MathIterator : private std::vector<MathCursorPos> {
 public:
-       /// default constructor, used for end of range
-       //MathIterator();
+       // re-use inherited stuff
+       typedef std::vector<MathCursorPos> base_type;
+       using base_type::clear;
+       using base_type::size;
+       using base_type::push_back;
+       using base_type::pop_back;
+       using base_type::back;
+       using base_type::begin;
+       using base_type::end;
+       using base_type::erase;
+       using base_type::operator[];
+       using base_type::size_type;
+       using base_type::difference_type;
+       using base_type::const_iterator;
+       friend bool operator!=(MathIterator const &, MathIterator const &);
+       friend bool operator==(MathIterator const &, MathIterator const &);
+
+       /// default constructor
+       MathIterator();
        /// start with given inset
        explicit MathIterator(MathInset * p);
-       /// start with given position
-       //explicit MathIterator(MathCursor::cursor_type const & cursor);
        ///
        MathCursorPos const & operator*() const;
        ///
@@ -21,13 +38,7 @@ public:
        /// move on one step
        void operator++();
        /// move on several steps
-       void jump(MathInset::difference_type);
-       /// read access to top most item
-       MathCursorPos const & position() const;
-       /// write access to top most item
-       MathCursorPos & position();
-       /// read access to full path
-       MathCursor::cursor_type const & cursor() const;
+       void jump(difference_type);
        /// read access to top most inset
        MathInset const * par() const;
        /// read access to top most inset
@@ -36,19 +47,16 @@ public:
        void goEnd();
        /// read access to top most item
        MathArray const & cell() const;
+       /// is this a non-end position
+       bool normal() const;
+       /// shrinks to at most i levels
+       void shrink(size_type i);
 
-private:       
-       /// read access to top most item
-       MathXArray const & xcell() const;
-       /// write access to top most item
-       MathInset * nextInset() const;
+private:
        /// own level down
        void push(MathInset *);
        /// own level up
        void pop();
-
-       /// current position
-       MathCursor::cursor_type cursor_;
 };
 
 ///