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