]> git.lyx.org Git - lyx.git/blob - src/TexRow.cpp
Fixed some lines that were too long. It compiled afterwards.
[lyx.git] / src / TexRow.cpp
1 /**
2  * \file TexRow.cpp
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 #include <algorithm>
19
20
21 namespace lyx {
22
23 using std::find_if;
24
25
26 namespace {
27
28 /// function object returning true when row number is found
29 class same_rownumber {
30 public:
31         same_rownumber(int row) : row_(row) {}
32         bool operator()(TexRow::RowList::value_type const & vt) const {
33                 return vt.rownumber() == row_;
34         }
35
36 private:
37         int row_;
38 };
39
40 } // namespace anon
41
42
43 void TexRow::reset()
44 {
45         rowlist.clear();
46         count = 0;
47         lastid = -1;
48         lastpos = -1;
49 }
50
51
52 void TexRow::start(int id, int pos)
53 {
54         lastid = id;
55         lastpos = pos;
56 }
57
58
59 void TexRow::newline()
60 {
61         int const id = lastid;
62         RowList::value_type tmp(id, lastpos, ++count);
63         rowlist.push_back(tmp);
64 }
65
66
67 bool TexRow::getIdFromRow(int row, int & id, int & pos) const
68 {
69         RowList::const_iterator cit =
70                 find_if(rowlist.begin(), rowlist.end(),
71                         same_rownumber(row));
72
73         if (cit != rowlist.end()) {
74                 id = cit->id();
75                 pos = cit->pos();
76                 return true;
77         }
78         id = -1;
79         pos = 0;
80         return false;
81 }
82
83
84 TexRow & TexRow::operator+=(TexRow const & tr)
85 {
86         rowlist.insert(rowlist.end(), tr.rowlist.begin(), tr.rowlist.end());
87         return *this;
88 }
89
90
91 } // namespace lyx