]> git.lyx.org Git - lyx.git/blob - src/toc.h
fix two crashes related to dEPM. Some crashes remain
[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 class TocItem {
33 public:
34         TocItem(int par_id, int d, std::string const & s)
35                 : id_(par_id), depth(d), str(s) {}
36         ///
37         std::string const asString() const;
38         /// set cursor in LyXView to this TocItem
39         void goTo(LyXView & lv_) const;
40         /// the action corresponding to the goTo above
41         FuncRequest action() const;
42         /// Paragraph ID containing this item
43         int id_;
44         /// nesting depth
45         int depth;
46         ///
47         std::string str;
48 };
49
50 ///
51 typedef std::vector<TocItem> Toc;
52 ///
53 typedef std::map<std::string, Toc> TocList;
54
55 ///
56 TocList const getTocList(Buffer const &);
57
58 ///
59 std::vector<std::string> const getTypes(Buffer const &);
60
61 ///
62 void asciiTocList(std::string const &, Buffer const &, std::ostream &);
63
64 /** Given the cmdName of the TOC param, returns the type used
65     by ControlToc::getContents() */
66 std::string const getType(std::string const & cmdName);
67
68 /** Returns the guiname from a given @c type
69     The localization of the names will be done in the frontends */
70 std::string const getGuiName(std::string const & type, Buffer const &);
71
72 inline
73 bool operator==(TocItem const & a, TocItem const & b)
74 {
75         return a.id_ == b.id_ && a.str == b.str;
76         // No need to compare depth.
77 }
78
79
80 inline
81 bool operator!=(TocItem const & a, TocItem const & b)
82 {
83         return !(a == b);
84 }
85
86
87 } // namespace toc
88 } // namespace lyx
89
90 #endif // CONTROLTOC_H