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>
13 #include "paper-stream.hh"
16 const int MAXLINELEN = 200;
18 Paper_stream::Paper_stream (String filename)
20 if (filename.length_i () && (filename != "-"))
21 os = new ofstream (filename.ch_C ());
23 // os = new ostream (cout.ostreambuf ());
24 os = new ostream (cout._strbuf);
26 error (_f ("can't open file: `%s\'", filename));
29 outputting_comment=false;
33 Paper_stream::~Paper_stream ()
38 warning (_ ("error syncing file (disk full?)"));
42 assert (nest_level == 0);
45 // print string. don't forget indent.
47 Paper_stream::operator << (Scalar s)
49 for (char const *cp = s.ch_C (); *cp; cp++)
51 if (outputting_comment)
56 outputting_comment=false;
65 outputting_comment = true;
78 delete os; // we want to see the remains.
79 assert (nest_level>=0);
82 /* don't break line if not nested; very ugly for ps */
93 if (line_len_i_ > MAXLINELEN)
106 Paper_stream::break_line ()
109 *os << to_str (' ', nest_level);