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.
17 #include "DocIterator.h"
19 #include "support/strfwd.h"
37 friend class TocBackend
;
40 /// Default constructor for STL containers.
41 TocItem() : dit_(0) {}
43 TocItem(DocIterator
const & dit
,
54 docstring
const & str() const;
56 docstring
const asString() const;
58 DocIterator
const & dit() const;
60 /// the action corresponding to the goTo above
61 FuncRequest
action() const;
64 /// Current position of item.
76 class Toc
: public std::vector
<TocItem
>
79 typedef std::vector
<TocItem
>::const_iterator const_iterator
;
80 typedef std::vector
<TocItem
>::iterator iterator
;
81 const_iterator
item(DocIterator
const & dit
) const;
82 /// Look for a TocItem given its depth and string.
83 /// \return The first matching item.
84 /// \retval end() if no item was found.
85 iterator
item(int depth
, docstring
const & str
);
88 typedef Toc::const_iterator TocIterator
;
91 /// A class and no typedef because we want to forward declare it.
92 class TocList
: public std::map
<std::string
, Toc
> {};
102 TocBackend(Buffer
const * buffer
) : buffer_(buffer
) {}
104 void setBuffer(Buffer
const * buffer
) { buffer_
= buffer
; }
107 /// \return true if the item was updated.
108 bool updateItem(DocIterator
const & pit
);
111 TocList
const & tocs() const { return tocs_
; }
112 TocList
& tocs() { return tocs_
; }
115 Toc
const & toc(std::string
const & type
) const;
116 Toc
& toc(std::string
const & type
);
118 /// Return the first Toc Item before the cursor
120 std::string
const & type
, ///< Type of Toc.
121 DocIterator
const & dit
///< The cursor location in the document.
125 void writePlaintextTocList(std::string
const & type
, odocstream
& os
) const;
131 Buffer
const * buffer_
;
134 inline bool operator==(TocItem
const & a
, TocItem
const & b
)
136 return a
.id() == b
.id() && a
.str() == b
.str() && a
.depth() == b
.depth();
140 inline bool operator!=(TocItem
const & a
, TocItem
const & b
)
148 #endif // TOC_BACKEND_H