]> git.donarmstrong.com Git - lilypond.git/blob - src/inputscore.cc
release: 0.0.27
[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 "paper.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 Input_score::Input_score(Input_score const&)
30 {
31     assert(false);
32 }
33
34 Score*
35 Input_score::parse()
36 {
37     Paperdef* paper_p=new Paperdef(*paper_);
38     Score *s_p = new Score(paper_p);
39     s_p->define_spot_str_ = define_spot_str_;
40     s_p->errorlevel_i_ = errorlevel_i_;
41     Array<Staff*> parsed_staffs;
42     for (iter_top(staffs_,i); i.ok(); i++) {
43         Staff* staf_p=i->parse(s_p);
44         parsed_staffs.push(staf_p);
45         s_p->add(staf_p);
46     }
47     int j = 0;
48     for (iter_top(staffs_,i); i.ok(); i++,j++) {
49         parsed_staffs[j]->do_commands(commands_, i->commands_);
50     }
51     return s_p;
52 }
53
54 Input_score::~Input_score()
55 {
56     // TODO!
57 //should fix paper/symtabs to allow this deletion.
58 //    delete paper_;
59 }
60
61 Input_score::Input_score()
62 {
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 }