26 #if ! defined (octave_c_file_ptr_stream_h)
27 #define octave_c_file_ptr_stream_h 1
29 #include "octave-config.h"
46 : std::streambuf (),
f (f_arg), cf (cf_arg)
63 int_type pbackfail (int_type);
65 std::streamsize xsputn (
const char*, std::streamsize);
67 std::streamsize xsgetn (
char *, std::streamsize);
69 std::streampos seekoff (std::streamoff, std::ios::seekdir,
70 std::ios::openmode = std::ios::in | std::ios::out);
72 std::streampos seekpos (std::streampos,
73 std::ios::openmode = std::ios::in | std::ios::out);
83 int seek (off_t offset,
int origin);
87 void clear (
void) {
if (
f) clearerr (
f); }
89 static int file_close (FILE *
f);
104 template <
typename STREAM_T,
typename FILE_T,
typename BUF_T>
111 :
STREAM_T (nullptr), buf (new BUF_T (
f, cf)) { STREAM_T::init (buf); }
121 BUF_T *
rdbuf (
void) {
return buf; }
125 int seek (off_t offset,
int origin)
126 {
return buf ? buf->seek (offset, origin) : -1; }
128 off_t
tell (
void) {
return buf ? buf->tell () : -1; }
130 void clear (
void) {
if (buf) buf->clear (); STREAM_T::clear (); }
144 #if defined (HAVE_ZLIB)
146 #if defined (HAVE_ZLIB_H)
162 : std::streambuf (),
f (f_arg), cf (cf_arg)
179 int_type pbackfail (int_type);
181 std::streamsize xsputn (
const char*, std::streamsize);
183 std::streamsize xsgetn (
char *, std::streamsize);
185 std::streampos seekoff (std::streamoff, std::ios::seekdir,
186 std::ios::openmode = std::ios::in | std::ios::out);
188 std::streampos seekpos (std::streampos,
189 std::ios::openmode = std::ios::in | std::ios::out);
195 int buf_close (
void);
199 int seek (off_t offset,
int origin)
200 {
return f ? gzseek (
f, offset, origin) >= 0 : -1; }
202 off_t
tell (
void) {
return f ? gztell (
f) : -1; }
static void close_fcn(FILE *f)
c_file_ptr_stream< std::ostream, gzFile, c_zfile_ptr_buf > o_c_zfile_ptr_stream
c_file_ptr_stream< std::iostream, gzFile, c_zfile_ptr_buf > io_c_zfile_ptr_stream
c_file_ptr_stream< std::istream, FILE *, c_file_ptr_buf > i_c_file_ptr_stream
c_file_ptr_stream< std::iostream, FILE *, c_file_ptr_buf > io_c_file_ptr_stream
c_file_ptr_stream< std::ostream, FILE *, c_file_ptr_buf > o_c_file_ptr_stream
c_file_ptr_stream< std::istream, gzFile, c_zfile_ptr_buf > i_c_zfile_ptr_stream
c_file_ptr_buf(FILE *f_arg, close_fcn cf_arg=file_close)
std::streambuf::int_type int_type
c_file_ptr_buf(const c_file_ptr_buf &)=delete
c_file_ptr_stream(FILE_T f, typename BUF_T::close_fcn cf=BUF_T::file_close)
int seek(off_t offset, int origin)
c_file_ptr_stream(const c_file_ptr_stream &)=delete
c_zfile_ptr_buf(const c_zfile_ptr_buf &)=delete
c_zfile_ptr_buf(gzFile f_arg, close_fcn cf_arg=file_close)
static int file_close(gzFile f)
int seek(off_t offset, int origin)
std::streambuf::int_type int_type
F77_RET_T const F77_DBLE const F77_DBLE * f