26#if ! defined (octave_c_file_ptr_stream_h)
27#define octave_c_file_ptr_stream_h 1
29#include "octave-config.h"
34#if defined (HAVE_ZLIB_H)
46 typedef int (*close_fcn) (FILE *);
53 : std::streambuf (), m_f (
f), m_cf (cf)
60 int_type overflow (int_type);
66 int_type pbackfail (int_type);
68 std::streamsize xsputn (
const char *, std::streamsize);
70 std::streamsize xsgetn (
char *, std::streamsize);
72 std::streampos seekoff (std::streamoff, std::ios::seekdir,
73 std::ios::openmode = std::ios::in | std::ios::out);
75 std::streampos seekpos (std::streampos,
76 std::ios::openmode = std::ios::in | std::ios::out);
86 int seek (off_t offset,
int origin);
90 void clear () {
if (m_f) clearerr (m_f); }
92 static int file_close (FILE *m_f);
107template <
typename STREAM_T,
typename FILE_T,
typename BUF_T>
115 typename BUF_T::close_fcn m_cf = BUF_T::file_close)
116 :
STREAM_T (nullptr), m_buf (new BUF_T (m_f, m_cf))
117 { STREAM_T::init (m_buf); }
127 int seek (off_t offset,
int origin)
128 {
return m_buf ? m_buf->seek (offset, origin) : -1; }
130 off_t
tell () {
return m_buf ? m_buf->tell () : -1; }
132 void clear () {
if (m_buf) m_buf->clear (); STREAM_T::clear (); }
147#if defined (HAVE_ZLIB)
162 : std::streambuf (),
m_f (
f),
m_cf (cf)
177 std::streamsize
xsputn (
const char *, std::streamsize);
179 std::streamsize
xsgetn (
char *, std::streamsize);
181 std::streampos
seekoff (std::streamoff, std::ios::seekdir,
182 std::ios::openmode = std::ios::in | std::ios::out);
184 std::streampos
seekpos (std::streampos,
185 std::ios::openmode = std::ios::in | std::ios::out);
195 int seek (off_t offset,
int origin)
196 {
return m_f ? gzseek (
m_f, offset, origin) >= 0 : -1; }
224OCTAVE_END_NAMESPACE(octave)
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, close_fcn cf=file_close)
std::streambuf::int_type int_type
int seek(off_t offset, int origin)
c_file_ptr_stream()=delete
c_file_ptr_stream(FILE_T m_f, typename BUF_T::close_fcn m_cf=BUF_T::file_close)
std::streampos seekpos(std::streampos, std::ios::openmode=std::ios::in|std::ios::out)
std::streamsize xsgetn(char *, std::streamsize)
static int file_close(gzFile m_f)
c_zfile_ptr_buf(gzFile f, close_fcn cf=file_close)
std::streampos seekoff(std::streamoff, std::ios::seekdir, std::ios::openmode=std::ios::in|std::ios::out)
int_type pbackfail(int_type)
int_type overflow(int_type)
int seek(off_t offset, int origin)
std::streamsize xsputn(const char *, std::streamsize)
std::streambuf::int_type int_type
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T const F77_DBLE const F77_DBLE * f