]> git.lyx.org Git - lyx.git/blob - src/toc.h
... and sanitize the simplified code...
[lyx.git] / src / toc.h
1 // -*- C++ -*-
2 /**
3  * \file toc.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jean-Marc Lasgouttes
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  *
12  * Nice functions and objects to handle TOCs
13  */
14
15 #ifndef TOC_H
16 #define TOC_H
17
18 #include <map>
19 #include <iosfwd>
20 #include <vector>
21 #include <string>
22
23 class Buffer;
24 class LyXView;
25 class Paragraph;
26 class FuncRequest;
27
28 namespace lyx {
29 namespace toc {
30
31 ///
32 struct TocItem {
33         TocItem(int par_id, int d, std::string const & s)
34                 : id_(par_id), depth(d), str(s) {}
35         ///
36         std::string const asString() const;
37         /// set cursor in LyXView to this TocItem
38         void goTo(LyXView & lv_) const;
39         /// the action corresponding to the goTo above
40         FuncRequest action() const;
41         /// Paragraph ID containing this item
42         int id_;
43         /// nesting depth
44         int depth;
45         ///
46         std::string str;
47 };
48
49 ///
50 typedef std::vector<TocItem> Toc;
51 ///
52 typedef std::map<std::string, Toc> TocList;
53
54 ///
55 TocList const getTocList(Buffer const &);
56
57 ///
58 std::vector<std::string> const getTypes(Buffer const &);
59
60 ///
61 void asciiTocList(std::string const &, Buffer const &, std::ostream &);
62
63 /** Given the cmdName of the TOC param, returns the type used
64     by ControlToc::getContents() */
65 std::string const getType(std::string const & cmdName);
66
67 inline
68 bool operator==(TocItem const & a, TocItem const & b)
69 {
70         return a.id_ == b.id_ && a.str == b.str;
71         // No need to compare depth.
72 }
73
74
75 inline
76 bool operator!=(TocItem const & a, TocItem const & b)
77 {
78         return !(a == b);
79 }
80
81
82 } // namespace toc
83 } // namespace lyx
84
85 #endif // CONTROLTOC_H