]> git.lyx.org Git - lyx.git/blob - src/ParIterator.h
Fix some issues with textmode. We'll let SetMode() handle as much of
[lyx.git] / src / ParIterator.h
1 // -*- C++ -*-
2 /* \file ParIterator.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author unknown
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef PARITERATOR_H
13 #define PARITERATOR_H
14
15 #include "DocIterator.h"
16
17 #include "support/types.h"
18
19 #include <vector>
20
21
22 namespace lyx {
23
24 class Buffer;
25 class Inset;
26 class Text;
27 class ParagraphList;
28
29
30 class ParIterator : public std::iterator<std::forward_iterator_tag, Paragraph>,
31                     public DocIterator
32 {
33 public:
34         typedef std::iterator<std::forward_iterator_tag, Paragraph> StdIt;
35
36         typedef StdIt::value_type value_type;
37         typedef StdIt::difference_type difference_type;
38         typedef StdIt::pointer pointer;
39         typedef StdIt::reference reference;
40
41         ///
42         ///
43         ParIterator(Buffer * buf) : DocIterator(buf) {}
44
45         ///
46         ParIterator(Buffer * buf, Inset &, pit_type pit);
47         ///
48         ParIterator(ParIterator const &);
49         ///
50         explicit ParIterator(DocIterator const &);
51
52         /// This really should be implemented...
53         //ParIterator & operator=(ParIterator const &);
54         ///
55         ParIterator & operator++();
56         ///
57         ParIterator operator++(int);
58         /// See comment in ParIterator.cpp
59         //ParIterator & operator--();
60         ///
61         Paragraph & operator*() const;
62         ///
63         Paragraph * operator->() const;
64         /// This gives us the top-most parent paragraph
65         pit_type outerPar() const;
66         ///
67         pit_type pit() const;
68         ///
69         /// return the paragraph this cursor is in
70         pit_type & pit() { return DocIterator::pit(); }
71
72         ParagraphList & plist() const;
73 };
74
75
76 ParIterator par_iterator_begin(Inset & inset);
77
78 ParIterator par_iterator_end(Inset & inset);
79
80
81 ///
82 //bool operator==(ParIterator const & it1, ParIterator const & it2);
83
84 // FIXME: Unfortunately operator!=(ParIterator &, ParIterator &) is
85 // implemented with operator!=(DocIterator &, DocIterator &) that gives
86 // false if the positions are different, even if the pars are the same.
87 // So ultimately it's a bug in operator!=(ParIterator &, ParIterator &)
88 // I'd say (nevertheless, I would be reluctant to change it, because I
89 // fear that some part of the code could rely on this "bug". --Alfredo
90 //bool operator!=(ParIterator const & it1, ParIterator const & it2);
91
92
93 class ParConstIterator : public std::iterator<std::forward_iterator_tag,
94                          Paragraph>,
95                          public DocIterator
96 {
97 public:
98         ///
99         ParConstIterator(Buffer const * buf);
100         ///
101         ParConstIterator(ParConstIterator const &);
102         ///
103         explicit ParConstIterator(DocIterator const &);
104         ///
105         void push_back(Inset const &);
106
107         ParConstIterator & operator++();
108         ///
109         ParConstIterator & operator--();
110         ///
111         Paragraph const & operator*() const;
112         ///
113         Paragraph const * operator->() const;
114         ///
115         ParagraphList const & plist() const;
116 };
117
118 //bool operator==(ParConstIterator const & it1, ParConstIterator const & it2);
119
120 //bool operator!=(ParConstIterator const & it1, ParConstIterator const & it2);
121
122
123 } // namespace lyx
124
125 #endif