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());
48 bool const isValid() const;
52 int const depth() const;
54 docstring const & str() const;
56 docstring const asString() const;
58 /// the action corresponding to the goTo above
59 FuncRequest action() const;
62 /// Current position of item.
63 ParConstIterator par_it_;
74 typedef std::vector<TocItem> Toc;
75 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>
90 TocBackend(Buffer const * buffer = NULL): buffer_(buffer) {}
94 void setBuffer(Buffer const * buffer)
99 void updateItem(ParConstIterator const & pit);
102 TocList const & tocs() const
106 Toc const & toc(std::string const & type) const;
107 /// Return the first Toc Item before the cursor
108 TocIterator const item(std::string const & type, ParConstIterator const &) const;
110 void writePlaintextTocList(std::string const & type, odocstream & os) const;
116 Buffer const * buffer_;
121 bool operator==(TocItem const & a, TocItem const & b)
123 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
128 bool operator!=(TocItem const & a, TocItem const & b)
136 #endif // TOC_BACKEND_H