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