26 #if ! defined (octave_oct_stdstrm_h)
27 #define octave_oct_stdstrm_h 1
29 #include "octave-config.h"
38 template <
typename BUF_T,
typename STREAM_T,
typename FILE_T>
45 std::ios::openmode
m = std::ios::in | std::ios::out,
47 const std::string& encoding =
"utf-8",
48 typename BUF_T::close_fcn cf = BUF_T::file_close)
50 m_stream (
f ? new
STREAM_T (
f, cf) : nullptr), m_fnum (fid)
57 int seek (off_t offset,
int origin)
59 return m_stream ? m_stream->
seek (offset, origin) : -1;
64 off_t
tell () {
return m_stream ? m_stream->tell () : -1; }
68 bool eof ()
const {
return m_stream ? m_stream->eof () :
true; }
72 std::string
name ()
const {
return m_name; }
76 return (m_mode & std::ios::in) ? m_stream :
nullptr;
81 return (m_mode & std::ios::out) ? m_stream :
nullptr;
87 return m_stream ? (
const_cast<STREAM_T *
> (m_stream))->rdbuf () :
nullptr;
92 bool bad ()
const {
return m_stream ? m_stream->bad () :
true; }
103 m_stream->stream_close ();
129 std::ios::openmode
m = std::ios::in | std::ios::out,
131 const std::string& encoding =
"utf-8",
134 (
n,
f,
f ? fileno (
f) : -1,
m, ff, encoding, cf) { }
138 std::ios::openmode
m = std::ios::in | std::ios::out,
140 const std::string& encoding =
"utf-8",
153 #if defined (HAVE_ZLIB)
162 std::ios::openmode
m = std::ios::in | std::ios::out,
164 const std::string& encoding =
"utf-8",
167 (
n,
f, fid,
m, ff, encoding, cf) { }
170 create (
const std::string&
n, gzFile
f =
nullptr,
int fid = 0,
171 std::ios::openmode
m = std::ios::in | std::ios::out,
173 const std::string& encoding =
"utf-8",
188 OCTAVE_END_NAMESPACE(
octave)
virtual int seek(off_t offset, int origin)=0
static int file_close(FILE *m_f)
static int file_close(gzFile m_f)
stdiostream(const std::string &n, FILE *f=nullptr, std::ios::openmode m=std::ios::in|std::ios::out, mach_info::float_format ff=mach_info::native_float_format(), const std::string &encoding="utf-8", c_file_ptr_buf::close_fcn cf=c_file_ptr_buf::file_close)
static stream create(const std::string &n, FILE *f=nullptr, std::ios::openmode m=std::ios::in|std::ios::out, mach_info::float_format ff=mach_info::native_float_format(), const std::string &encoding="utf-8", c_file_ptr_buf::close_fcn cf=c_file_ptr_buf::file_close)
std::ios::openmode m_mode
tstdiostream(const std::string &n, FILE_T f=0, int fid=0, std::ios::openmode m=std::ios::in|std::ios::out, mach_info::float_format ff=mach_info::native_float_format(), const std::string &encoding="utf-8", typename BUF_T::close_fcn cf=BUF_T::file_close)
std::istream * input_stream()
std::ostream * output_stream()
zstdiostream(const std::string &n, gzFile f=nullptr, int fid=0, std::ios::openmode m=std::ios::in|std::ios::out, mach_info::float_format ff=mach_info::native_float_format(), const std::string &encoding="utf-8", c_zfile_ptr_buf::close_fcn cf=c_zfile_ptr_buf::file_close)
static stream create(const std::string &n, gzFile f=nullptr, int fid=0, std::ios::openmode m=std::ios::in|std::ios::out, mach_info::float_format ff=mach_info::native_float_format(), const std::string &encoding="utf-8", c_zfile_ptr_buf::close_fcn cf=c_zfile_ptr_buf::file_close)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T const F77_DBLE const F77_DBLE * f
float_format native_float_format()