]> git.donarmstrong.com Git - lilypond.git/blob - mi2mu/include/midi-parser.hh
release: 1.0.1
[lilypond.git] / mi2mu / include / midi-parser.hh
1 /*
2   midi-parser.hh -- declare Midi_parser
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9
10 #ifndef MIDI_PARSER_HH
11 #define MIDI_PARSER_HH
12
13 // must, gcc 2.7.2{,.1} hits ico on midi-track-parser.cc:134 (@Midi_note)
14 #define INLINES
15
16 #ifdef INLINES
17
18 #define next_byte() (inline_next_byte (__FUNCTION__))
19 #define peek_byte() (inline_peek_byte (__FUNCTION__))
20 #define forward_byte_L(n) (inline_forward_byte_L (__FUNCTION__, n))
21
22 #else
23
24 #define next_byte()\
25   ((info_l_->byte_L_ < info_l_->end_byte_L_ ?\
26     *info_l_->byte_L_++\
27    : (Byte const)exit (__FUNCTION__": unexpected EOF")));
28
29 #define peek_byte()\
30   ((info_l_->byte_L_ < info_l_->end_byte_L_ ?\
31     *info_l_->byte_L_\
32   : (Byte const)exit (__FUNCTION__": unexpected EOF")));
33
34 #define forward_byte_L(n) (inline_forward_byte_L (__FUNCTION__, n))
35
36 #endif
37
38 #include "proto.hh"
39 #include "moment.hh"
40 #include "mi2mu-proto.hh"
41
42 struct Midi_parser_info
43 {
44   Midi_parser_info();
45   int division_1_i_;
46   int format_i_;
47   int tracks_i_;
48   int errorlevel_i_;
49   Byte const* byte_L_;
50   Byte const* end_byte_L_;
51   Source_file* source_l_;
52   Mudela_score* score_l_;
53   Moment bar_mom_;
54 };
55
56 #include "string.hh"
57
58 class Midi_parser
59 {
60 public:
61   Midi_parser ();
62
63   Midi_parser_info* info_l_;
64
65 protected:
66 //  Byte const* inline_forward_byte_L (int n)
67   Byte const* inline_forward_byte_L (char const* fun, int n)
68   {
69     if (info_l_->byte_L_ + n < info_l_->end_byte_L_ )
70       {
71       Byte const* p = info_l_->byte_L_;
72       info_l_->byte_L_ += n;
73       return p;
74     }
75 //    exit (__FUNCTION__": unexpected EOF");
76     exit (String (fun) + ": unexpected EOF");
77     return 0;
78   }
79
80 #ifdef INLINES
81 //  Byte inline_next_byte () 
82   Byte inline_next_byte (char const* fun) 
83     {
84       if (info_l_->byte_L_ < info_l_->end_byte_L_)
85          return *info_l_->byte_L_++;
86 //    exit (__FUNCTION__": unexpected EOF");
87       exit (String (fun) + ": unexpected EOF");
88       return 0;
89     }
90
91 //  Byte inline_peek_byte ()
92   Byte inline_peek_byte (char const* fun)
93     {
94       if (info_l_->byte_L_ < info_l_->end_byte_L_)
95         return *info_l_->byte_L_;
96 //      exit (__FUNCTION__": unexpected EOF");
97       exit (String (fun) + ": unexpected EOF");
98       return 0;
99     }
100 #endif
101
102   int get_i (int);
103   String get_str (int);
104   unsigned get_u (int);
105   int get_var_i ();
106   int exit (String);
107   void error (String);
108   String message (String);
109   void warning (String);
110 };
111
112 #endif // MIDI_PARSER_HH