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"
40 friend class TocBackend;
44 TocItem(ParConstIterator const & par_it = ParConstIterator(),
46 docstring const & s = docstring());
50 bool const isValid() const;
54 int const depth() const;
56 docstring const & str() const;
58 docstring const asString() const;
60 /// the action corresponding to the goTo above
61 FuncRequest action() const;
64 /// Current position of item.
65 ParConstIterator par_it_;
76 typedef std::vector<TocItem> Toc;
77 typedef Toc::const_iterator TocIterator;
79 /// A class and no typedef because we want to forward declare it.
80 class TocList : public std::map<std::string, Toc>
92 TocBackend(Buffer const * buffer = NULL): buffer_(buffer) {}
96 void setBuffer(Buffer const * buffer)
99 bool addType(std::string const & type);
103 TocList const & tocs() const
106 std::vector<std::string> const & types() const
109 Toc const & toc(std::string const & type) const;
110 /// Return the first Toc Item before the cursor
111 TocIterator const item(std::string const & type, ParConstIterator const &) const;
113 void asciiTocList(std::string const & type, odocstream & os) const;
119 std::vector<std::string> types_;
121 Buffer const * buffer_;
126 bool operator==(TocItem const & a, TocItem const & b)
128 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
133 bool operator!=(TocItem const & a, TocItem const & b)
141 #endif // TOC_BACKEND_H