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"
46 friend class TocBackend;
47 friend bool operator==(Item const & a, Item const & b);
52 ParConstIterator const & par_it = ParConstIterator(),
54 docstring const & s = docstring());
58 bool const isValid() const;
62 int const depth() const;
64 docstring const & str() const;
66 docstring const asString() const;
68 /// the action corresponding to the goTo above
69 FuncRequest action() const;
72 /// Current position of item.
73 ParConstIterator par_it_;
83 typedef std::vector<Item> Toc;
84 typedef std::vector<Item>::const_iterator TocIterator;
86 typedef std::map<std::string, Toc> TocList;
90 TocBackend(Buffer const * buffer = NULL): buffer_(buffer) {}
94 void setBuffer(Buffer const * buffer)
97 bool addType(std::string const & type);
101 TocList const & tocs() const
104 std::vector<std::string> const & types() const
107 Toc const & toc(std::string const & type) const;
108 /// Return the first Toc Item before the cursor
109 TocIterator const item(std::string const & type, ParConstIterator const &) const;
111 void asciiTocList(std::string const & type, odocstream & os) const;
117 std::vector<std::string> types_;
119 Buffer const * buffer_;
124 bool operator==(TocBackend::Item const & a, TocBackend::Item const & b)
126 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
131 bool operator!=(TocBackend::Item const & a, TocBackend::Item const & b)
139 #endif // TOC_BACKEND_H