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
|
|
|
|
|
2002-09-11 09:14:57 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2002-07-26 14:11:19 +00:00
|
|
|
#include "math_pos.h"
|
|
|
|
#include <vector>
|
2001-12-05 17:50:18 +00:00
|
|
|
|
2002-07-26 14:11:19 +00:00
|
|
|
// this is used for traversing math insets
|
2001-12-05 17:50:18 +00:00
|
|
|
|
2002-07-26 14:11:19 +00:00
|
|
|
class MathIterator : private std::vector<MathCursorPos> {
|
2001-12-05 17:50:18 +00:00
|
|
|
public:
|
2002-07-26 14:11:19 +00:00
|
|
|
// re-use inherited stuff
|
|
|
|
typedef std::vector<MathCursorPos> base_type;
|
|
|
|
using base_type::clear;
|
|
|
|
using base_type::size;
|
|
|
|
using base_type::push_back;
|
|
|
|
using base_type::pop_back;
|
|
|
|
using base_type::back;
|
|
|
|
using base_type::begin;
|
|
|
|
using base_type::end;
|
2002-08-13 17:43:40 +00:00
|
|
|
using base_type::erase;
|
2002-07-26 14:11:19 +00:00
|
|
|
using base_type::operator[];
|
|
|
|
using base_type::size_type;
|
|
|
|
using base_type::difference_type;
|
|
|
|
using base_type::const_iterator;
|
|
|
|
friend bool operator!=(MathIterator const &, MathIterator const &);
|
|
|
|
friend bool operator==(MathIterator const &, MathIterator const &);
|
|
|
|
|
|
|
|
/// default constructor
|
|
|
|
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
|
|
|
///
|
|
|
|
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-07-26 14:11:19 +00:00
|
|
|
void jump(difference_type);
|
2001-12-05 17:50:18 +00:00
|
|
|
/// 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-11-06 11:13:56 +00:00
|
|
|
/// is this a non-end position
|
|
|
|
bool normal() const;
|
2002-08-13 17:43:40 +00:00
|
|
|
/// shrinks to at most i levels
|
|
|
|
void shrink(size_type i);
|
2002-01-03 09:41:26 +00:00
|
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
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
|