1 /* \file ParIterator.cpp
2 * This file is part of LyX, the document processor.
3 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS.
13 #include "ParIterator.h"
15 #include "Paragraph.h"
18 #include "insets/Inset.h"
27 ParIterator::ParIterator(DocIterator const & cur)
32 ParIterator par_iterator_begin(Inset & inset)
34 return ParIterator(doc_iterator_begin(inset));
38 ParIterator par_iterator_end(Inset & inset)
40 return ParIterator(doc_iterator_end(inset));
44 ParIterator::ParIterator(ParIterator const & pi)
45 : DocIterator(DocIterator(pi))
49 ParIterator & ParIterator::operator++()
56 ParIterator ParIterator::operator++(int)
58 ParIterator tmp(*this);
65 // Unused member functions. Also having this makes ParIterator not be
66 // an forward iterator anymore. So unless we change that, this function
67 // should not be compiled/used. (Lgb)
68 ParIterator & ParIterator::operator--()
71 // DocIterator::backwardPar();
77 Paragraph & ParIterator::operator*() const
79 return const_cast<Paragraph&>(text()->getPar(pit()));
83 pit_type ParIterator::pit() const
85 return DocIterator::pit();
89 Paragraph * ParIterator::operator->() const
91 return const_cast<Paragraph*>(&text()->getPar(pit()));
95 pit_type ParIterator::outerPar() const
97 return bottom().pit();
101 ParagraphList & ParIterator::plist() const
103 return const_cast<ParagraphList&>(text()->paragraphs());
107 DocIterator makeDocIterator(ParIterator const & par, pos_type pos)
109 DocIterator dit(par);
121 ParConstIterator::ParConstIterator(DocIterator const & dit)
126 ParConstIterator::ParConstIterator(ParConstIterator const & pi)
127 : DocIterator(DocIterator(pi))
131 ParConstIterator & ParConstIterator::operator++()
133 DocIterator::forwardPar();
138 Paragraph const & ParConstIterator::operator*() const
140 return text()->getPar(pit());
144 Paragraph const * ParConstIterator::operator->() const
146 return &text()->getPar(pit());
150 ParagraphList const & ParConstIterator::plist() const
152 return text()->paragraphs();
156 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
158 // FIXME: this makes two full copies!
159 return DocIterator(iter1) == DocIterator(iter2);
163 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
165 return !(iter1 == iter2);
170 // FIXME: const correctness!
172 ParConstIterator par_const_iterator_begin(Inset const & inset)
174 return ParConstIterator(doc_iterator_begin(const_cast<Inset &>(inset)));
178 ParConstIterator par_const_iterator_end(Inset const & inset)
180 return ParConstIterator(doc_iterator_end(const_cast<Inset &>(inset)));