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)
20 if (filename.length_i () && (filename != "-"))
21 os = new ofstream (filename.ch_C ());
23 os = new ostream (cout._strbuf);
25 error (_f ("can't open file: `%s'", filename));
30 close_file_stream (ostream* os)
35 warning (_ ("Error syncing file (disk full?)"));
41 Paper_stream::Paper_stream (String filename)
43 os_ = open_file_stream (filename);
46 outputting_comment_b_=false;
49 Paper_stream::~Paper_stream ()
51 close_file_stream (os_);
52 assert (nest_level == 0);
55 // print string. don't forget indent.
57 Paper_stream::operator << (String s)
59 for (char const *cp = s.ch_C (); *cp; cp++)
61 if (outputting_comment_b_)
66 outputting_comment_b_=false;
75 outputting_comment_b_ = true;
88 delete os_; // we want to see the remains.
89 assert (nest_level>=0);
92 /* don't break line if not nested; very ugly for ps */
104 if (line_len_i_ > MAXLINELEN)
113 //urg, for debugging only!!
119 Paper_stream::break_line ()
122 *os_ << to_str (' ', nest_level);
123 outputting_comment_b_ = false;