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