From: fred Date: Tue, 10 Dec 1996 14:05:30 +0000 (+0000) Subject: lilypond-0.0.15 X-Git-Tag: release/1.5.59~6631 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=209974dacebd6675c47eadfe363f326671c9e2c2;p=lilypond.git lilypond-0.0.15 --- diff --git a/hdr/identifier.hh b/hdr/identifier.hh index c5d7a5b5b7..3ac537f63e 100644 --- a/hdr/identifier.hh +++ b/hdr/identifier.hh @@ -8,17 +8,24 @@ #ifndef IDENTIFIER_HH #define IDENTIFIER_HH #include "identparent.hh" +#include "symtable.hh" #include "inputstaff.hh" #include "inputmusic.hh" #define make_id_class(Idclass, Class, accessor) \ struct Idclass : Identifier {\ Idclass(String s, Class*st):Identifier(s) { data = st; }\ - virtual Class* accessor() { return (Class*) data; }\ + virtual Class* accessor(bool copy=false) {\ + if (copy)\ + return new Class(* (Class*) data);\ + else\ + return (Class*) data;\ + }\ ~Idclass() { delete accessor(); }\ }\ - +make_id_class(Lookup_id, Lookup, lookup); +make_id_class(Symtables_id, Symtables, symtables); make_id_class(Staff_id, Input_staff, staff); make_id_class(M_chord_id, Music_general_chord, mchord); make_id_class(M_voice_id, Music_voice, mvoice); diff --git a/hdr/identparent.hh b/hdr/identparent.hh index d8d3cb1735..dafeed96fa 100644 --- a/hdr/identparent.hh +++ b/hdr/identparent.hh @@ -17,12 +17,14 @@ struct Identifier Identifier(String n) : name(n) { } virtual ~Identifier() {} - virtual Input_staff * staff() { assert(false); } - virtual Voice_list * voices() { assert(false); } - virtual Horizontal_music*hmusic() { assert(false); } - virtual Vertical_music*vmusic() { assert(false); } - virtual Music_voice *mvoice() { assert(false); } - virtual Music_general_chord *mchord() { assert(false); } + + virtual Input_staff * staff(bool = false) { assert(false); } + virtual Horizontal_music*hmusic(bool = false) { assert(false); } + virtual Vertical_music*vmusic(bool = false) { assert(false); } + virtual Music_voice *mvoice(bool = false) { assert(false); } + virtual Symtables *symtables(bool = false) { assert(false); } + virtual Music_general_chord *mchord(bool = false) { assert(false); } + virtual Lookup*lookup(bool = false) { assert(false); } }; #endif // IDENTPARENT_HH diff --git a/src/symtable.cc b/src/symtable.cc index 39b6fdead0..bc5d173869 100644 --- a/src/symtable.cc +++ b/src/symtable.cc @@ -5,8 +5,25 @@ #include "real.hh" #include "symbol.hh" #include "assoc.hh" +#include "associter.hh" #include "symtable.hh" +Symtables::Symtables() +{ +} + +Symtables::Symtables(Symtables const &s) +{ + for (Assoc_iter i(s); i.ok(); i++) { + add(i.key(), new Symtable(*i.val())); + } +} +Symtables::~Symtables() +{ + for (Assoc_iter i(*this); i.ok(); i++) { + delete i.val(); + } +} Symbol Symtable::lookup(String s) const @@ -25,36 +42,3 @@ Symtables::operator()(String s) { return Assoc::operator[](s); } - -void -Symtables::read(Text_db &symini) -{ - while (!symini.eof()) { - Text_record r(symini++); - if (r[0] == "end" ) - return; - assert (r[0] == "table"); - - String tabnam = r[1]; - Symtable * sp = new Symtable; - while (!symini.eof()){ - r = symini++; - if (r[0] == "end") - break; - - if (r.sz() != 6) - error("Not enough fields in symbol init"); - - int i=0; - String id=r[i++]; - String tex=r[i++]; - svec dims; - for (int j=0; j < 4; j++) - dims.add( parse_dimen(r[i++])); - - Symbol s(tex, Box(dims)); - (*sp)[id] = s; - } - (*this)[tabnam] = sp; - } -}