X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fiterators.h;h=a68f7ff12d565886c7c732b4332edd0d79a214b0;hb=67f9c9fdae42211aa3ff8d0c6f62485bd721d8eb;hp=9bc322ec6bae490e301ed3a63c2191de6711a030;hpb=d605c30d8cfdba7ab14c111b0cbe4b9d4fdbacc4;p=lyx.git diff --git a/src/iterators.h b/src/iterators.h index 9bc322ec6b..a68f7ff12d 100644 --- a/src/iterators.h +++ b/src/iterators.h @@ -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 +#include "support/types.h" -class ParIterator { +#include + +#include + +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 it; + /// + boost::optional 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*(); + Paragraph & operator*() const; /// - ParagraphList::iterator operator->(); + 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 PosHolder; + PosHolder const & positions() const + { + return positions_; + } private: - struct Pimpl; - boost::scoped_ptr 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,20 +107,23 @@ public: /// ParConstIterator & operator++(); /// - ParagraphList::iterator operator*(); - + ParagraphList::const_iterator pit() const; /// - ParagraphList::iterator operator->(); - + 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 PosHolder; + PosHolder const & positions() const + { + return positions_; + } private: - struct Pimpl; - boost::scoped_ptr pimpl_; + PosHolder positions_; }; bool operator==(ParConstIterator const & iter1,