]> git.lyx.org Git - lyx.git/blob - src/iterators.h
add PosIterator
[lyx.git] / src / iterators.h
1 // -*- C++ -*-
2 /* \file iterators.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 ITERATORS_H
13 #define ITERATORS_H
14
15 #include "ParagraphList_fwd.h"
16 #include "support/types.h"
17
18 #include <boost/scoped_ptr.hpp>
19
20 class LyXText;
21 class InsetOld;
22 class Cursor;
23 class PosIterator;
24
25
26 class ParIterator {
27 public:
28         ///
29         ParIterator(ParagraphList::iterator pit, ParagraphList const & pl);
30         ///
31         ~ParIterator();
32         ///
33         ParIterator(ParIterator const &);
34         ///
35         void operator=(ParIterator const &);
36         ///
37         ParIterator & operator++();
38         ///
39         Paragraph & operator*() const;
40         ///
41         ParagraphList::iterator operator->() const;
42         /// This gives us the top-most parent paragraph
43         ParagraphList::iterator outerPar() const;
44         ///
45         ParagraphList::iterator pit() const;
46         ///
47         ParagraphList & plist() const;
48         /// returns 'innermost' LyXText if in an inset or '0' instead of
49         //bv->text
50         LyXText * text() const;
51         /// returns innermost inset
52         InsetOld * inset() const;
53         /// returns index of cell in innermost inset
54         int index() const;
55         ///
56         size_t size() const;
57         ///
58         void asCursor(Cursor & cursor) const;
59         ///
60         friend
61         bool operator==(ParIterator const & iter1, ParIterator const & iter2);
62
63         ///
64         PosIterator asPosIterator(lyx::pos_type) const;
65 private:
66         struct Pimpl;
67         boost::scoped_ptr<Pimpl> pimpl_;
68 };
69
70 ///
71 bool operator==(ParIterator const & iter1, ParIterator const & iter2);
72
73 ///
74 bool operator!=(ParIterator const & iter1, ParIterator const & iter2);
75
76
77 class ParConstIterator {
78 public:
79         ///
80         ParConstIterator(ParagraphList::iterator pit, ParagraphList const & pl);
81         ///
82         ~ParConstIterator();
83         ///
84         ParConstIterator(ParConstIterator const &);
85         ///
86         ParConstIterator & operator++();
87         ///
88         ParagraphList::const_iterator pit() const;
89         ///
90         Paragraph const & operator*() const;
91         ///
92         ParagraphList::const_iterator operator->() const;
93         ///
94         ParagraphList const & plist() const;
95
96         /// depth of nesting
97         size_t size() const;
98         ///
99         friend
100         bool operator==(ParConstIterator const & iter1,
101                         ParConstIterator const & iter2);
102
103 private:
104         struct Pimpl;
105         boost::scoped_ptr<Pimpl> pimpl_;
106 };
107
108 bool operator==(ParConstIterator const & iter1,
109                 ParConstIterator const & iter2);
110
111 bool operator!=(ParConstIterator const & iter1,
112                 ParConstIterator const & iter2);
113
114 #endif