]> git.lyx.org Git - lyx.git/blob - src/iterators.h
add lockPath and a few helpers
[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() 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         void asCursor(Cursor & cursor) 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