-/* \file iterators.C
+/* \file pariterator.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* Full author contact details are available in file CREDITS.
*/
-
#include <config.h>
-
#include "pariterator.h"
#include "ParagraphList_fwd.h"
#include "insets/inset.h"
-using lyx::par_type;
+using lyx::pit_type;
+
///
/// ParIterator
///
-ParIterator::ParIterator(DocumentIterator const & cur) : DocumentIterator(cur)
+ParIterator::ParIterator(DocIterator const & cur) : DocIterator(cur)
{}
-ParIterator::ParIterator(InsetBase & in, par_type pit) : DocumentIterator(in)
+ParIterator par_iterator_begin(InsetBase & inset)
+{
+ return ParIterator(doc_iterator_begin(inset));
+}
+
+
+ParIterator par_iterator_end(InsetBase & inset)
{
- par() = pit;
+ return ParIterator(doc_iterator_end(inset));
}
ParIterator::ParIterator(ParIterator const & pi)
- : DocumentIterator(DocumentIterator(pi))
+ : DocIterator(DocIterator(pi))
{}
}
+ParIterator ParIterator::operator++(int)
+{
+ ParIterator tmp(*this);
+ forwardPar();
+ return tmp;
+}
+
+
+#if 0
+// Unused member functions. Also having this makes ParIterator not be
+// an forward iterator anymore. So unless we change that, this function
+// should not be compiled/used. (Lgb)
ParIterator & ParIterator::operator--()
{
-// DocumentIterator::backwardPar();
+#ifdef WITH_WARNINGS
+#warning look here
+#endif
+// DocIterator::backwardPar();
return *this;
}
+#endif
Paragraph & ParIterator::operator*() const
{
- return text()->getPar(par());
+ return text()->getPar(pit());
}
-par_type ParIterator::pit() const
+pit_type ParIterator::pit() const
{
- return par();
+ return pit();
}
Paragraph * ParIterator::operator->() const
{
- return &text()->getPar(par());
+ return &text()->getPar(pit());
}
-par_type ParIterator::outerPar() const
+pit_type ParIterator::outerPar() const
{
- return bottom().par();
+ return bottom().pit();
}
bool operator==(ParIterator const & iter1, ParIterator const & iter2)
{
- return DocumentIterator(iter1) == DocumentIterator(iter2);
+ return DocIterator(iter1) == DocIterator(iter2);
}
return !(iter1 == iter2);
}
-DocumentIterator
-makeDocumentIterator(ParIterator const & par, lyx::pos_type pos)
+
+DocIterator makeDocIterator(ParIterator const & par, lyx::pos_type pos)
{
- DocumentIterator dit(par);
+ DocIterator dit(par);
dit.pos() = pos;
return dit;
}
+
+
///
/// ParConstIterator
///
-ParConstIterator::ParConstIterator(InsetBase const & in, par_type pit)
- : DocumentIterator(const_cast<InsetBase &>(in))
-{
- par() = pit;
-}
-
-
-ParConstIterator::ParConstIterator(DocumentIterator const & dit)
- : DocumentIterator(dit)
+ParConstIterator::ParConstIterator(DocIterator const & dit)
+ : DocIterator(dit)
{}
ParConstIterator::ParConstIterator(ParConstIterator const & pi)
- : DocumentIterator(DocumentIterator(pi))
+ : DocIterator(DocIterator(pi))
{}
ParConstIterator & ParConstIterator::operator++()
{
- DocumentIterator::forwardPar();
+ DocIterator::forwardPar();
return *this;
}
Paragraph const & ParConstIterator::operator*() const
{
- return text()->getPar(par());
+ return text()->getPar(pit());
}
Paragraph const * ParConstIterator::operator->() const
{
- return &text()->getPar(par());
+ return &text()->getPar(pit());
}
bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
{
- return DocumentIterator(iter1) == DocumentIterator(iter2);
+ return DocIterator(iter1) == DocIterator(iter2);
}
{
return !(iter1 == iter2);
}
+
+
+#ifdef WITH_WARNINGS
+#warning const correctness!
+#endif
+
+ParConstIterator par_const_iterator_begin(InsetBase const & inset)
+{
+ return ParConstIterator(doc_iterator_begin(const_cast<InsetBase &>(inset)));
+}
+
+
+ParConstIterator par_const_iterator_end(InsetBase const & inset)
+{
+ return ParConstIterator(doc_iterator_end(const_cast<InsetBase &>(inset)));
+}