]> git.donarmstrong.com Git - lilypond.git/blob - src/inputstaff.cc
70d91c669f8ce9d4d5f01f899b1cf6a23c6aff6f
[lilypond.git] / src / inputstaff.cc
1 #include "getcommand.hh"
2 #include "debug.hh"
3 #include "score.hh"
4 #include "inputmusic.hh"
5 #include "inputstaff.hh"
6 #include "inputcommand.hh"
7 #include "staffcommands.hh"
8 #include "melodicstaff.hh"
9 #include "rhythmstaff.hh"
10 #include "lyricstaff.hh"
11 #include "staff.hh"
12
13 void
14 Input_staff::add(Array<Input_command*> &s)
15 {
16     commands_.bottom().add(get_reset_command());
17     for (int i=0; i < s.size(); i++)
18         commands_.bottom().add(s[i]);
19     s.set_size(0);
20 }
21
22 Input_staff::Input_staff(String s)
23 {
24     type= s;
25 }
26
27 void
28 Input_staff::add(Input_music*m)
29 {
30     music_.bottom().add(m);
31 }
32
33 Staff*
34 Input_staff::parse(Score*score_l)
35 {
36     Staff *p=0;
37     
38     if (type == "melodic")
39         p = new Melodic_staff;
40     else if (type == "rhythmic")
41         p = new Rhythmic_staff;
42     else if (type == "lyric")
43         p = new Lyric_staff;
44     p->score_l_ = score_l;
45     p->define_spot_str_ = define_spot_str_;
46     
47     for (iter_top(music_,i); i.ok(); i++) {
48         Voice_list vl = i->convert();
49         p->add(vl);
50     }
51     
52     {
53         Array<String> mark_arr;
54         Array<Moment> moment_arr;
55         p->get_marks(mark_arr, moment_arr);
56         score_l->add_marks(mark_arr, moment_arr);
57     }
58     
59     return p;
60 }
61
62 Input_staff::Input_staff(Input_staff const&s)
63 {
64     for (iter_top(s.commands_,i); i.ok(); i++)
65         commands_.bottom().add(new Input_command(**i));
66     for (iter_top(s.music_,i); i.ok(); i++)
67         add(i->clone());
68     define_spot_str_ = s.define_spot_str_;
69     type = s.type;
70 }
71
72 void
73 Input_staff::print() const
74 {
75 #ifndef NPRINT
76     mtor << "Input_staff {\n";
77     for (iter_top(commands_,i); i.ok(); i++)
78         i->print();
79     for (iter_top(music_,i); i.ok(); i++)
80         i->print();
81     mtor << "}\n";
82 #endif
83 }