#define MATH_ROWST_H
#include <vector>
+#include "support/LAssert.h"
/** The physical structure of a row and aditional information is stored here.
It allows to manage the extra info independently of the paragraph data.
///
struct iterator {
///
- iterator(MathedRowContainer * m) : st_(m->data_) {}
+ iterator() : st_(0) {}
+ ///
+ explicit iterator(MathedRowSt * st) : st_(st) {}
+ /// "better" conversion to bool
+ explicit iterator(MathedRowContainer * m) : st_(m->data_) {}
/// "better" conversion to bool
operator void *() const { return st_; }
///
- MathedRowStruct & operator*() { return *st_; }
+ MathedRowStruct & operator*() { Assert(st_); return *st_; }
///
MathedRowStruct * operator->() { return st_; }
///
- void operator++() { st_ = st_->next_; }
+ MathedRowStruct const * operator->() const { return st_; }
+ ///
+ void operator++() { Assert(st_); st_ = st_->next_; }
///
- bool is_last() const { return st_->next_ == 0; }
+ bool is_last() const { Assert(st_); return st_->next_ == 0; }
///
bool operator==(const iterator & it) const { return st_ == it.st_; }
- private:
+ //private:
///
MathedRowSt * st_;
};
MathedXIter::MathedXIter()
: MathedIter(), size_(0), x_(0), y_(0), p_(0), sx_(0), sw_(0),
- crow_(0)
+ crow_()
{
// should limits_ be initialized?
}
MathedXIter::MathedXIter(MathParInset * pp)
- : x_(0), y_(0), p_(pp), sx_(0), sw_(0), limits_(false)
+ : x_(0), y_(0), p_(pp), sx_(0), sw_(0), limits_(false), crow_()
{
if (p_)
SetData(p_);
else {
- crow_ = 0;
size_ = 0;
}
}
}
if (IsCR()) {
if (crow_) {
- MathedRowSt * r = crow_->getNext();
+ MathedRowContainer::iterator r = crow_;
+ ++r;
if (r) {
- crow_->setNext(r->getNext());
- delete r;
+ crow_.st_->setNext(r.st_->getNext());
+ delete r.st_;
}
}
}
while (pos < pos2 && OK()) {
if (IsCR()) {
if (p_ && p_->Permit(LMPF_ALLOW_CR)) {
- MathedRowSt * r = new MathedRowSt(ncols + 1);
+ MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
if (crow_) {
- r->setNext(crow_->getNext());
- crow_->setNext(r);
+ r.st_->setNext(crow_.st_->getNext());
+ crow_.st_->setNext(r.st_);
} else {
- r->setNext(0);
+ r.st_->setNext(0);
}
crow_ = r;
} else {
x_ = y_ = 0;
array = &p_->GetData();
ncols = p_->GetColumns();
- crow_ = p_->getRowSt().data_;
+ crow_ = p_->getRowSt().begin();
if (p_->Permit(LMPF_ALLOW_CR))
flags |= MthIF_CR;
if (p_->Permit(LMPF_ALLOW_TAB))
} else
if (c == LM_TC_CR && p_) {
x_ = 0;
- if (crow_ && crow_->getNext()) {
- crow_ = crow_->getNext();
+ if (crow_ && crow_.st_->getNext()) {
+ ++crow_;
y_ = crow_->getBaseline();
w = crow_->getTab(0);
}
x_ = y_ = 0;
sw_ = sx_ = 0;
if (p_) {
- crow_ = p_->getRowSt().data_;
+ crow_ = p_->getRowSt().begin();
if (crow_) {
x_ = crow_->getTab(0);
y_ = crow_->getBaseline();
return;
}
// Create new item for the structure
- MathedRowSt * r = new MathedRowSt(ncols + 1);
+ MathedRowContainer::iterator r( new MathedRowSt(ncols + 1) );
if (crow_) {
- r->setNext(crow_->getNext());
- crow_->setNext(r);
+ r.st_->setNext(crow_.st_->getNext());
+ crow_.st_->setNext(r.st_);
} else {
crow_ = r;
- r->setNext(0);
+ r.st_->setNext(0);
}
// Fill missed tabs in current row
while (col < ncols - 1)
if (line_empty) {
- MathedRowSt * r = crow_->getNext();
+ MathedRowContainer::iterator r( crow_.st_->getNext() );
if (r) {
- crow_->setNext(r->getNext());
- delete r;
+ crow_.st_->setNext(r.st_->getNext());
+ delete r.st_;
}
join(p1);
Delete();
x_ = stck.x;
y_ = stck.y;
if (p_) {
- crow_ = p_->getRowSt().data_;
+ crow_ = p_->getRowSt().begin();
if (crow_)
for (int i = 0; i < row; ++i)
- crow_ = crow_->getNext();
+ ++crow_;
}
}
GoBegin();
if (!crow_) {
// lyxerr << " CRW" << ncols << " ";
- crow_ = new MathedRowSt(ncols + 1); // this leaks
+ crow_.st_ = new MathedRowSt(ncols + 1); // this leaks
}
// lyxerr<< " CRW[" << crow_ << "] ";
- MathedRowSt * mrow = crow_;
+ MathedRowSt * mrow = crow_.st_;
while (OK()) {
if (IsCR()) {
if (col >= ncols) ncols = col + 1;
MathedRowSt * r = new MathedRowSt(ncols + 1); // this leaks
// r->next = crow_->next;
- crow_->setNext(r);
- crow_ = r;
+ crow_.st_->setNext(r);
+ crow_.st_ = r;
// lyxerr << " CX[" << crow_ << "]";
}
Next();