]> git.lyx.org Git - lyx.git/blob - src/texrow.h
hopefully fix tex2lyx linking.
[lyx.git] / src / texrow.h
1 // -*- C++ -*-
2 /**
3  * \file texrow.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Matthias Ettrich
8  * \author Lars Gullik Bjønnes
9  * \author John Levon
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef TEXROW_H
15 #define TEXROW_H
16
17 #include <list>
18
19
20 namespace lyx {
21
22
23 /// Represents the correspondence between paragraphs and the generated LaTeX file
24 class TexRow {
25 public:
26         ///
27         TexRow() : count(0), lastid(-1), lastpos(-1) {}
28
29         TexRow & operator+= (TexRow const &);
30
31         /// Clears structure
32         void reset();
33
34         /// Define what paragraph and position the next row will represent
35         void start(int id, int pos);
36
37         /// Insert node when line is completed
38         void newline();
39
40         /**
41          * getIdFromRow - find pid and position for a given row
42          * @param row row number to find
43          * @param id set to id if found
44          * @param pos set to paragraph position if found
45          * @return true if found, false otherwise
46          *
47          * If the row could not be found, pos is set to zero and
48          * id is set to -1
49          */
50         bool getIdFromRow(int row, int & id, int & pos) const;
51
52         /// Returns the number of rows contained
53         int rows() const { return count; }
54
55         /// an individual id/pos <=> row mapping
56         class RowItem {
57         public:
58                 RowItem(int id, int pos, int row)
59                         : id_(id), pos_(pos), rownumber_(row)
60                 {}
61
62                 /// paragraph id
63                 int id() const {
64                         return id_;
65                 }
66
67                 /// set paragraph position
68                 void pos(int p) {
69                         pos_ = p;
70                 }
71
72                 /// paragraph position
73                 int pos() const {
74                         return pos_;
75                 }
76
77                 /// row number
78                 int rownumber() const {
79                         return rownumber_;
80                 }
81         private:
82                 int id_;
83                 int pos_;
84                 int rownumber_;
85         };
86         ///
87         typedef std::list<RowItem> RowList;
88 private:
89         /// number of lines
90         unsigned int count;
91         /// container of id/pos <=> row mapping
92         RowList rowlist;
93         /// Last paragraph
94         int lastid;
95         /// Last position
96         int lastpos;
97 };
98
99
100 } // namespace lyx
101
102 #endif // TEXROW_H