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)
|
2002-08-11 15:03:52 +00:00
|
|
|
: par(p), it(p->insetlist.begin()), index(-1) {}
|
2001-09-01 21:26:34 +00:00
|
|
|
///
|
|
|
|
Paragraph * par;
|
|
|
|
///
|
2002-08-11 15:03:52 +00:00
|
|
|
InsetList::iterator it;
|
2001-09-01 21:26:34 +00:00
|
|
|
///
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2002-11-08 01:08:27 +00:00
|
|
|
|
|
|
|
class ParConstIterator {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
typedef std::stack<ParPosition> PosHolder;
|
|
|
|
///
|
|
|
|
ParConstIterator() {}
|
|
|
|
///
|
|
|
|
ParConstIterator(Paragraph * par) {
|
|
|
|
positions.push(ParPosition(par));
|
|
|
|
}
|
|
|
|
///
|
|
|
|
ParConstIterator & operator++();
|
|
|
|
///
|
|
|
|
Paragraph const * operator*() {
|
|
|
|
return positions.top().par;
|
|
|
|
}
|
|
|
|
///
|
|
|
|
PosHolder::size_type size() const
|
|
|
|
{ return positions.size(); }
|
|
|
|
///
|
|
|
|
friend
|
|
|
|
bool operator==(ParConstIterator const & iter1,
|
|
|
|
ParConstIterator const & iter2);
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
PosHolder positions;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
inline
|
|
|
|
bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2) {
|
|
|
|
return iter1.positions == iter2.positions;
|
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
inline
|
|
|
|
bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2) {
|
|
|
|
return !(iter1 == iter2);
|
|
|
|
}
|
|
|
|
|
2001-09-01 21:26:34 +00:00
|
|
|
#endif
|