]> git.donarmstrong.com Git - lilypond.git/blob - lily/notename-table.cc
release: 1.3.19
[lilypond.git] / lily / notename-table.cc
1 /*
2   notename-table.cc -- implement Notename_table
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "notename-table.hh"
10 #include "dictionary-iter.hh"
11 #include "dictionary.hh"
12 #include "musical-pitch.hh"
13
14 String
15 Notename_table::get_name (Musical_pitch m) const
16 {
17   for (Dictionary_iter<Musical_pitch> ai (*pitch_dict_); ai.ok (); ai++)
18     {
19       if (ai.val () == m)
20         return ai.key ();
21     }
22   return "r";                   // rest. 
23 }
24
25
26 void
27 Notename_table::add_note_name (String s,
28                                Musical_pitch const *p)
29 {
30   pitch_dict_->elem (s) = *p;
31 }
32
33 Notename_table::Notename_table ()
34 {
35   pitch_dict_ = new Dictionary<Musical_pitch>;
36 }
37
38 Notename_table::~Notename_table()
39 {
40   delete pitch_dict_;
41 }
42
43 Notename_table::Notename_table (Notename_table const &s)
44 {
45   pitch_dict_ = new Dictionary<Musical_pitch> (*s.pitch_dict_);
46 }
47 bool
48 Notename_table::elem_b (String s)const
49 {
50   return pitch_dict_->elem_b (s);
51 }
52 Musical_pitch
53 Notename_table::get_pitch (String s)const
54 {
55   return (*pitch_dict_)[s];
56 }