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 *);
52 : std::streambuf (), m_f (
f), m_cf (cf)
69 int_type pbackfail (int_type);
71 std::streamsize xsputn (
const char *, std::streamsize);
73 std::streamsize xsgetn (
char *, std::streamsize);
75 std::streampos seekoff (std::streamoff, std::ios::seekdir,
76 std::ios::openmode = std::ios::in | std::ios::out);
78 std::streampos seekpos (std::streampos,
79 std::ios::openmode = std::ios::in | std::ios::out);
89 int seek (off_t offset,
int origin);
93 void clear (
void) {
if (m_f) clearerr (m_f); }
95 static int file_close (FILE *m_f);
110 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 BUF_T *
rdbuf (
void) {
return m_buf; }
133 int seek (off_t offset,
int origin)
134 {
return m_buf ? m_buf->seek (offset, origin) : -1; }
136 off_t
tell (
void) {
return m_buf ? m_buf->tell () : -1; }
138 void clear (
void) {
if (m_buf) m_buf->clear (); STREAM_T::clear (); }
153 #if defined (HAVE_ZLIB)
162 typedef int (*close_fcn) (gzFile);
167 : std::streambuf (), m_f (
f), m_cf (cf)
184 int_type pbackfail (int_type);
186 std::streamsize xsputn (
const char *, std::streamsize);
188 std::streamsize xsgetn (
char *, std::streamsize);
190 std::streampos seekoff (std::streamoff, std::ios::seekdir,
191 std::ios::openmode = std::ios::in | std::ios::out);
193 std::streampos seekpos (std::streampos,
194 std::ios::openmode = std::ios::in | std::ios::out);
200 int buf_close (
void);
204 int seek (off_t offset,
int origin)
205 {
return m_f ? gzseek (m_f, offset, origin) >= 0 : -1; }
207 off_t
tell (
void) {
return m_f ? gztell (m_f) : -1; }
209 void clear (
void) {
if (m_f) gzclearerr (m_f); }
211 static int file_close (gzFile m_f) { return ::gzclose (m_f); }
235 #if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)
237 OCTAVE_DEPRECATED (7,
"use 'octave::i_c_file_ptr_stream' instead")
252 # if defined (HAVE_ZLIB)
254 OCTAVE_DEPRECATED (7,
"use 'octave::i_c_zfile_ptr_stream' instead")
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
c_file_ptr_buf(const c_file_ptr_buf &)=delete
int seek(off_t offset, int origin)
c_file_ptr_stream(FILE_T m_f, typename BUF_T::close_fcn m_cf=BUF_T::file_close)
c_file_ptr_stream(const c_file_ptr_stream &)=delete
c_zfile_ptr_buf(const c_zfile_ptr_buf &)=delete
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