2001-12-10 20:06:59 +00:00
|
|
|
// -*- C++ -*-
|
2001-12-05 17:50:18 +00:00
|
|
|
#ifndef MATH_ITERATOR_H
|
|
|
|
#define MATH_ITERATOR_H
|
|
|
|
|
|
|
|
#include "math_cursor.h"
|
|
|
|
|
|
|
|
// this helper struct is used for traversing math insets
|
|
|
|
|
|
|
|
class MathIterator {
|
|
|
|
public:
|
|
|
|
/// default constructor, used for end of range
|
2001-12-10 10:09:00 +00:00
|
|
|
//MathIterator();
|
2001-12-11 15:35:18 +00:00
|
|
|
/// start with given inset
|
|
|
|
explicit MathIterator(MathInset * p);
|
2001-12-05 17:50:18 +00:00
|
|
|
/// start with given position
|
2001-12-11 15:35:18 +00:00
|
|
|
//explicit MathIterator(MathCursor::cursor_type const & cursor);
|
2001-12-05 17:50:18 +00:00
|
|
|
///
|
|
|
|
MathCursorPos const & operator*() const;
|
|
|
|
///
|
|
|
|
MathCursorPos const & operator->() const;
|
2002-01-03 09:41:26 +00:00
|
|
|
/// move on one step
|
2001-12-05 17:50:18 +00:00
|
|
|
void operator++();
|
2002-01-03 09:41:26 +00:00
|
|
|
/// move on several steps
|
2002-01-08 11:03:34 +00:00
|
|
|
void jump(MathInset::difference_type);
|
2002-03-12 14:59:08 +00:00
|
|
|
/// read access to top most item (inline after running gprof!)
|
|
|
|
MathCursorPos const & position() const { return cursor_.back(); }
|
2001-12-05 17:50:18 +00:00
|
|
|
/// write access to top most item
|
2002-03-12 14:59:08 +00:00
|
|
|
MathCursorPos & position() { return cursor_.back(); }
|
2001-12-05 17:50:18 +00:00
|
|
|
/// read access to full path
|
|
|
|
MathCursor::cursor_type const & cursor() const;
|
|
|
|
/// read access to top most inset
|
2001-12-11 15:35:18 +00:00
|
|
|
MathInset const * par() const;
|
2001-12-10 10:09:00 +00:00
|
|
|
/// read access to top most inset
|
2001-12-11 15:35:18 +00:00
|
|
|
MathInset * par();
|
2001-12-10 10:09:00 +00:00
|
|
|
/// helper for iend
|
|
|
|
void goEnd();
|
2002-01-03 09:41:26 +00:00
|
|
|
/// read access to top most item
|
|
|
|
MathArray const & cell() const;
|
|
|
|
|
2002-03-21 17:42:56 +00:00
|
|
|
private:
|
2001-12-05 17:50:18 +00:00
|
|
|
/// own level down
|
2001-12-11 15:35:18 +00:00
|
|
|
void push(MathInset *);
|
2001-12-05 17:50:18 +00:00
|
|
|
/// own level up
|
|
|
|
void pop();
|
|
|
|
|
|
|
|
/// current position
|
|
|
|
MathCursor::cursor_type cursor_;
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
bool operator==(MathIterator const &, MathIterator const &);
|
|
|
|
///
|
|
|
|
bool operator!=(MathIterator const &, MathIterator const &);
|
|
|
|
|
2001-12-10 10:09:00 +00:00
|
|
|
///
|
2001-12-11 15:35:18 +00:00
|
|
|
MathIterator ibegin(MathInset * p);
|
2001-12-10 10:09:00 +00:00
|
|
|
///
|
2001-12-11 15:35:18 +00:00
|
|
|
MathIterator iend(MathInset * p);
|
2001-12-05 17:50:18 +00:00
|
|
|
|
|
|
|
#endif
|