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_bo_
= false;
24 Lily_stream::~Lily_stream()
28 warning( "lily indent level: " + String( indent_i_
), 0 );
32 Lily_stream::operator <<( String str
)
34 while ( str
.length_i() ) {
35 int max_i
= wrap_column_i_
- column_i_
;
36 String line
= str
.left_str( max_i
);
38 while ( max_i
&& ( max_i
< line
.length_i() )
39 && ( isalnum( line
[ max_i
] )
40 || ( line
[ max_i
] == '\\' ) ) )
43 line
= str
.left_str( max_i
+ 1 );
44 else // cannot break neatly...
45 max_i
= wrap_column_i_
- column_i_
- 1;
47 str
= str
.mid_str( max_i
+ 1, INT_MAX
);
49 check_comment( line
);
50 column_i_
+= line
.length_i();
51 if ( column_i_
>= wrap_column_i_
) {
53 if ( comment_mode_bo_
)
62 Lily_stream::operator <<( Midi_event
& midi_event_r
)
64 midi_event_r
.output_mudela( *this, false );
69 Lily_stream::check_comment( String str
)
71 int newline_i
= str
.index_last_i( '\n' );
72 if ( newline_i
!= -1 ) {
73 str
= str
.mid_str( newline_i
+1, INT_MAX
);
74 comment_mode_bo_
= false;
76 if ( str
.index_i( '%' ) != -1 )
77 comment_mode_bo_
= true;
83 *os_p_
<< "% Creator: " << version_str() << "\n";
84 *os_p_
<< "% Automatically generated, at ";
85 time_t t( time( 0 ) );
86 *os_p_
<< ctime( &t
);
87 *os_p_
<< "% from input file: ";
88 *os_p_
<< midi_parser_l_g
->filename_str_
;
100 Lily_stream::newline()
102 *os_p_
<< "\n" << String( '\t', indent_i_
);
103 column_i_
= indent_i_
* 8;
104 comment_mode_bo_
= false;
110 os_p_
= new ofstream( filename_str_
);
112 error ( "can't open `" + filename_str_
+ "\'", 0 );
116 Lily_stream::tnedni()
118 assert( indent_i_
> 0 );