]> git.lyx.org Git - lyx.git/blob - src/ParIterator.h
Move <QTimer> from TocWidget.h
[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
20 namespace lyx {
21
22 class Buffer;
23 class Inset;
24 class ParagraphList;
25
26
27 class ParIterator : public std::iterator<std::forward_iterator_tag, Paragraph>,
28                     public DocIterator
29 {
30 public:
31         typedef std::iterator<std::forward_iterator_tag, Paragraph> StdIt;
32
33         typedef StdIt::value_type value_type;
34         typedef StdIt::difference_type difference_type;
35         typedef StdIt::pointer pointer;
36         typedef StdIt::reference reference;
37
38         ///
39         ///
40         ParIterator(Buffer * buf) : DocIterator(buf) {}
41
42         ///
43         ParIterator(Buffer * buf, Inset &, pit_type pit);
44         ///
45         ParIterator(ParIterator const &);
46         ///
47         explicit ParIterator(DocIterator const &);
48
49         /// This really should be implemented...
50         //ParIterator & operator=(ParIterator const &);
51         ///
52         ParIterator & operator++();
53         ///
54         ParIterator operator++(int);
55         /// See comment in ParIterator.cpp
56         //ParIterator & operator--();
57         ///
58         Paragraph & operator*() const;
59         ///
60         Paragraph * operator->() const;
61         /// This gives us the top-most parent paragraph
62         pit_type outerPar() const;
63         ///
64         pit_type pit() const;
65         ///
66         /// return the paragraph this cursor is in
67         pit_type & pit() { return DocIterator::pit(); }
68
69         ParagraphList & plist() const;
70 };
71
72
73 ParIterator par_iterator_begin(Inset & inset);
74
75 ParIterator par_iterator_end(Inset & inset);
76
77
78 ///
79 //bool operator==(ParIterator const & it1, ParIterator const & it2);
80
81 // FIXME: Unfortunately operator!=(ParIterator &, ParIterator &) is
82 // implemented with operator!=(DocIterator &, DocIterator &) that gives
83 // false if the positions are different, even if the pars are the same.
84 // So ultimately it's a bug in operator!=(ParIterator &, ParIterator &)
85 // I'd say (nevertheless, I would be reluctant to change it, because I
86 // fear that some part of the code could rely on this "bug". --Alfredo
87 //bool operator!=(ParIterator const & it1, ParIterator const & it2);
88
89
90 class ParConstIterator : public std::iterator<std::forward_iterator_tag,
91                          Paragraph>,
92                          public DocIterator
93 {
94 public:
95         ///
96         ParConstIterator(Buffer const * buf);
97         ///
98         ParConstIterator(ParConstIterator const &);
99         ///
100         explicit ParConstIterator(DocIterator const &);
101         ///
102         void push_back(Inset const &);
103
104         ParConstIterator & operator++();
105         ///
106         ParConstIterator & operator--();
107         ///
108         Paragraph const & operator*() const;
109         ///
110         Paragraph const * operator->() const;
111         ///
112         ParagraphList const & plist() const;
113 };
114
115 //bool operator==(ParConstIterator const & it1, ParConstIterator const & it2);
116
117 //bool operator!=(ParConstIterator const & it1, ParConstIterator const & it2);
118
119
120 } // namespace lyx
121
122 #endif