2001-09-01 21:26:34 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
|
|
|
|
#ifndef ITERATORS_H
|
|
|
|
#define ITERATORS_H
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
#include <stack>
|
2001-09-01 21:26:34 +00:00
|
|
|
|
|
|
|
#include "paragraph.h"
|
|
|
|
|
|
|
|
class ParPosition {
|
|
|
|
public:
|
|
|
|
ParPosition(Paragraph * p)
|
|
|
|
: par(p), it(p->inset_iterator_begin()), index(-1) {}
|
|
|
|
///
|
|
|
|
Paragraph * par;
|
|
|
|
///
|
|
|
|
Paragraph::inset_iterator it;
|
|
|
|
///
|
|
|
|
int index;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class ParIterator {
|
|
|
|
public:
|
2002-02-16 15:59:55 +00:00
|
|
|
///
|
|
|
|
typedef std::stack<ParPosition> PosHolder;
|
2001-09-01 21:26:34 +00:00
|
|
|
///
|
|
|
|
ParIterator() {}
|
2002-02-16 15:59:55 +00:00
|
|
|
///
|
|
|
|
ParIterator(Paragraph * par) {
|
|
|
|
positions.push(ParPosition(par));
|
|
|
|
}
|
2001-09-01 21:26:34 +00:00
|
|
|
///
|
|
|
|
ParIterator & operator++();
|
|
|
|
///
|
2002-02-16 15:59:55 +00:00
|
|
|
Paragraph * operator*() {
|
|
|
|
return positions.top().par;
|
|
|
|
}
|
2001-09-01 21:26:34 +00:00
|
|
|
///
|
2002-03-21 17:27:08 +00:00
|
|
|
PosHolder::size_type size() const
|
2001-09-01 21:26:34 +00:00
|
|
|
{ return positions.size(); }
|
|
|
|
///
|
|
|
|
friend
|
|
|
|
bool operator==(ParIterator const & iter1, ParIterator const & iter2);
|
|
|
|
private:
|
|
|
|
///
|
2002-02-16 15:59:55 +00:00
|
|
|
PosHolder positions;
|
2001-09-01 21:26:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|