X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fcounters.h;h=1f98e89adc3f06a38c7b1e56dfc3859b45193290;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=19014cc6fceb0b580eff76fe3fac767f9ee3b464;hpb=0b1b6dfa4ed99f2b7c2a36cb56dcbb9d5553ac33;p=lyx.git diff --git a/src/counters.h b/src/counters.h index 19014cc6fc..1f98e89adc 100644 --- a/src/counters.h +++ b/src/counters.h @@ -1,20 +1,29 @@ // -*- C++ -*- +/** + * \file counters.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Lars Gullik Bjønnes + * \author Jean-Marc Lasgouttes + * \author John Levon + * \author Martin Vermeer + * + * Full author contact details are available in file CREDITS. + */ #ifndef COUNTERS_H -#define COUTNERS_H +#define COUNTERS_H + +#include "support/docstring.h" #include -#include -#include "LString.h" -#ifdef SIGC_CXX_NAMESPACES -using SigC::Object; -using SigC::Signal0; -#endif +namespace lyx { -/// -class Counter : public Object { +/// This represents a single counter. +class Counter { public: /// Counter(); @@ -28,39 +37,64 @@ public: void step(); /// void reset(); - /// - Signal0 onstep; + /// Returns the master counter of this counter + lyx::docstring master() const; + /// sets the master counter for this counter + void setMaster(lyx::docstring const & m); private: /// int value_; + /// contains master counter name; master counter is the counter + /// that, if stepped (incremented) zeroes this counter. E.g. + /// "subparagraph"'s master is "paragraph". + lyx::docstring master_; }; -/** This is a class of (La)TeX type counters. The counters is in a text - Style and can be reset by signals emitted from a single counter. -*/ +/// This is a class of (La)TeX type counters. +/// Every instantiation is an array of counters of type Counter. class Counters { public: - /// - ~Counters(); - /// - void newCounter(string const & newc); - /// - void newCounter(string const & newc, string const & oldc); - /// - void set(string const & ctr, int val); - /// - void addto(string const & ctr, int val); - /// - int value(string const & ctr) const; - /// - void step(string const & ctr); - // string refstep(string const & cou); + /// Add a new counter to array. + void newCounter(lyx::docstring const & newc); + /// Add new counter having oldc as its master. + void newCounter(lyx::docstring const & newc, + lyx::docstring const & oldc); + /// + void set(lyx::docstring const & ctr, int val); + /// + void addto(lyx::docstring const & ctr, int val); + /// + int value(lyx::docstring const & ctr) const; + /// Step (increment by one) counter named by arg, and + /// zeroes slave counter(s) for which it is the master. + /// NOTE sub-slaves not zeroed! That happens at slave's + /// first step 0->1. Seems to be sufficient. + void step(lyx::docstring const & ctr); + /// Reset all counters. + void reset(); + /// Reset counters matched by match string. + void reset(lyx::docstring const & match); + /// Copy counters whose name matches match from the &from to + /// the &to array of counters. Empty string matches all. + void copy(Counters & from, Counters & to, + lyx::docstring const & match = lyx::docstring()); + /// A complete expanded label, like 2.1.4 for a subsubsection + /// according to the given format + lyx::docstring counterLabel(lyx::docstring const & format); private: - /// - typedef std::map CounterList; - /// + /// A counter label's single item, 1 for subsection number in + /// the 2.1.4 subsubsection number label. + lyx::docstring labelItem(lyx::docstring const & ctr, + lyx::docstring const & numbertype); + /// Maps counter (layout) names to actual counters. + typedef std::map CounterList; + /// Instantiate. CounterList counterList; + }; + +} // namespace lyx + #endif