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"
46 friend class TocBackend;
47 friend bool operator==(Item const & a, Item const & b);
52 ParConstIterator const & par_it = ParConstIterator(),
54 std::string const & s = std::string());
58 bool const isValid() const;
62 int const depth() const;
64 std::string const & str() const;
66 std::string const asString() const;
67 /// set cursor in LyXView to this Item
68 void goTo(LyXView & lv_) const;
69 /// the action corresponding to the goTo above
70 FuncRequest action() const;
73 /// Current position of item.
74 ParConstIterator par_it_;
84 typedef std::vector<Item> Toc;
85 typedef std::vector<Item>::const_iterator TocIterator;
87 typedef std::map<std::string, Toc> TocList;
91 TocBackend(Buffer const * buffer = NULL): buffer_(buffer) {}
95 void setBuffer(Buffer const * buffer)
98 bool addType(std::string const & type);
102 TocList const & tocs()
105 std::vector<std::string> const & types()
108 Toc const & toc(std::string const & type);
109 /// Return the first Toc Item before the cursor
110 TocIterator const item(std::string const & type, ParConstIterator const &);
112 void asciiTocList(std::string const & type, std::ostream & os) const;
118 std::vector<std::string> types_;
120 Buffer const * buffer_;
125 bool operator==(TocBackend::Item const & a, TocBackend::Item const & b)
127 return a.id() == b.id() && a.str() == b.str() && a.depth() == b.depth();
132 bool operator!=(TocBackend::Item const & a, TocBackend::Item const & b)
140 #endif // TOC_BACKEND_H