]> git.lyx.org Git - lyx.git/blob - src/InsetList.h
Hebrew translation updates by Ran
[lyx.git] / src / InsetList.h
1 // -*- C++ -*-
2 /**
3  * \file InsetList.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_LIST_H
13 #define INSET_LIST_H
14
15 #include "insets/InsetCode.h"
16
17 #include "support/types.h"
18
19 #include <vector>
20
21
22 namespace lyx {
23
24 class Inset;
25 class Buffer;
26
27 ///
28 class InsetList {
29 public:
30         ///
31         InsetList() {}
32         ///
33         InsetList(InsetList const &);
34         ///
35         void setBuffer(Buffer &);
36
37         ///
38         class InsetTable {
39         public:
40                 ///
41                 InsetTable(pos_type p, Inset * i) : pos(p), inset(i) {}
42                 ///
43                 pos_type pos;
44                 ///
45                 Inset * inset;
46         };
47         ///
48         typedef std::vector<InsetTable> List;
49         ///
50         typedef List::iterator iterator;
51         ///
52         typedef List::const_iterator const_iterator;
53
54         ///
55         ~InsetList();
56         ///
57         iterator begin() { return list_.begin(); }
58         ///
59         iterator end() { return list_.end(); }
60         ///
61         const_iterator begin() const { return list_.begin(); }
62         ///
63         const_iterator end() const { return list_.end(); }
64         ///
65         bool empty() const { return list_.empty(); }
66         ///
67         iterator insetIterator(pos_type pos);
68         ///
69         const_iterator insetIterator(pos_type pos) const;
70         ///
71         void insert(Inset * inset, pos_type pos);
72         ///
73         void erase(pos_type pos);
74         ///
75         Inset * release(pos_type);
76         ///
77         Inset * get(pos_type pos) const;
78         ///
79         void increasePosAfterPos(pos_type pos);
80         ///
81         void decreasePosAfterPos(pos_type pos);
82
83         /// search for next occurence of an \c Inset type.
84         /// \return the position of the found inset.
85         /// \retval -1 if no \c Inset is found.
86         pos_type find(
87                 InsetCode code, ///< Code of inset to find.
88                 pos_type startpos = 0 ///< start position for the search.
89                 ) const;
90
91         /// count occurences of of an \c Inset type.
92         /// \return the number of found inset(s).
93         int count(
94                 InsetCode code, ///< Code of inset type to count.
95                 pos_type startpos = 0 ///< start position for the counting.
96                 ) const;
97
98 private:
99         ///
100         List list_;
101 };
102
103
104 } // namespace lyx
105
106 #endif