X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FInsetList.h;h=708eab86fa0377ca7bd56e6bfc10ebfb820594c3;hb=801d7dc9f42baf331642606a6641606779985439;hp=30dfea3fc4c670fef393aa23080344f1cd54d165;hpb=260c7f3187a7dd392888b1d1eea513abffd8f2f7;p=lyx.git diff --git a/src/InsetList.h b/src/InsetList.h index 30dfea3fc4..708eab86fa 100644 --- a/src/InsetList.h +++ b/src/InsetList.h @@ -1,91 +1,111 @@ // -*- C++ -*- +/** + * \file InsetList.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Lars Gullik Bjønnes + * + * Full author contact details are available in file CREDITS. + */ #ifndef INSET_LIST_H #define INSET_LIST_H +#include "insets/InsetCode.h" + #include "support/types.h" +#include -class Inset; -class BufferView; +namespace lyx { + +class Inset; +class Buffer; /// class InsetList { public: /// - struct InsetTable { - /// - lyx::pos_type pos; - /// - Inset * inset; - /// - InsetTable(lyx::pos_type p, Inset * i) : pos(p), inset(i) {} - }; + InsetList() {} + /// + InsetList(InsetList const &); + /// Partial copy constructor. + /// Copy the InsetList contents from \p beg to \p end (without end). + InsetList(InsetList const &, pos_type beg, pos_type end); + /// + void setBuffer(Buffer &); /// - typedef std::vector List; + void resetBuffer(); /// - class iterator { + class Element { public: /// - iterator() {} - // - iterator(List::iterator const & iter); - /// - iterator & operator++(); - /// - iterator operator++(int); - /// - lyx::pos_type getPos() const; + Element(pos_type p, Inset * i) : pos(p), inset(i) {} /// - Inset * getInset() const; + pos_type pos; /// - void setInset(Inset * inset); - /// - friend bool operator==(iterator const &, iterator const &); - private: - /// - List::iterator it; + Inset * inset; }; + /// + typedef std::vector List; + /// + typedef List::iterator iterator; + /// + typedef List::const_iterator const_iterator; + /// ~InsetList(); /// - iterator begin(); + iterator begin() { return list_.begin(); } /// - iterator end(); + iterator end() { return list_.end(); } /// - iterator begin() const; + const_iterator begin() const { return list_.begin(); } /// - iterator end() const; + const_iterator end() const { return list_.end(); } /// - iterator insetIterator(lyx::pos_type pos); + bool empty() const { return list_.empty(); } /// - void insert(Inset * inset, lyx::pos_type pos); + iterator insetIterator(pos_type pos); /// - void erase(lyx::pos_type pos); + const_iterator insetIterator(pos_type pos) const; /// - Inset * release(lyx::pos_type); + void insert(Inset * inset, pos_type pos); /// - Inset * get(lyx::pos_type pos) const; + void erase(pos_type pos); /// - void increasePosAfterPos(lyx::pos_type pos); + Inset * release(pos_type); /// - void decreasePosAfterPos(lyx::pos_type pos); + Inset * get(pos_type pos) const; /// - void deleteInsetsLyXText(BufferView * bv); + void increasePosAfterPos(pos_type pos); /// - void resizeInsetsLyXText(BufferView * bv); + void decreasePosAfterPos(pos_type pos); + + /// search for next occurence of an \c Inset type. + /// \return the position of the found inset. + /// \retval -1 if no \c Inset is found. + pos_type find( + InsetCode code, ///< Code of inset to find. + pos_type startpos = 0 ///< start position for the search. + ) const; + + /// count occurrences of an \c Inset type. + /// \return the number of found inset(s). + int count( + InsetCode code, ///< Code of inset type to count. + pos_type startpos = 0 ///< start position for the counting. + ) const; + private: /// - List list; + List list_; }; -/// -bool operator==(InsetList::iterator const & i1, - InsetList::iterator const & i2); -/// -bool operator!=(InsetList::iterator const & i1, - InsetList::iterator const & i2); + +} // namespace lyx #endif