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;
17 Paper_stream::Paper_stream (String filename)
19 if (filename.length_i () && (filename != "-"))
20 os = new ofstream (filename.ch_C ());
22 // os = new ostream (cout.ostreambuf ());
23 os = new ostream (cout._strbuf);
25 error (_f ("Can't open file: `%s'", filename));
28 outputting_comment_b_=false;
31 Paper_stream::~Paper_stream ()
36 warning (_ ("Error syncing file (disk full?)"));
40 assert (nest_level == 0);
43 // print string. don't forget indent.
45 Paper_stream::operator << (String s)
47 for (char const *cp = s.ch_C (); *cp; cp++)
49 if (outputting_comment_b_)
54 outputting_comment_b_=false;
63 outputting_comment_b_ = true;
76 delete os; // we want to see the remains.
77 assert (nest_level>=0);
80 /* don't break line if not nested; very ugly for ps */
92 if (line_len_i_ > MAXLINELEN)
101 //urg, for debugging only!!
107 Paper_stream::break_line ()
110 *os << to_str (' ', nest_level);
111 outputting_comment_b_ = false;