Another minor change, but this should almost get us to the point that we
[lyx.git] / src / ParIterator.h
blob320493dac0832910b8f26eda8bf0874114cfbe99
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.
6 * \author unknown
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
12 #ifndef PARITERATOR_H
13 #define PARITERATOR_H
15 #include "DocIterator.h"
17 #include "support/types.h"
19 #include <vector>
22 namespace lyx {
24 class Buffer;
25 class Inset;
26 class Text;
27 class ParagraphList;
30 class ParIterator : public std::iterator<std::forward_iterator_tag, Paragraph>,
31 public DocIterator
33 public:
34 typedef std::iterator<std::forward_iterator_tag, Paragraph> StdIt;
36 typedef StdIt::value_type value_type;
37 typedef StdIt::difference_type difference_type;
38 typedef StdIt::pointer pointer;
39 typedef StdIt::reference reference;
41 ///
42 ///
43 ParIterator(Buffer * buf) : DocIterator(buf) {}
45 ///
46 ParIterator(Buffer * buf, Inset &, pit_type pit);
47 ///
48 ParIterator(ParIterator const &);
49 ///
50 explicit ParIterator(DocIterator const &);
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(); }
72 ParagraphList & plist() const;
76 ParIterator par_iterator_begin(Inset & inset);
78 ParIterator par_iterator_end(Inset & inset);
81 ///
82 //bool operator==(ParIterator const & it1, ParIterator const & it2);
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);
93 class ParConstIterator : public std::iterator<std::forward_iterator_tag,
94 Paragraph>,
95 public DocIterator
97 public:
98 ///
99 ParConstIterator(Buffer const * buf);
101 ParConstIterator(ParConstIterator const &);
103 explicit ParConstIterator(DocIterator const &);
105 void push_back(Inset const &);
107 ParConstIterator & operator++();
109 ParConstIterator & operator--();
111 Paragraph const & operator*() const;
113 Paragraph const * operator->() const;
115 ParagraphList const & plist() const;
118 //bool operator==(ParConstIterator const & it1, ParConstIterator const & it2);
120 //bool operator!=(ParConstIterator const & it1, ParConstIterator const & it2);
123 } // namespace lyx
125 #endif