]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/symtable.cc
release: 1.1.18
[lilypond.git] / lily / symtable.cc
index 25e4ff8ce735eaf19ab5ee48d928d8947fe89c94..ccf1eb16102584041048253f83486af0a9154f39 100644 (file)
@@ -3,25 +3,27 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #include "misc.hh"
-#include "dimen.hh"
 #include "debug.hh"
 #include "real.hh"
-#include "symbol.hh"
-#include "assoc.hh"
-#include "assoc-iter.hh"
+#include "atom.hh"
+#include "dictionary-iter.hh"
 #include "symtable.hh"
 
 Symtables::Symtables()
 {
 }
 
+
 Symtables::Symtables (Symtables const &s)
+  : Dictionary<Symtable*> (s)
 {
-  for (Assoc_iter<String, Symtable*>  i (s); i.ok(); i++) 
+  font_name_ = s.font_name_;
+
+  for (Dictionary_iter< Symtable*>  i (s); i.ok(); i++)
     {
       add (i.key(), new Symtable (*i.val ()));
     }
@@ -29,36 +31,48 @@ Symtables::Symtables (Symtables const &s)
 
 Symtables::~Symtables()
 {
-  for (Assoc_iter<String, Symtable*>  i (*this); i.ok(); i++) 
+  for (Dictionary_iter<Symtable*>  i (*this); i.ok(); i++)
     {
       delete i.val();
     }
 }
 
-Symbol 
+Atom
 Symtable::lookup (String s) const
 {
-  if (elt_b (s))
-    return (*this)[s];
-  else 
+  if (elem_b (s))
+    {
+      Atom a (elem(s));
+      return a;
+    }
+  else
     {
-      warning ("Symtable `" + id_str+ "\': unknown symbol `" +s+"'\n");
-      Symbol sy;       
+      warning (_f ("Symtable `%s\': unknown symbol: `%s\'", id_str, s));
+      Atom sy;
       return sy;
     }
 }
 
-Symtable* 
-Symtables::operator()(String s) 
+Symtable*
+Symtables::operator()(String s)
 {
-  return Assoc<String, Symtable*>::operator[](s);
-} 
+  if (!elem_b (s))
+    {
+      error (_f ("Symtable `%s\' unknown", s));
+      /* 
+        We can 't return, because we would dump core anyway.
+       */
+      return 0;
+    }
+  else
+    return elem(s);
+}
 void
 Symtables::print() const
 {
-  for (Assoc_iter<String, Symtable*>  i (*this); i.ok(); i++) 
+  for (Dictionary_iter<Symtable*>  i (*this); i.ok(); i++)
     {
-      DOUT << "table \'" << i.key() << "\' {\n";
+      DOUT << "table \'" << i.key () << "\' {\n";
       i.val()->print ();
       DOUT << "}\n";
     }
@@ -66,15 +80,15 @@ Symtables::print() const
 void
 Symtable::print() const
 {
-  for (Assoc_iter<String, Symbol>  i (*this); i.ok(); i++) 
+  for (Dictionary_iter<Atom>  i (*this); i.ok(); i++)
     {
-      DOUT << "\'" << i.key() << "\'->" << i.val ().str () << "\n";
+      DOUT << "\'" << i.key() << "\'->" << i.val ().str () << '\n';
     }
 }
-       
+
 void
 Symtables::add (String s, Symtable*p)
 {
   p-> id_str = s;
-  Assoc<String, Symtable*>::add (s,p);
+  Dictionary<Symtable*>::elem  (s) = p;
 }