4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * \author Martin Vermeer
12 * Full author contact details are available in file CREDITS.
18 #include "support/docstring.h"
25 /// This represents a single counter.
31 Counter(docstring const & mc, docstring const & ls,
32 docstring const & lsa);
43 /// Returns the master counter of this counter
44 docstring const & master() const;
45 /// Returns a LaTeX-like string to format the counter, similar
46 /// to LaTeX' \c \thesubsection.
47 docstring const & labelString() const;
48 /// Returns a LaTeX-like string to format the counter in
49 /// appendix, similar to LaTeX' \c \thesubsection.
50 docstring const & labelStringAppendix() const;
54 /// contains master counter name; master counter is the counter
55 /// that, if stepped (incremented) zeroes this counter. E.g.
56 /// "subsection"'s master is "section".
58 // Contains a LaTeX-like string to format the counter, similar
59 // to LaTeX' \c \thesubsection.
60 docstring labelstring_;
61 // The same as labelstring_, but in appendices.
62 docstring labelstringappendix_;
66 /// This is a class of (La)TeX type counters.
67 /// Every instantiation is an array of counters of type Counter.
70 /// Add a new counter to array.
71 void newCounter(docstring const & newc);
72 /// Add new counter having oldc as its master and ls as its label.
73 void newCounter(docstring const & newc,
74 docstring const & masterc,
76 docstring const & lsa);
78 bool hasCounter(docstring const & c) const;
80 void set(docstring const & ctr, int val);
82 void addto(docstring const & ctr, int val);
84 int value(docstring const & ctr) const;
85 /// Step (increment by one) counter named by arg, and
86 /// zeroes slave counter(s) for which it is the master.
87 /// NOTE sub-slaves not zeroed! That happens at slave's
88 /// first step 0->1. Seems to be sufficient.
89 void step(docstring const & ctr);
90 /// Reset all counters.
92 /// Reset counters matched by match string.
93 void reset(docstring const & match);
94 /// Copy counters whose name matches match from the &from to
95 /// the &to array of counters. Empty string matches all.
96 void copy(Counters & from, Counters & to,
97 docstring const & match = docstring());
98 /// returns the string representation of the counter.
99 docstring theCounter(docstring const & c);
100 /// A complete expanded label, like 2.1.4 for a subsubsection
101 /// according to the given format
102 docstring counterLabel(docstring const & format);
104 bool appendix() const { return appendix_; };
106 void appendix(bool a) { appendix_ = a; };
108 std::string const & current_float() const { return current_float_; }
110 void current_float(std::string const & f) { current_float_ = f; }
112 /// A counter label's single item, 1 for subsection number in
113 /// the 2.1.4 subsubsection number label.
114 docstring labelItem(docstring const & ctr,
115 docstring const & numbertype);
116 /// Maps counter (layout) names to actual counters.
117 typedef std::map<docstring, Counter> CounterList;
119 CounterList counterList;
123 std::string current_float_;