4 // source file of the LilyPond music typesetter
6 // (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
8 // should i be named Mudela_stream?
12 Lily_stream::Lily_stream( String filename_str
)
14 filename_str_
= filename_str
;
17 comment_mode_b_
= false;
24 Lily_stream::~Lily_stream()
28 warning( "lily indent level: " + String( indent_i_
));
32 Lily_stream::operator <<( String str
)
34 static String word_sep_str
= "{} \t\n";
35 while ( str
.length_i() ) {
36 int i
= str
.index_any_i( word_sep_str
) + 1;
39 String word
= str
.left_str( i
);
40 str
= str
.mid_str( i
, str
.length_i() );
41 output_wrapped( word
);
47 Lily_stream::operator <<( Midi_event
& midi_event_r
)
49 midi_event_r
.output_mudela( *this, false );
57 *os_p_
<< "% Creator: " << mi2mu_version_str() << "\n";
58 *os_p_
<< "% Automatically generated, at ";
59 time_t t( time( 0 ) );
60 *os_p_
<< ctime( &t
);
61 *os_p_
<< "% from input file: ";
62 *os_p_
<< midi_parser_l_g
->filename_str_
;
65 *os_p_
<< "\\version \"0.1.0\";\n";
71 os_p_
= new ofstream( filename_str_
);
73 error ( "can't open `" + filename_str_
+ "\'");
77 Lily_stream::output( String str
)
79 for ( int i
= 0; i
< str
.length_i(); i
++ ) {
96 comment_mode_b_
= true;
106 *os_p_
<< String( '\t', indent_i_
);
107 column_i_
= indent_i_
* 8;
108 comment_mode_b_
= false;
119 Lily_stream::output_wrapped( String str
)
121 // enough room left -> doit
122 if ( column_i_
+ str
.length_i() <= wrap_column_i_
) {
127 // we're at BOL already; this will never fit -> doit
128 if ( column_i_
== indent_i_
* 8 ) {
134 // preserve comment mode
135 if ( comment_mode_b_
)
136 output( String( "\n%" ) );
138 output( String( "\n" ) );