4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Jean-Marc Lasgouttes
8 * \author Angus Leeming
9 * \author Abdelrazak Younes
11 * Full author contact details are available in file CREDITS.
17 #include "DocIterator.h"
19 #include "support/strfwd.h"
37 friend class TocBackend;
40 /// Default constructor for STL containers.
43 TocItem(DocIterator const & dit,
54 docstring const & str() const;
56 docstring const asString() const;
58 /// the action corresponding to the goTo above
59 FuncRequest action() const;
62 /// Current position of item.
74 class Toc : public std::vector<TocItem> {
76 typedef std::vector<TocItem>::const_iterator const_iterator;
77 const_iterator Toc::item(DocIterator const & dit) const;
80 typedef Toc::const_iterator TocIterator;
83 /// A class and no typedef because we want to forward declare it.
84 class TocList : public std::map<std::string, Toc> {};
94 TocBackend(Buffer const * buffer) : buffer_(buffer) {}
96 void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
100 void updateItem(DocIterator const & pit);
103 TocList const & tocs() const { return tocs_; }
104 TocList & tocs() { return tocs_; }
107 Toc const & toc(std::string const & type) const;
108 Toc & toc(std::string const & type);
110 /// Return the first Toc Item before the cursor
112 std::string const & type, ///< Type of Toc.
113 DocIterator const & dit ///< The cursor location in the document.
117 void writePlaintextTocList(std::string const & type, odocstream & os) const;
123 Buffer const * buffer_;
126 inline bool operator==(TocItem const & a, TocItem const & b)
128 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
132 inline bool operator!=(TocItem const & a, TocItem const & b)
140 #endif // TOC_BACKEND_H