Another minor change, but this should almost get us to the point that we
[lyx.git] / src / InsetList.h
blobdcaa28eabce6ee073c00367b53032406c12e51be
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.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
12 #ifndef INSET_LIST_H
13 #define INSET_LIST_H
15 #include "insets/InsetCode.h"
17 #include "support/types.h"
19 #include <vector>
22 namespace lyx {
24 class Inset;
25 class Buffer;
27 ///
28 class InsetList {
29 public:
30 ///
31 InsetList() {}
32 ///
33 InsetList(InsetList const &);
34 /// Partial copy constructor.
35 /// Copy the InsetList contents from \p beg to \p end (without end).
36 InsetList(InsetList const &, pos_type beg, pos_type end);
37 ///
38 void setBuffer(Buffer &);
40 ///
41 class InsetTable {
42 public:
43 ///
44 InsetTable(pos_type p, Inset * i) : pos(p), inset(i) {}
45 ///
46 pos_type pos;
47 ///
48 Inset * inset;
50 ///
51 typedef std::vector<InsetTable> List;
52 ///
53 typedef List::iterator iterator;
54 ///
55 typedef List::const_iterator const_iterator;
57 ///
58 ~InsetList();
59 ///
60 iterator begin() { return list_.begin(); }
61 ///
62 iterator end() { return list_.end(); }
63 ///
64 const_iterator begin() const { return list_.begin(); }
65 ///
66 const_iterator end() const { return list_.end(); }
67 ///
68 bool empty() const { return list_.empty(); }
69 ///
70 iterator insetIterator(pos_type pos);
71 ///
72 const_iterator insetIterator(pos_type pos) const;
73 ///
74 void insert(Inset * inset, pos_type pos);
75 ///
76 void erase(pos_type pos);
77 ///
78 Inset * release(pos_type);
79 ///
80 Inset * get(pos_type pos) const;
81 ///
82 void increasePosAfterPos(pos_type pos);
83 ///
84 void decreasePosAfterPos(pos_type pos);
86 /// search for next occurence of an \c Inset type.
87 /// \return the position of the found inset.
88 /// \retval -1 if no \c Inset is found.
89 pos_type find(
90 InsetCode code, ///< Code of inset to find.
91 pos_type startpos = 0 ///< start position for the search.
92 ) const;
94 /// count occurences of of an \c Inset type.
95 /// \return the number of found inset(s).
96 int count(
97 InsetCode code, ///< Code of inset type to count.
98 pos_type startpos = 0 ///< start position for the counting.
99 ) const;
101 private:
103 List list_;
107 } // namespace lyx
109 #endif