source file of the GNU LilyPond music typesetter
- (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
*/
#include "midi-stream.hh"
file_name_string_ = file_name;
out_file_ = fopen (file_name.c_str (), "wb");
if (!out_file_)
- error (_f ("can't open for write: %s: %s", file_name, strerror (errno)));
+ error (_f ("cannot open for write: %s: %s", file_name, strerror (errno)));
}
Midi_stream::~Midi_stream ()
fclose (out_file_);
}
-Midi_stream &
-Midi_stream::operator << (string str)
+void
+Midi_stream::write (string str)
{
size_t sz = sizeof (Byte);
size_t n = str.length ();
size_t written = fwrite (str.data (), sz, n, out_file_);
if (written != sz * n)
- warning (_ ("can't write to file: `%s'"));
-
- return *this;
+ warning (_ ("cannot write to file: `%s'"));
}
-Midi_stream &
-Midi_stream::operator << (Midi_item const &midi_c_r)
+void
+Midi_stream::write (Midi_item const &midi)
{
- string str = midi_c_r.to_string ();
-
- // ugh, should have separate debugging output with Midi*::print routines
- if (do_midi_debugging_global)
- {
- str = String_convert::bin2hex (str) + "\n";
- for (ssize i = str.find ("0a"); i != NPOS; i = str.find ("0a"))
- {
- str[i] = '\n';
- str[i + 1] = '\t';
- }
- }
+ string str = midi.to_string ();
- return operator << (str);
+ return write (str);
}
-Midi_stream &
-Midi_stream::operator << (int i)
+void
+Midi_stream::write (int i)
{
- // output binary string ourselves
- *this << Midi_item::i2varint_string (i);
- return *this;
+ write (Midi_item::i2varint_string (i));
}