2003-11-02 17:56:26 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* \file PosIterator.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Alfredo Braunstein
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef POSITERATOR_H
|
|
|
|
#define POSITERATOR_H
|
|
|
|
|
|
|
|
#include "ParagraphList_fwd.h"
|
|
|
|
|
|
|
|
#include "iterators.h"
|
|
|
|
|
|
|
|
#include "support/types.h"
|
|
|
|
|
2003-11-07 09:40:49 +00:00
|
|
|
#include <vector>
|
2003-11-02 17:56:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BufferView;
|
|
|
|
|
|
|
|
struct PosIteratorItem
|
|
|
|
{
|
|
|
|
PosIteratorItem(ParagraphList * pl,
|
|
|
|
ParagraphList::iterator pit,
|
|
|
|
lyx::pos_type pos,
|
|
|
|
int index = 0)
|
|
|
|
: pl(pl), pit(pit), pos(pos), index(index) {};
|
|
|
|
ParagraphList * pl;
|
|
|
|
ParagraphList::iterator pit;
|
|
|
|
lyx::pos_type pos;
|
|
|
|
int index;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class PosIterator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PosIterator(BufferView & bv);
|
|
|
|
PosIterator(ParIterator & par, lyx::pos_type pos);
|
|
|
|
PosIterator(ParagraphList * pl, ParagraphList::iterator pit,
|
|
|
|
lyx::pos_type pos);
|
|
|
|
PosIterator(ParIterator const & parit, lyx::pos_type p);
|
|
|
|
PosIterator & operator++();
|
|
|
|
PosIterator & operator--();
|
|
|
|
friend bool operator==(PosIterator const &, PosIterator const &);
|
|
|
|
|
2003-11-07 09:40:49 +00:00
|
|
|
ParagraphList::iterator pit() const { return stack_.back().pit; }
|
|
|
|
lyx::pos_type pos() const { return stack_.back().pos; }
|
2003-11-02 17:56:26 +00:00
|
|
|
bool at_end() const;
|
2003-11-07 09:40:49 +00:00
|
|
|
InsetOld * inset() const;
|
2003-11-02 17:56:26 +00:00
|
|
|
friend PosIterator ParIterator::asPosIterator(lyx::pos_type) const;
|
2003-11-06 09:51:08 +00:00
|
|
|
friend ParIterator::ParIterator(PosIterator const &);
|
2003-11-02 17:56:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
PosIterator() {};
|
2003-11-07 09:40:49 +00:00
|
|
|
//this is conceptually a stack, but we need random access sometimes
|
|
|
|
std::vector<PosIteratorItem> stack_;
|
2003-11-02 17:56:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool operator!=(PosIterator const &, PosIterator const &);
|
2003-11-03 09:23:23 +00:00
|
|
|
bool operator==(PosIterator const &, PosIterator const &);
|
2003-11-02 17:56:26 +00:00
|
|
|
|
2003-11-03 09:23:23 +00:00
|
|
|
int distance(PosIterator const &, PosIterator const &);
|
|
|
|
void advance(PosIterator &, int);
|
2003-11-02 17:56:26 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|