]> git.lyx.org Git - lyx.git/blob - src/toc.h
include sys/time.h
[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 #include <config.h>
20
21 #include "support/LOstream.h"
22 #include "LString.h"
23
24 #include <map>
25 #include <vector>
26
27 class Buffer;
28 class LyXView;
29 class Paragraph;
30
31 /** Nice functions and objects to handle TOCs
32  */
33 namespace toc
34 {
35
36 ///
37 struct TocItem {
38         TocItem(Paragraph const * p, int d, string const & s)
39                 : par(p), depth(d), str(s) {}
40         ///
41         string const asString() const;
42         /// set cursor in LyXView to this TocItem
43         void goTo(LyXView & lv_) const;
44         /// the action corresponding to the goTo above
45         int action() const;
46         ///
47         Paragraph const * par;
48         ///
49         int depth;
50         ///
51         string str;
52 };
53
54 ///
55 typedef std::vector<TocItem> Toc;
56 ///
57 typedef std::map<string, Toc> TocList;
58
59 ///
60 TocList const getTocList(Buffer const *);
61
62 ///
63 std::vector<string> const getTypes(Buffer const *);
64
65 ///
66 void asciiTocList(string const &, Buffer const *, std::ostream &);
67
68 /** Given the cmdName of the TOC param, returns the type used
69     by ControlToc::getContents() */
70 string const getType(string const & cmdName);
71
72 ///
73 inline
74 bool operator==(TocItem const & a, TocItem const & b)
75 {
76         return a.par == b.par && a.str == b.str;
77         // No need to compare depth.
78 }
79
80
81 ///
82 inline
83 bool operator!=(TocItem const & a, TocItem const & b)
84 {
85         return !(a == b);
86         // No need to compare depth.
87 }
88
89
90 } // namespace toc
91
92 #endif // CONTROLTOC_H