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