]> git.lyx.org Git - lyx.git/blob - src/ParIterator.cpp
cosmetics
[lyx.git] / src / ParIterator.cpp
1 /* \file ParIterator.cpp
2  * This file is part of LyX, the document processor.
3  * Licence details can be found in the file COPYING.
4  *
5  * \author unknown
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "ParIterator.h"
14
15 #include "Paragraph.h"
16 #include "Text.h"
17
18 #include "insets/Inset.h"
19
20
21 namespace lyx {
22
23 ///
24 /// ParIterator
25 ///
26
27 ParIterator::ParIterator(DocIterator const & cur)
28         : DocIterator(cur)
29 {}
30
31
32 ParIterator par_iterator_begin(Inset & inset)
33 {
34         return ParIterator(doc_iterator_begin(inset));
35 }
36
37
38 ParIterator par_iterator_end(Inset & inset)
39 {
40         return ParIterator(doc_iterator_end(inset));
41 }
42
43
44 ParIterator::ParIterator(ParIterator const & pi)
45         : DocIterator(DocIterator(pi))
46 {}
47
48
49 ParIterator & ParIterator::operator++()
50 {
51         forwardPar();
52         return *this;
53 }
54
55
56 ParIterator ParIterator::operator++(int)
57 {
58         ParIterator tmp(*this);
59         forwardPar();
60         return tmp;
61 }
62
63
64 #if 0
65 // Unused member functions. Also having this makes ParIterator not be
66 // an forward iterator anymore. So unless we change that, this function
67 // should not be compiled/used. (Lgb)
68 ParIterator & ParIterator::operator--()
69 {
70         // FIXME: look here
71 //      DocIterator::backwardPar();
72         return *this;
73 }
74 #endif
75
76
77 Paragraph & ParIterator::operator*() const
78 {
79         return const_cast<Paragraph&>(text()->getPar(pit()));
80 }
81
82
83 pit_type ParIterator::pit() const
84 {
85         return DocIterator::pit();
86 }
87
88
89 Paragraph * ParIterator::operator->() const
90 {
91         return const_cast<Paragraph*>(&text()->getPar(pit()));
92 }
93
94
95 pit_type ParIterator::outerPar() const
96 {
97         return bottom().pit();
98 }
99
100
101 ParagraphList & ParIterator::plist() const
102 {
103         return const_cast<ParagraphList&>(text()->paragraphs());
104 }
105
106
107 ///
108 /// ParConstIterator
109 ///
110
111
112 ParConstIterator::ParConstIterator(DocIterator const & dit)
113         : DocIterator(dit)
114 {}
115
116
117 ParConstIterator::ParConstIterator(ParConstIterator const & pi)
118         : DocIterator(DocIterator(pi))
119 {}
120
121
122 void ParConstIterator::push_back(Inset const & inset)
123 {
124         DocIterator::push_back(CursorSlice(const_cast<Inset &>(inset)));
125 }
126
127
128 ParConstIterator & ParConstIterator::operator++()
129 {
130         DocIterator::forwardPar();
131         return *this;
132 }
133
134
135 Paragraph const & ParConstIterator::operator*() const
136 {
137         return text()->getPar(pit());
138 }
139
140
141 Paragraph const * ParConstIterator::operator->() const
142 {
143         return &text()->getPar(pit());
144 }
145
146
147 ParagraphList const & ParConstIterator::plist() const
148 {
149         return text()->paragraphs();
150 }
151
152 #if 0
153 bool operator==(ParConstIterator const & iter1, ParConstIterator const & iter2)
154 {
155         // FIXME: this makes two full copies!
156         return DocIterator(iter1) == DocIterator(iter2);
157 }
158
159
160 bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
161 {
162         return !(iter1 == iter2);
163 }
164 #endif
165
166
167 // FIXME: const correctness!
168
169 ParConstIterator par_const_iterator_begin(Inset const & inset)
170 {
171         return ParConstIterator(doc_iterator_begin(const_cast<Inset &>(inset)));
172 }
173
174
175 ParConstIterator par_const_iterator_end(Inset const & inset)
176 {
177         return ParConstIterator(doc_iterator_end(const_cast<Inset &>(inset)));
178 }
179
180
181 } // namespace lyx