2 paper-stream.cc -- implement Paper_stream
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
14 #include "paper-stream.hh"
17 const int MAXLINELEN = 200;
19 Paper_stream::Paper_stream (String filename)
21 if (filename.length_i () && (filename != "-"))
22 os = new ofstream (filename.ch_C ());
24 // os = new ostream (cout.ostreambuf ());
25 os = new ostream (cout._strbuf);
27 error (_f ("can't open file: `%s\'", filename));
30 outputting_comment=false;
34 Paper_stream::~Paper_stream ()
39 warning (_ ("error syncing file (disk full?)"));
43 assert (nest_level == 0);
46 // print string. don't forget indent.
48 Paper_stream::operator << (Scalar s)
50 for (char const *cp = s.ch_C (); *cp; cp++)
52 if (outputting_comment)
57 outputting_comment=false;
66 outputting_comment = true;
79 delete os; // we want to see the remains.
80 assert (nest_level>=0);
89 if (line_len_i_ > MAXLINELEN)
102 Paper_stream::break_line ()
105 *os << to_str (' ', nest_level);