]> git.lyx.org Git - lyx.git/blob - src/toc.h
78ec77afa964da65921d5836a9e479e1e673cf45
[lyx.git] / src / toc.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2002 The LyX Team.
8  *
9  * ======================================================
10  *
11  * \file toc.h
12  * \author Angus Leeming <a.leeming@ic.ac.uk>
13  * \author Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
14  */
15
16 #ifndef TOC_H
17 #define TOC_H
18
19 #ifdef __GNUG__
20 #pragma interface
21 #endif
22
23 #include "support/LOstream.h"
24 #include "LString.h"
25
26 #include <map>
27 #include <vector>
28
29 class Buffer;
30 class LyXView;
31 class Paragraph;
32
33 /** Nice functions and objects to handle TOCs
34  */
35 namespace toc 
36 {
37
38 ///
39 struct TocItem {
40         TocItem(Paragraph * p, int d, string const & s)
41                 : par(p), depth(d), str(s) {}
42         ///
43         string const asString() const;
44         /// set cursor in LyXView to this TocItem
45         void goTo(LyXView & lv_) const;
46         /// the action corresponding to the goTo above
47         int action() const;
48         ///
49         Paragraph * par;
50         ///
51         int depth;
52         ///
53         string str;
54 };
55
56 ///
57 typedef std::vector<TocItem> Toc;
58 ///
59 typedef std::map<string, Toc> TocList;
60
61 ///
62 TocList const getTocList(Buffer const *);
63
64 ///
65 std::vector<string> const getTypes(Buffer const *);
66
67 ///
68 void asciiTocList(string const &, Buffer const *, ostream &);
69         
70 /** Given the cmdName of the TOC param, returns the type used
71     by ControlToc::getContents() */
72 string const getType(string const & cmdName);
73
74 ///
75 inline
76 bool operator==(TocItem const & a, TocItem const & b)
77 {
78         return a.par == b.par && a.str == b.str;
79         // No need to compare depth.
80 }
81
82
83 ///
84 inline
85 bool operator!=(TocItem const & a, TocItem const & b)
86 {
87         return !(a == b);
88         // No need to compare depth.
89 }
90
91
92 } // namespace toc
93
94 #endif // CONTROLTOC_H