diff src/c-file-ptr-stream.h @ 4326:1cae4472c624

[project @ 2003-02-15 23:14:47 by jwe]
author jwe
date Sat, 15 Feb 2003 23:14:47 +0000
parents da7226ca8b91
children 19b8225bdaa2
line wrap: on
line diff
--- a/src/c-file-ptr-stream.h	Sat Feb 15 04:54:57 2003 +0000
+++ b/src/c-file-ptr-stream.h	Sat Feb 15 23:14:47 2003 +0000
@@ -103,7 +103,7 @@
 
   c_file_ptr_buf *rdbuf (void) { return buf; }
 
-  void close (void);
+  void close (void) { if (buf) buf->close (); }
 
 private:
 
@@ -123,7 +123,27 @@
 
   c_file_ptr_buf *rdbuf (void) { return buf; }
 
-  void close (void);
+  void close (void) { if (buf) buf->close (); }
+
+private:
+
+  c_file_ptr_buf *buf;
+};
+
+class
+io_c_file_ptr_stream : public std::iostream
+{
+public:
+
+  io_c_file_ptr_stream (FILE* f,
+			c_file_ptr_buf::close_fcn cf = c_file_ptr_buf::fclose)
+    : std::iostream (0), buf (new c_file_ptr_buf (f, cf)) { init (buf); }
+
+  ~io_c_file_ptr_stream (void) { delete buf; buf = 0; }
+
+  c_file_ptr_buf *rdbuf (void) { return buf; }
+
+  void close (void) { if (buf) buf->close (); }
 
 private: