]> git.lyx.org Git - lyx.git/blobdiff - src/iterators.h
"Inter-word Space"
[lyx.git] / src / iterators.h
index 148eda029ceabff7a47c8fbdea8794230d70f10a..8c607ee212d6da3819109d03ec202408de1dda88 100644 (file)
@@ -1,72 +1,86 @@
 // -*- C++ -*-
+/* \file iterators.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author unknown
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
+ */
 
 #ifndef ITERATORS_H
 #define ITERATORS_H
 
-#include <vector>
+#include "ParagraphList.h"
 
-#include "paragraph.h"
+#include <boost/scoped_ptr.hpp>
 
-class ParPosition {
+class ParIterator {
 public:
-       ParPosition(Paragraph * p)
-               : par(p), it(p->inset_iterator_begin()), index(-1) {}
        ///
-       Paragraph * par;
+       ParIterator(ParagraphList::iterator pit, ParagraphList const & pl);
+       ///
+       ~ParIterator();
+       ///
+       ParIterator(ParIterator const &);
+       ///
+       void operator=(ParIterator const &);
+       ///
+       ParIterator & operator++();
+       ///
+       ParagraphList::iterator operator*() const;
        ///
-       Paragraph::inset_iterator it;
+       ParagraphList::iterator operator->() const;
        ///
-       int index;
+       ParagraphList & plist() const;
+       ///
+       size_t size() const;
+       ///
+       friend
+       bool operator==(ParIterator const & iter1, ParIterator const & iter2);
+private:
+       struct Pimpl;
+       boost::scoped_ptr<Pimpl> pimpl_;
 };
 
+///
+bool operator==(ParIterator const & iter1, ParIterator const & iter2);
 
-inline
-bool operator==(ParPosition const & pos1, ParPosition const & pos2) {
-       return pos1.par == pos2.par &&
-               pos1.it == pos2.it &&
-               pos1.index == pos2.index;
-}
-
-inline
-bool operator!=(ParPosition const & pos1, ParPosition const & pos2) {
-       return !(pos1 == pos2);
-}
+///
+bool operator!=(ParIterator const & iter1, ParIterator const & iter2);
 
 
-class ParIterator {
+class ParConstIterator {
 public:
        ///
-       ParIterator() {}
-       //
-       ParIterator(Paragraph * par) 
-               : positions(1, ParPosition(par)) {}
+       ParConstIterator(ParagraphList::iterator pit, ParagraphList const & pl);
        ///
-       ParIterator & operator++();
+       ~ParConstIterator();
+       ///
+       ParConstIterator(ParConstIterator const &);
        ///
-       Paragraph * operator*() { return positions.back().par; }
+       ParConstIterator & operator++();
+       ///
+       ParagraphList::iterator operator*() const;
+       ///
+       ParagraphList::iterator operator->() const;
+
        ///
-       vector<ParPosition>::size_type size() const 
-               { return positions.size(); }
+       size_t size() const;
        ///
        friend
-       bool operator==(ParIterator const & iter1, ParIterator const & iter2);
+       bool operator==(ParConstIterator const & iter1,
+                       ParConstIterator const & iter2);
 private:
-       ///
-       std::vector<ParPosition> positions;
+       struct Pimpl;
+       boost::scoped_ptr<Pimpl> pimpl_;
 };
 
+bool operator==(ParConstIterator const & iter1,
+               ParConstIterator const & iter2);
 
-///
-inline
-bool operator==(ParIterator const & iter1, ParIterator const & iter2) {
-       return iter1.positions == iter2.positions;
-}
-
-
-///
-inline
-bool operator!=(ParIterator const & iter1, ParIterator const & iter2) {
-       return !(iter1 == iter2);
-}
+bool operator!=(ParConstIterator const & iter1,
+               ParConstIterator const & iter2);
 
 #endif