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.
13 * TocBackend mainly used in toc.[Ch]
23 #include "ParIterator.h"
25 #include "support/docstream.h"
38 friend class TocBackend;
42 TocItem(ParConstIterator const & par_it = ParConstIterator(),
44 docstring const & s = docstring()
49 bool const isValid() const;
53 int const depth() const;
55 docstring const & str() const;
57 docstring const asString() const;
59 /// the action corresponding to the goTo above
60 FuncRequest action() const;
63 /// Current position of item.
64 ParConstIterator par_it_;
75 typedef std::vector<TocItem> Toc;
76 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>
91 TocBackend(Buffer const * buffer = NULL): buffer_(buffer) {}
95 void setBuffer(Buffer const * buffer)
100 void updateItem(ParConstIterator const & pit);
103 TocList const & tocs() const
107 Toc const & toc(std::string const & type) const;
108 /// Return the first Toc Item before the cursor
109 TocIterator const item(
110 std::string const & type, ///< Type of Toc.
111 ParConstIterator const & ///< The cursor location in the document.
114 void writePlaintextTocList(std::string const & type, odocstream & os) const;
120 Buffer const * buffer_;
125 bool operator==(TocItem const & a, TocItem const & b)
127 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
132 bool operator!=(TocItem const & a, TocItem const & b)
140 #endif // TOC_BACKEND_H