2002->2003
[lilypond.git] / lily / translator-ctors.cc
blob000b01208616a0420db023cc74cd2c4e3470b159
1 /*
2 translator-ctors.cc -- implement Translator construction
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "translator.hh"
10 #include "dictionary.hh"
11 #include "warn.hh"
14 should delete these after exit.
18 UGH. Dictionary is deprecated
20 Dictionary<Translator*> *global_translator_dict=0;
22 LY_DEFINE(get_all_translators,"ly:get-all-translators", 0, 0, 0, (),
23 "Return an list of a all translator objects that may be instantiated
24 during a lilypond run.")
26 SCM l = SCM_EOL;
27 for (std::map<String,Translator*>::const_iterator (ci (global_translator_dict->begin()));
28 ci != global_translator_dict->end (); ci++)
30 l = scm_cons ((*ci).second->self_scm (), l);
32 return l;
35 void
36 add_translator (Translator *t)
38 if (!global_translator_dict)
39 global_translator_dict = new Dictionary<Translator*>;
41 (*global_translator_dict)[classname (t)] = t;
44 Translator*
45 get_translator (String s)
47 if (global_translator_dict->elem_b (s))
49 Translator* t = (*global_translator_dict)[s];
50 return t;
53 error (_f ("unknown translator: `%s'", s));
54 return 0;