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"
36 friend class TocBackend;
39 /// Default constructor for STL containers.
42 TocItem(DocIterator const & dit,
53 docstring const & str() const;
55 docstring const asString() const;
57 /// the action corresponding to the goTo above
58 FuncRequest action() const;
61 /// Current position of item.
73 class Toc : public std::vector<TocItem> {};
75 typedef Toc::const_iterator TocIterator;
78 /// A class and no typedef because we want to forward declare it.
79 class TocList : public std::map<std::string, Toc> {};
89 TocBackend(Buffer const * buffer) : buffer_(buffer) {}
91 void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
95 void updateItem(DocIterator const & pit);
98 TocList const & tocs() const { return tocs_; }
99 TocList & tocs() { return tocs_; }
102 Toc const & toc(std::string const & type) const;
103 Toc & toc(std::string const & type);
105 /// Return the first Toc Item before the cursor
107 std::string const & type, ///< Type of Toc.
108 DocIterator const & dit ///< The cursor location in the document.
112 void writePlaintextTocList(std::string const & type, odocstream & os) const;
118 Buffer const * buffer_;
121 inline bool operator==(TocItem const & a, TocItem const & b)
123 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
127 inline bool operator!=(TocItem const & a, TocItem const & b)
135 #endif // TOC_BACKEND_H