]> git.donarmstrong.com Git - lilypond.git/blob - src/inputstaff.cc
release: 0.0.30
[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 "staff.hh"
9 #include "complexstaff.hh"
10 #include "lexer.hh"
11 #include "lyricstaff.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     defined_ch_c_l_ = 0;
26 }
27
28 void
29 Input_staff::add(Input_music*m)
30 {
31     music_.bottom().add(m);
32 }
33
34 Staff*
35 Input_staff::parse(Score*score_l)
36 {
37     Staff *p=0;
38 #if 0
39     if (type == "simple")
40         p = new Melodic_staff;
41     else if (type == "rhythmic")
42         p = new Rhythmic_staff;
43     else
44 #endif
45         
46         if (type == "melodic")
47         p = new Complex_staff;
48     else if (type == "lyric")
49         p = new Lyric_staff;
50     else
51         error( "Unknown staff-type `" + type +"\'", 0 );
52
53     p->score_l_ = score_l;
54     p->define_spot_str_ = "";   // todo
55     
56     for (iter_top(music_,i); i.ok(); i++) {
57         Voice_list vl = i->convert();
58         p->add(vl);
59     }
60     
61     {
62         Array<String> mark_arr;
63         Array<Moment> moment_arr;
64         p->get_marks(mark_arr, moment_arr);
65         score_l->add_marks(mark_arr, moment_arr);
66     }
67     
68     return p;
69 }
70
71 Input_staff::Input_staff(Input_staff const&s)
72 {
73     
74     for (iter_top(s.commands_,i); i.ok(); i++)
75         commands_.bottom().add(new Input_command(**i));
76     for (iter_top(s.music_,i); i.ok(); i++)
77         add(i->clone());
78     defined_ch_c_l_ = s.defined_ch_c_l_;
79     type = s.type;
80 }
81
82 void
83 Input_staff::print() const
84 {
85 #ifndef NPRINT
86     mtor << "Input_staff {\n";
87     for (iter_top(commands_,i); i.ok(); i++)
88         i->print();
89     for (iter_top(music_,i); i.ok(); i++)
90         i->print();
91     mtor << "}\n";
92 #endif
93 }