]> git.lyx.org Git - lyx.git/blob - src/counters.h
d737f995bd30e647fd0b90d4be2dda51c48e1759
[lyx.git] / src / counters.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  *
11  * ====================================================== */
12
13
14 #ifndef COUNTERS_H
15 #define COUNTERS_H
16
17 #ifdef __GNUG__
18 #pragma interface
19 #endif
20
21 #include "LString.h"
22 #include <map>
23 #include <vector>
24
25 ///
26 class Counter {
27 public:
28         ///
29         Counter();
30         ///
31         void set(int v);
32         ///
33         void addto(int v);
34         ///
35         int value() const;
36         ///
37         void step();
38         ///
39         void reset();
40         ///
41         string master() const;
42         ///
43         void setMaster(string const & m);
44         ///
45
46 private:
47         int value_;
48         ///
49         string master_;
50 };
51
52
53 /** This is a class of (La)TeX type counters. The counters is in a text
54     Style and can be reset by signals emitted from a single counter.
55 */
56 class Counters {
57 public:
58         ///
59         Counters();
60         ///     
61         //~Counters();
62         ///
63         void newCounter(string const & newc);
64         ///
65         void newCounter(string const & newc, string const & oldc);
66         ///
67         void set(string const & ctr, int val);
68         ///
69         void addto(string const & ctr, int val);
70         ///
71         int value(string const & ctr) const;
72         ///
73         void step(string const & ctr);
74         ///
75         void reset(string const & match = "");
76         ///
77         void copy(Counters & from, Counters & to, string const & match = "");
78         ///
79         string labelItem(string const & ctr,
80                         string const & labeltype, 
81                         string const & langtype = "latin",
82                         bool first = false);
83         ///
84         string numberLabel(string const & ctr,
85                         string const & labeltype, 
86                         string const & langtype = "latin",
87                         int head = 0);
88         ///
89         std::vector<string> enums, sects;
90         
91 private:
92         ///
93         typedef std::map<string, Counter> CounterList;
94         ///
95         CounterList counterList;
96
97 };
98
99 #endif