2 paper-stream.cc -- implement Paper_stream
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "paper-stream.hh"
15 const int MAXLINELEN
= 200;
18 open_file_stream (String filename
)
21 if (filename
.length_i () && (filename
!= "-"))
22 os
= new ofstream (filename
.ch_C ());
24 os
= new ostream (cout
._strbuf
);
26 error (_f ("can't open file: `%s'", filename
));
31 close_file_stream (ostream
*os
)
36 warning (_ ("Error syncing file (disk full?)"));
42 Paper_stream::Paper_stream (String filename
)
44 os_
= open_file_stream (filename
);
47 outputting_comment_b_
=false;
50 Paper_stream::~Paper_stream ()
52 close_file_stream (os_
);
53 assert (nest_level
== 0);
56 // print string. don't forget indent.
58 Paper_stream::operator << (String s
)
60 for (char const *cp
= s
.ch_C (); *cp
; cp
++)
62 if (outputting_comment_b_
)
67 outputting_comment_b_
=false;
76 outputting_comment_b_
= true;
89 delete os_
; // we want to see the remains.
90 assert (nest_level
>=0);
93 /* don't break line if not nested; very ugly for ps */
105 if (line_len_i_
> MAXLINELEN
)
114 //urg, for debugging only!!
120 Paper_stream::break_line ()
123 *os_
<< to_str (' ', nest_level
);
124 outputting_comment_b_
= false;