2 input-translator.cc -- implement Input_translator
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #include "engraver.hh"
11 #include "input-translator.hh"
13 #include "input-translator.hh"
14 #include "engraver-group.hh"
15 #include "performer-group-performer.hh"
18 Input_translator::is_name_b (String n
)
20 for (int i
=0; i
< alias_str_arr_
.size(); i
++)
21 if (alias_str_arr_
[i
] == n
)
27 Input_translator::print() const
32 DOUT
<< base_str_
<<" " << type_str_
<<" {\n";
33 DOUT
<< "Consists of ";
34 for (int i
=0; i
< consists_str_arr_
.size(); i
++)
35 DOUT
<< consists_str_arr_
[i
] << ',';
36 if (contains_itrans_p_list_
.size())
37 DOUT
<< "\nContains " ;
38 for (PCursor
<Input_translator
*> i (contains_itrans_p_list_
.top()); i
.ok (); i
++)
47 Input_translator::recursive_find (String nm
)
52 Input_translator
* r
=0;
54 PCursor
<Input_translator
*> i (contains_itrans_p_list_
.top());
55 for (; !r
&&i
.ok(); i
++)
57 if (i
->recursive_find (nm
))
65 Input_translator::find_itrans_l (String nm
)
67 for (PCursor
<Input_translator
*> i (contains_itrans_p_list_
.top()); i
.ok (); i
++)
68 if (i
->is_name_b (nm
))
75 Engraver_group_engraver
*
76 Input_translator::get_group_engraver_p()
78 assert (base_str_
== "Engraver");
79 Engraver_group_engraver
* grav_p
= (Engraver_group_engraver
*)
80 get_engraver_p (type_str_
);
82 for (int i
=0; i
< consists_str_arr_
.size(); i
++)
84 grav_p
->add (get_engraver_p (consists_str_arr_
[i
]));
86 grav_p
->itrans_l_
= this;
87 grav_p
->id_str_
= default_id_str_
;
91 Performer_group_performer
*
92 Input_translator::get_group_performer_p()
94 assert (base_str_
== "Performer");
95 Performer_group_performer
* perf_p
= (Performer_group_performer
*)
96 get_performer_p (type_str_
);
98 for (int i
=0; i
< consists_str_arr_
.size(); i
++)
100 perf_p
->add (get_performer_p (consists_str_arr_
[i
]));
102 perf_p
->itrans_l_
= this;
103 perf_p
->id_str_
= default_id_str_
;
108 Input_translator::accept_req_b()
110 return ! contains_itrans_p_list_
.size();
114 Input_translator::add (Input_translator
*ip
)
116 contains_itrans_p_list_
.bottom().add (ip
);
120 Input_translator::get_default_itrans_l()
122 if (contains_itrans_p_list_
.size())
123 return contains_itrans_p_list_
.top();
129 Input_translator_list::Input_translator_list (Input_translator_list
const &s
)
131 for (PCursor
<Input_translator
*> pc (s
); pc
.ok(); pc
++)
133 Input_translator
*q
= pc
;
134 Input_translator
*p
=new Input_translator (*q
) ;