]> git.lyx.org Git - lyx.git/blob - src/ParIterator.h
Disable direct insertion of multiple spaces in mathed text
[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 Paragraph;
25 class ParagraphList;
26
27
28 class ParIterator : public std::iterator<std::forward_iterator_tag, Paragraph>,
29                     public DocIterator
30 {
31 public:
32         typedef std::iterator<std::forward_iterator_tag, Paragraph> StdIt;
33
34         typedef StdIt::value_type value_type;
35         typedef StdIt::difference_type difference_type;
36         typedef StdIt::pointer pointer;
37         typedef StdIt::reference reference;
38
39         ///
40         ///
41         ParIterator(Buffer * buf) : DocIterator(buf) {}
42         ///
43         ParIterator(ParIterator const & pi) :
44                 DocIterator(DocIterator(pi)) {}
45         ///
46         explicit ParIterator(DocIterator const & dit) :
47                 DocIterator(dit) {}
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                 : DocIterator(const_cast<Buffer *>(buf)) {}
98         ///
99         ParConstIterator(ParConstIterator const & pi)
100                 : DocIterator(DocIterator(pi)) {}
101         ///
102         explicit ParConstIterator(DocIterator const & dit)
103                 : DocIterator(dit) {}
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