Mercurial > hg > octave-nkf
diff src/c-file-ptr-stream.h @ 3775:13905c3a24af
[project @ 2001-02-06 01:56:59 by jwe]
author | jwe |
---|---|
date | Tue, 06 Feb 2001 01:57:06 +0000 |
parents | 08fe5f74c7d4 |
children | bbe74a066592 |
line wrap: on
line diff
--- a/src/c-file-ptr-stream.h +++ b/src/c-file-ptr-stream.h @@ -28,29 +28,43 @@ #endif #include <iostream> -#include <stdio.h> +#include <fstream> +#include <cstdio> class c_file_ptr_buf : public std::filebuf { public: +#if !defined (CXX_ISO_COMPLIANT_LIBRARY) + typedef int int_type; +#endif + typedef int (*close_fcn) (FILE *); FILE* stdiofile (void) const { return f; } c_file_ptr_buf (FILE *f_arg, close_fcn cf_arg = ::fclose) - : std::filebuf (f_arg ? fileno (f_arg) : -1), f (f_arg), cf (cf_arg) { } + : +#ifdef __SUNPRO_CC + std::filebuf (f_arg ? fileno (f_arg) : -1), +#else + std::filebuf (f_arg ? fileno (f_arg) : -1, + 0, std::ios::in | std::ios::out), +#endif + f (f_arg), cf (cf_arg), + fd (f_arg ? fileno (f_arg) : -1) + { } ~c_file_ptr_buf (void); - int overflow (int); + int_type overflow (int_type); - int underflow (void); + int_type underflow (void); - int uflow (void); + int_type uflow (void); - int pbackfail (int); + int_type pbackfail (int_type); std::streamsize xsputn (const char*, std::streamsize); @@ -68,11 +82,17 @@ int close (void); + int file_number () const { return fd; } + protected: FILE *f; close_fcn cf; + +private: + + int fd; }; class @@ -81,7 +101,7 @@ public: i_c_file_ptr_stream (FILE* f, c_file_ptr_buf::close_fcn cf = ::fclose) - : std::istream (), buf (new c_file_ptr_buf (f, cf)) { init (buf); } + : std::istream (0), buf (new c_file_ptr_buf (f, cf)) { init (buf); } ~i_c_file_ptr_stream (void) { delete buf; buf = 0; } @@ -100,7 +120,7 @@ public: o_c_file_ptr_stream (FILE* f, c_file_ptr_buf::close_fcn cf = ::fclose) - : std::ostream (), buf (new c_file_ptr_buf (f, cf)) { init (buf); } + : std::ostream (0), buf (new c_file_ptr_buf (f, cf)) { init (buf); } ~o_c_file_ptr_stream (void) { delete buf; buf = 0; }