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 "ParIterator.h"
19 #include "support/strfwd.h"
36 friend class TocBackend;
39 /// Default constructor for STL containers.
42 TocItem(ParConstIterator const & par_it,
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.
62 ParConstIterator par_it_;
73 typedef std::vector<TocItem> Toc;
74 typedef Toc::const_iterator TocIterator;
77 /// A class and no typedef because we want to forward declare it.
78 class TocList : public std::map<std::string, Toc> {};
88 TocBackend(Buffer const * buffer = NULL) : buffer_(buffer) {}
90 void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
94 void updateItem(ParConstIterator const & pit);
97 TocList const & tocs() const { return tocs_; }
98 TocList & tocs() { return tocs_; }
101 Toc const & toc(std::string const & type) const;
102 Toc & toc(std::string const & type);
104 /// Return the first Toc Item before the cursor
106 std::string const & type, ///< Type of Toc.
107 ParConstIterator const & ///< The cursor location in the document.
111 void writePlaintextTocList(std::string const & type, odocstream & os) const;
117 Buffer const * buffer_;
120 inline bool operator==(TocItem const & a, TocItem const & b)
122 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
126 inline bool operator!=(TocItem const & a, TocItem const & b)
134 #endif // TOC_BACKEND_H