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]
24 #include "pariterator.h"
45 friend class TocBackend;
46 friend bool operator==(Item const & a, Item const & b);
51 ParConstIterator const & par_it = ParConstIterator(),
53 docstring const & s = docstring());
57 bool const isValid() const;
61 int const depth() const;
63 docstring const & str() const;
65 docstring const asString() const;
66 /// set cursor in LyXView to this Item
67 void goTo(LyXView & lv_) 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()
104 std::vector<std::string> const & types()
107 Toc const & toc(std::string const & type);
108 /// Return the first Toc Item before the cursor
109 TocIterator const item(std::string const & type, ParConstIterator 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