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 void updateItem(ParConstIterator const & pit);
106 TocList const & tocs() const
109 std::vector<std::string> const & types() const
112 Toc const & toc(std::string const & type) const;
113 /// Return the first Toc Item before the cursor
114 TocIterator const item(std::string const & type, ParConstIterator const &) const;
116 void writePlaintextTocList(std::string const & type, odocstream & os) const;
122 std::vector<std::string> types_;
124 Buffer const * buffer_;
129 bool operator==(TocItem const & a, TocItem const & b)
131 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
136 bool operator!=(TocItem const & a, TocItem const & b)
144 #endif // TOC_BACKEND_H