Browse Source

add write()

David Rose 16 years ago
parent
commit
cfbac6e51a
2 changed files with 14 additions and 0 deletions
  1. 12 0
      dtool/src/prc/streamWriter.I
  2. 2 0
      dtool/src/prc/streamWriter.h

+ 12 - 0
dtool/src/prc/streamWriter.I

@@ -415,3 +415,15 @@ INLINE void StreamWriter::
 flush() {
   _out->flush();
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: StreamWriter::write
+//       Access: Published
+//  Description: A synonym of append_data().  This is useful when
+//               assigning the StreamWriter to sys.stderr and/or
+//               sys.stdout in Python.
+////////////////////////////////////////////////////////////////////
+INLINE void StreamWriter::
+write(const string &data) {
+  append_data(data.data(), data.length());
+}

+ 2 - 0
dtool/src/prc/streamWriter.h

@@ -76,6 +76,8 @@ PUBLISHED:
 
   BLOCKING INLINE void flush();
 
+  BLOCKING INLINE void write(const string &str);
+
 private:
   ostream *_out;
   bool _owns_stream;