]> git.donarmstrong.com Git - lilypond.git/blob - src/inputscore.cc
release: 0.0.31
[lilypond.git] / src / inputscore.cc
1 #include "debug.hh"
2 #include "inputcommand.hh"
3 #include "inputscore.hh"
4 #include "inputstaff.hh"
5 #include "score.hh"
6 #include "paperdef.hh"
7 #include "staff.hh"
8
9 void
10 Input_score::add(Array<Input_command*> &s)
11 {
12     commands_.bottom().add(get_reset_command());
13     for (int i=0; i < s.size(); i++)
14         commands_.bottom().add(s[i]);
15 }
16
17 void
18 Input_score::add(Input_staff*s)
19 {
20     staffs_.bottom().add(s);
21 }
22
23 void
24 Input_score::set(Paperdef*p)
25 {
26     delete paper_;
27     paper_ = p;
28 }
29
30 Input_score::Input_score(Input_score const&)
31 {
32     assert(false);
33 }
34
35 Score*
36 Input_score::parse()
37 {
38     Paperdef* paper_p=new Paperdef(*paper_);
39     Score *s_p = new Score(paper_p);
40     s_p->defined_ch_c_l_= defined_ch_c_l_;
41     s_p->errorlevel_i_ = errorlevel_i_;
42     Array<Staff*> parsed_staffs;
43     for (iter_top(staffs_,i); i.ok(); i++) {
44         Staff* staf_p=i->parse(s_p);
45         parsed_staffs.push(staf_p);
46         s_p->add(staf_p);
47     }
48     int j = 0;
49     for (iter_top(staffs_,i); i.ok(); i++,j++) {
50         parsed_staffs[j]->do_commands(commands_, i->commands_);
51     }
52     return s_p;
53 }
54
55 Input_score::~Input_score()
56 {
57     delete paper_;
58 }
59
60 Input_score::Input_score()
61 {
62     defined_ch_c_l_=0;
63     paper_= 0;
64     errorlevel_i_ = 0;
65 }
66
67 void
68 Input_score::print()const
69 {
70     #ifndef NPRINT
71     mtor << "Input_score {\n";
72     for (iter_top(staffs_,i); i.ok(); i++) {
73         i->print();
74     }
75     mtor << "}\n";
76 #endif
77 }