]> git.lyx.org Git - lyx.git/blob - src/texrow.C
Strip 320 #includes from the files in src.
[lyx.git] / src / texrow.C
1 /**
2  * \file texrow.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Matthias Ettrich
7  * \author Lars Gullik Bjønnes
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "texrow.h"
16 #include "debug.h"
17
18
19 using std::find_if;
20 using std::endl;
21
22 namespace {
23
24 /// function object returning true when row number is found
25 class same_rownumber {
26 public:
27         same_rownumber(int row) : row_(row) {}
28         bool operator()(TexRow::RowList::value_type const & vt) const {
29                 return vt.rownumber() == row_;
30         }
31
32 private:
33         int row_;
34 };
35
36 } // namespace anon
37
38
39 void TexRow::reset()
40 {
41         rowlist.clear();
42         count = 0;
43         lastid = -1;
44         lastpos = -1;
45 }
46
47
48 void TexRow::start(int id, int pos)
49 {
50         lastid = id;
51         lastpos = pos;
52 }
53
54
55 void TexRow::newline()
56 {
57         int const id = lastid;
58         RowList::value_type tmp(id, lastpos, ++count);
59         rowlist.push_back(tmp);
60 }
61
62
63 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
64 {
65         RowList::const_iterator cit =
66                 find_if(rowlist.begin(), rowlist.end(),
67                         same_rownumber(row));
68
69         if (cit != rowlist.end()) {
70                 id = cit->id();
71                 pos = cit->pos();
72                 return true;
73         }
74         id = -1;
75         pos = 0;
76         return false;
77 }
78
79
80 TexRow & TexRow::operator+=(TexRow const & tr)
81 {
82         rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());
83         return *this;
84 }