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.
46 /* This is similar to what one gets in LaTeX when using
49 docstring const & labelString() const;
50 /// Returns a LaTeX-like string to format the counter in appendix.
51 /* This is similar to what one gets in LaTeX when using
52 * "\the<counter>" in an appendix.
54 docstring const & labelStringAppendix() const;
58 /// contains master counter name.
59 /* The master counter is the counter that, if stepped
60 * (incremented) zeroes this counter. E.g. "subsection"'s
61 * master is "section".
64 // Contains a LaTeX-like string to format the counter.
65 docstring labelstring_;
66 // The same as labelstring_, but in appendices.
67 docstring labelstringappendix_;
71 /// This is a class of (La)TeX type counters.
72 /// Every instantiation is an array of counters of type Counter.
75 /// Add a new counter to array.
76 void newCounter(docstring const & newc);
77 /// Add new counter having oldc as its master and ls as its label.
78 void newCounter(docstring const & newc,
79 docstring const & masterc,
81 docstring const & lsa);
82 /// Checks whether the given counter exists.
83 bool hasCounter(docstring const & c) const;
85 void set(docstring const & ctr, int val);
87 void addto(docstring const & ctr, int val);
89 int value(docstring const & ctr) const;
90 /// Increment by one counter named by arg, and zeroes slave
91 /// counter(s) for which it is the master.
92 /* Sub-slaves not zeroed! That happens at slave's first step
93 * 0->1. Seems to be sufficient.
95 void step(docstring const & ctr);
96 /// Reset all counters.
98 /// Reset counters matched by match string.
99 void reset(docstring const & match);
100 /// Copy counters whose name matches match from the &from to
101 /// the &to array of counters. Empty string matches all.
102 void copy(Counters & from, Counters & to,
103 docstring const & match = docstring());
104 /// returns the expanded string representation of the counter.
105 docstring theCounter(docstring const & c);
106 /// Replace om format all the LaTeX-like macros that depend on
108 docstring counterLabel(docstring const & format);
109 /// Are we in apendix?
110 bool appendix() const { return appendix_; };
111 /// Set the state variable indicating whether we are in appendix.
112 void appendix(bool a) { appendix_ = a; };
113 /// Returns the current enclosing float.
114 std::string const & current_float() const { return current_float_; }
115 /// Sets the current enclosing float.
116 void current_float(std::string const & f) { current_float_ = f; }
118 /// Returns the value of the counter according to the
119 /// numbering scheme numbertype.
120 /* Available numbering schemes are arabic (1, 2,...), roman
121 * (i, ii,...), Roman (I, II,...), alph (a, b,...), Alpha (A,
124 docstring labelItem(docstring const & ctr,
125 docstring const & numbertype);
126 /// Maps counter (layout) names to actual counters.
127 typedef std::map<docstring, Counter> CounterList;
129 CounterList counterList;
130 /// Are we in an appendix?
132 /// The current enclosing float.
133 std::string current_float_;