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