]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_iterator.C
remove unneeded inset() member function
[lyx.git] / src / mathed / math_iterator.C
index ddfbc620aa4fc6eca595a9b30dde715289d28b0b..180de4602ff5daea747bc8b85a6bdfd8bd45a585 100644 (file)
@@ -1,13 +1,20 @@
-#ifdef __GNUG__
-#pragma implementation 
-#endif
+/**
+ * \file math_iterator.C
+ * 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.
+ */
 
 #include <config.h>
 
 #include "math_iterator.h"
 #include "math_inset.h"
-#include "debug.h"
-#include "support/LAssert.h"
+#include "math_data.h"
+
+#include <boost/assert.hpp>
 
 
 MathIterator::MathIterator()
@@ -20,22 +27,11 @@ MathIterator::MathIterator(MathInset * p)
 }
 
 
-MathInset const * MathIterator::par() const
-{
-       return back().par_;
-}
-
-
-MathInset * MathIterator::par()
-{
-       return back().par_;
-}
-
 
 MathArray const & MathIterator::cell() const
 {
-       MathCursorPos const & top = back();
-       return top.par_->cell(top.idx_);
+       CursorSlice const & top = back();
+       return top.asMathInset()->cell(top.idx_);
 }
 
 
@@ -43,25 +39,25 @@ MathArray const & MathIterator::cell() const
 void MathIterator::push(MathInset * p)
 {
        //lyxerr << "push: " << p << endl;
-       push_back(MathCursorPos(p));
+       push_back(CursorSlice(p));
 }
 
 
 void MathIterator::pop()
 {
        //lyxerr << "pop: " << endl;
-       lyx::Assert(size());
+       BOOST_ASSERT(size());
        pop_back();
 }
 
 
-MathCursorPos const & MathIterator::operator*() const
+CursorSlice const & MathIterator::operator*() const
 {
        return back();
 }
 
 
-MathCursorPos const & MathIterator::operator->() const
+CursorSlice const & MathIterator::operator->() const
 {
        return back();
 }
@@ -69,16 +65,16 @@ MathCursorPos const & MathIterator::operator->() const
 
 void MathIterator::goEnd()
 {
-       MathCursorPos & top = back();
-       top.idx_ = top.par_->nargs() - 1;
+       CursorSlice & top = back();
+       top.idx_ = top.asMathInset()->nargs() - 1;
        top.pos_ = cell().size();
 }
 
 
 void MathIterator::operator++()
 {
-       MathCursorPos & top = back();
-       MathArray     & ar  = top.par_->cell(top.idx_);
+       CursorSlice & top = back();
+       MathArray   & ar  = top.asMathInset()->cell(top.idx_);
 
        // move into the current inset if possible
        // it is impossible for pos() == size()!
@@ -98,10 +94,10 @@ void MathIterator::operator++()
        }
 
        // otherwise try to move on one cell if possible
-       while (top.idx_ + 1 < top.par_->nargs()) {
+       while (top.idx_ + 1 < top.asMathInset()->nargs()) {
                // idx() == nargs() is _not_ valid!
                ++top.idx_;
-               if (top.par_->validCell(top.idx_)) {
+               if (top.asMathInset()->validCell(top.idx_)) {
                        top.pos_ = 0;
                        return;
                }
@@ -118,25 +114,15 @@ void MathIterator::operator++()
 void MathIterator::jump(difference_type i)
 {
        back().pos_ += i;
-       //lyx::Assert(back().pos_ >= 0);
-       lyx::Assert(back().pos_ <= cell().size());
-}
-
-
-/*
-void MathIterator::shrink(size_type i)
-{
-       if (i < size())
-               erase(begin() + i, end());
+       //BOOST_ASSERT(back().pos_ >= 0);
+       BOOST_ASSERT(back().pos_ <= cell().size());
 }
 
 
-void MathIterator::shrink(size_type i)
+bool MathIterator::normal() const
 {
-       if (i < size())
-               erase(begin() + i, end());
+       return back().pos_ < cell().size();
 }
-*/
 
 
 void MathIterator::shrink(size_type i)