]> git.lyx.org Git - lyx.git/blobdiff - src/iterators.h
fix mathed crash
[lyx.git] / src / iterators.h
index 5cca3f717d6dc3e2fa4de25696a0a0467960c646..a68f7ff12d565886c7c732b4332edd0d79a214b0 100644 (file)
@@ -6,17 +6,46 @@
  * \author unknown
  * \author Lars Gullik Bjønnes
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #ifndef ITERATORS_H
 #define ITERATORS_H
 
-#include "ParagraphList.h"
+#include "ParagraphList_fwd.h"
+#include "InsetList.h"
 
-#include <boost/scoped_ptr.hpp>
+#include "support/types.h"
 
-class ParIterator {
+#include <boost/optional.hpp>
+
+#include <vector>
+
+class LyXText;
+class InsetBase;
+class Cursor;
+class Buffer;
+class PosIterator;
+
+
+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);
@@ -25,19 +54,37 @@ public:
        ///
        ParIterator(ParIterator const &);
        ///
+       ParIterator(PosIterator const &);
+       ///
+       void operator=(ParIterator const &);
+       ///
        ParIterator & operator++();
        ///
-       ParagraphList::iterator operator*() const;
+       Paragraph & operator*() const;
        ///
        ParagraphList::iterator operator->() const;
+       /// This gives us the top-most parent paragraph
+       ParagraphList::iterator outerPar() const;
        ///
-       size_t size() const;
+       ParagraphList::iterator pit() const;
+       ///
+       ParagraphList & plist() const;
+       /// returns 'innermost' LyXText
+       LyXText * text(Buffer &) const;
+       /// returns innermost inset
+       InsetBase * inset() const;
+       /// returns index of cell in innermost inset
+       int index() const;
        ///
-       friend
-       bool operator==(ParIterator const & iter1, ParIterator const & iter2);
+       size_t size() const;
+
+       typedef std::vector<ParPosition> PosHolder;
+       PosHolder const & positions() const
+       {
+               return positions_;
+       }
 private:
-       struct Pimpl;
-       boost::scoped_ptr<Pimpl> pimpl_;
+       PosHolder positions_;
 };
 
 ///
@@ -47,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);
@@ -58,19 +107,23 @@ public:
        ///
        ParConstIterator & operator++();
        ///
-       ParagraphList::iterator operator*() const;
+       ParagraphList::const_iterator pit() const;
        ///
-       ParagraphList::iterator operator->() const;
-
+       Paragraph const & operator*() const;
        ///
-       size_t size() const;
+       ParagraphList::const_iterator operator->() const;
        ///
-       friend
-       bool operator==(ParConstIterator const & iter1,
-                       ParConstIterator const & iter2);
+       ParagraphList const & plist() const;
+
+       /// depth of nesting
+       size_t size() const;
+       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,