]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_iterator.h
Georg Baum's vspace change
[lyx.git] / src / mathed / math_iterator.h
index d30bd4752998ba59c2d499f5935e6c45515d40d5..bc437b74d3b97409a60c33fe4a6019430c0c9877 100644 (file)
@@ -1,50 +1,73 @@
 // -*- C++ -*-
+/**
+ * \file math_iterator.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
 #ifndef MATH_ITERATOR_H
 #define MATH_ITERATOR_H
 
-#include "math_cursor.h"
+#include "math_pos.h"
+
+#include <vector>
+
 
-// this helper struct is used for traversing math insets
+// this is used for traversing math insets
 
-class MathIterator {
+class MathIterator : private std::vector<CursorPos> {
 public:
-       /// default constructor, used for end of range
-       //MathIterator();
+       // re-use inherited stuff
+       typedef std::vector<CursorPos> 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;
+       CursorPos const & operator*() const;
        ///
-       MathCursorPos const & operator->() const;
+       CursorPos const & operator->() const;
        /// move on one step
        void operator++();
        /// move on several steps
-       void jump(MathInset::difference_type);
-       /// read access to top most item (inline after running gprof!)
-       MathCursorPos const & position() const { return cursor_.back(); }
-       /// write access to top most item
-       MathCursorPos & position() { return cursor_.back(); }
-       /// 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;
+       MathInset const * inset() const;
        /// read access to top most inset
-       MathInset * par();
+       MathInset * inset();
        /// helper for iend
        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:
        /// own level down
        void push(MathInset *);
        /// own level up
        void pop();
-
-       /// current position
-       MathCursor::cursor_type cursor_;
 };
 
 ///