]> git.lyx.org Git - lyx.git/blobdiff - src/iterators.h
fix mathed crash
[lyx.git] / src / iterators.h
index bb3288ce8a711d9ec28ba87ed182ccd4882d9453..a68f7ff12d565886c7c732b4332edd0d79a214b0 100644 (file)
 #define ITERATORS_H
 
 #include "ParagraphList_fwd.h"
+#include "InsetList.h"
+
 #include "support/types.h"
 
-#include <boost/scoped_ptr.hpp>
+#include <boost/optional.hpp>
+
+#include <vector>
 
 class LyXText;
-class InsetOld;
+class InsetBase;
 class Cursor;
-class BufferView;
+class Buffer;
 class PosIterator;
 
 
-class ParIterator {
+class ParPosition {
+public:
+       ///
+       ParPosition(ParagraphList::iterator p, ParagraphList const & pl);
+       ///
+       ParagraphList::iterator pit;
+       ///
+       ParagraphList const * plist;
+       ///
+       boost::optional<InsetList::iterator> it;
+       ///
+       boost::optional<int> index;
+};
+
+
+class ParIterator  : public std::iterator<
+       std::forward_iterator_tag,
+       ParagraphList::value_type> {
 public:
        ///
        ParIterator(ParagraphList::iterator pit, ParagraphList const & pl);
@@ -49,24 +70,21 @@ public:
        ///
        ParagraphList & plist() const;
        /// returns 'innermost' LyXText
-       LyXText * text(BufferView *) const;
+       LyXText * text(Buffer &) const;
        /// returns innermost inset
-       InsetOld * inset() const;
+       InsetBase * inset() const;
        /// returns index of cell in innermost inset
        int index() const;
        ///
        size_t size() const;
-       ///
-       friend
-       bool operator==(ParIterator const & iter1, ParIterator const & iter2);
-       ///
-       void lockPath(BufferView *) const;
 
-       ///
-       PosIterator asPosIterator(lyx::pos_type) const;
+       typedef std::vector<ParPosition> PosHolder;
+       PosHolder const & positions() const
+       {
+               return positions_;
+       }
 private:
-       struct Pimpl;
-       boost::scoped_ptr<Pimpl> pimpl_;
+       PosHolder positions_;
 };
 
 ///
@@ -76,7 +94,9 @@ bool operator==(ParIterator const & iter1, ParIterator const & iter2);
 bool operator!=(ParIterator const & iter1, ParIterator const & iter2);
 
 
-class ParConstIterator {
+class ParConstIterator : public std::iterator<
+       std::forward_iterator_tag,
+       ParagraphList::value_type> {
 public:
        ///
        ParConstIterator(ParagraphList::iterator pit, ParagraphList const & pl);
@@ -97,14 +117,13 @@ public:
 
        /// depth of nesting
        size_t size() const;
-       ///
-       friend
-       bool operator==(ParConstIterator const & iter1,
-                       ParConstIterator const & iter2);
-
+       typedef std::vector<ParPosition> PosHolder;
+       PosHolder const & positions() const
+       {
+               return positions_;
+       }
 private:
-       struct Pimpl;
-       boost::scoped_ptr<Pimpl> pimpl_;
+       PosHolder positions_;
 };
 
 bool operator==(ParConstIterator const & iter1,