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