1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
13 #pragma implementation
30 void Counter::set(int v)
36 void Counter::addto(int v)
42 int Counter::value() const
63 // We need this since we store the Counter's as pointers in
65 for (CounterList::iterator it = counterList.begin();
66 it != counterList.end();
72 void Counters::newCounter(string const & newc)
74 // First check if newc already exist
75 CounterList::iterator cit = counterList.find(newc);
76 // if alrady exist give warning and return
77 if (cit != counterList.end()) {
78 lyxerr << "The new counter already exist." << endl;
81 counterList[newc] = new Counter;
85 void Counters::newCounter(string const & newc, string const & oldc)
87 // First check if newc already exist
88 CounterList::iterator cit = counterList.find(newc);
89 // if already existant give warning and return
90 if (cit != counterList.end()) {
91 lyxerr << "The new counter already exist." << endl;
94 // then check if oldc exist
95 CounterList::iterator it = counterList.find(oldc);
96 // if not give warning and return
97 if (it == counterList.end()) {
98 lyxerr << "The old counter does not exist." << endl;
102 Counter * tmp = new Counter;
103 it->second->onstep.connect(SigC::slot(tmp,
105 counterList[newc] = tmp;
109 void Counters::set(string const & ctr, int val)
111 CounterList::iterator it = counterList.find(ctr);
112 if (it == counterList.end()) {
113 lyxerr << "Counter does not exist." << endl;
116 it->second->set(val);
120 void Counters::addto(string const & ctr, int val)
122 CounterList::iterator it = counterList.find(ctr);
123 if (it == counterList.end()) {
124 lyxerr << "Counter does not exist." << endl;
127 it->second->addto(val);
131 int Counters::value(string const & ctr) const
133 CounterList::const_iterator cit = counterList.find(ctr);
134 if (cit == counterList.end()) {
135 lyxerr << "Counter does not exist." << endl;
138 return cit->second->value();
142 void Counters::step(string const & ctr)
144 CounterList::iterator it = counterList.find(ctr);
145 if (it == counterList.end()) {
146 lyxerr << "Counter does not exist." << endl;