\end_document replaces \the_end.
[lyx.git] / src / texrow.C
blobb2a883aae6ba3d5710c1bae80fcf2941d84b04dc
1 /**
2  * \file texrow.C
3  * Copyright 1995-2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Matthias Ettrich
7  */
9 #include <config.h>
11 #include "texrow.h"
12 #include "debug.h"
14 #include <algorithm>
16 using std::find_if;
17 using std::endl;
19 namespace {
21 /// function object returning true when row number is found
22 class same_rownumber {
23 public:
24         same_rownumber(int row) : row_(row) {}
25         bool operator()(TexRow::RowList::value_type const & vt) const {
26                 return vt.rownumber() == row_;
27         }
29 private:
30         int row_;
33 } // namespace anon
36 void TexRow::reset()
38         rowlist.clear();
39         count = 0;
40         lastid = -1;
41         lastpos = -1;
45 void TexRow::start(int id, int pos)
47         lastid = id;
48         lastpos = pos;
52 void TexRow::newline()
54         int const id = lastid;
55         RowList::value_type tmp(id, lastpos, ++count);
56         rowlist.push_back(tmp);
60 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
62         RowList::const_iterator cit =
63                 find_if(rowlist.begin(), rowlist.end(),
64                         same_rownumber(row));
66         if (cit != rowlist.end()) {
67                 id = cit->id();
68                 pos = cit->pos();
69                 return true;
70         }
71         id = -1;
72         pos = 0;
73         return false;
77 TexRow & TexRow::operator+=(TexRow const & tr)
79         rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());
80         return *this;