4 * This file is part of LyX, the document processor.
\r
5 * Licence details can be found in the file COPYING.
\r
7 * \author Jean-Marc Lasgouttes
\r
8 * \author Angus Leeming
\r
9 * \author Abdelrazak Younes
\r
11 * Full author contact details are available in file CREDITS.
\r
13 * TocBackend mainly used in toc.[Ch]
\r
16 #ifndef TOC_BACKEND_H
\r
17 #define TOC_BACKEND_H
\r
24 #include "pariterator.h"
\r
46 friend class TocBackend;
\r
47 friend bool operator==(Item const & a, Item const & b);
\r
52 ParConstIterator const & par_it = ParConstIterator(),
\r
54 std::string const & s = std::string());
\r
58 bool const isValid() const;
\r
60 int const id() const;
\r
62 int const depth() const;
\r
64 std::string const & str() const;
\r
66 std::string const asString() const;
\r
67 /// set cursor in LyXView to this Item
\r
68 void goTo(LyXView & lv_) const;
\r
69 /// the action corresponding to the goTo above
\r
70 FuncRequest action() const;
\r
73 /// Current position of item.
\r
74 ParConstIterator par_it_;
\r
79 /// Full item string
\r
84 typedef std::vector<Item> Toc;
\r
85 typedef std::vector<Item>::const_iterator TocIterator;
\r
87 typedef std::map<std::string, Toc> TocList;
\r
91 TocBackend(Buffer const * buffer = NULL): buffer_(buffer) {}
\r
95 void setBuffer(Buffer const * buffer)
\r
96 { buffer_ = buffer; }
\r
98 bool addType(std::string const & type);
\r
102 TocList const & tocs()
\r
105 std::vector<std::string> const & types()
\r
108 Toc const & toc(std::string const & type);
\r
109 /// Return the first Toc Item before the cursor
\r
110 TocIterator const item(std::string const & type, ParConstIterator const &);
\r
112 void asciiTocList(std::string const & type, std::ostream & os) const;
\r
118 std::vector<std::string> types_;
\r
120 Buffer const * buffer_;
\r
125 bool operator==(TocBackend::Item const & a, TocBackend::Item const & b)
\r
127 return a.id() == b.id() && a.str() == b.str();
\r
128 // No need to compare depth.
\r
133 bool operator!=(TocBackend::Item const & a, TocBackend::Item const & b)
\r
141 #endif // TOC_BACKEND_H
\r