mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-01 05:25:55 +00:00
8aaf803192
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8060 a592a061-630c-0410-9148-cb99ea01b6c8
72 lines
1.7 KiB
C++
72 lines
1.7 KiB
C++
// -*- 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"
|
|
|
|
#include <vector>
|
|
|
|
|
|
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 &);
|
|
|
|
ParagraphList::iterator pit() const { return stack_.back().pit; }
|
|
lyx::pos_type pos() const { return stack_.back().pos; }
|
|
bool at_end() const;
|
|
InsetOld * inset() const;
|
|
friend PosIterator ParIterator::asPosIterator(lyx::pos_type) const;
|
|
friend ParIterator::ParIterator(PosIterator const &);
|
|
|
|
private:
|
|
PosIterator() {};
|
|
//this is conceptually a stack, but we need random access sometimes
|
|
std::vector<PosIteratorItem> stack_;
|
|
};
|
|
|
|
bool operator!=(PosIterator const &, PosIterator const &);
|
|
bool operator==(PosIterator const &, PosIterator const &);
|
|
|
|
int distance(PosIterator const &, PosIterator const &);
|
|
void advance(PosIterator &, int);
|
|
|
|
#endif
|
|
|