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)
47 typedef int (*close_fcn) (FILE *);
54 : std::streambuf (), m_f (
f), m_cf (cf)
61 int_type overflow (int_type);
67 int_type pbackfail (int_type);
69 std::streamsize xsputn (
const char *, std::streamsize);
71 std::streamsize xsgetn (
char *, std::streamsize);
73 std::streampos seekoff (std::streamoff, std::ios::seekdir,
74 std::ios::openmode = std::ios::in | std::ios::out);
76 std::streampos seekpos (std::streampos,
77 std::ios::openmode = std::ios::in | std::ios::out);
87 int seek (off_t offset,
int origin);
91 void clear () {
if (m_f) clearerr (m_f); }
93 static int file_close (FILE *m_f);
108 template <
typename STREAM_T,
typename FILE_T,
typename BUF_T>
117 typename BUF_T::close_fcn m_cf = BUF_T::file_close)
118 :
STREAM_T (nullptr), m_buf (new BUF_T (m_f, m_cf))
119 { STREAM_T::init (m_buf); }
129 int seek (off_t offset,
int origin)
130 {
return m_buf ? m_buf->seek (offset, origin) : -1; }
132 off_t
tell () {
return m_buf ? m_buf->tell () : -1; }
134 void clear () {
if (m_buf) m_buf->clear (); STREAM_T::clear (); }
149 #if defined (HAVE_ZLIB)
158 typedef int (*close_fcn) (gzFile);
165 : std::streambuf (), m_f (
f), m_cf (cf)
172 int_type overflow (int_type);
178 int_type pbackfail (int_type);
180 std::streamsize xsputn (
const char *, std::streamsize);
182 std::streamsize xsgetn (
char *, std::streamsize);
184 std::streampos seekoff (std::streamoff, std::ios::seekdir,
185 std::ios::openmode = std::ios::in | std::ios::out);
187 std::streampos seekpos (std::streampos,
188 std::ios::openmode = std::ios::in | std::ios::out);
198 int seek (off_t offset,
int origin)
199 {
return m_f ? gzseek (m_f, offset, origin) >= 0 : -1; }
201 off_t
tell () {
return m_f ? gztell (m_f) : -1; }
203 void clear () {
if (m_f) gzclearerr (m_f); }
205 static int file_close (gzFile m_f) { return ::gzclose (m_f); }
227 OCTAVE_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)
static int file_close(gzFile m_f)
c_zfile_ptr_buf(gzFile f, close_fcn cf=file_close)
int seek(off_t offset, int origin)
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