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)
61 int seek (off_t offset,
int origin)
63 return m_stream ? m_stream->seek (offset, origin) : -1;
68 off_t
tell (
void) {
return m_stream ? m_stream->tell () : -1; }
72 bool eof (
void)
const {
return m_stream ? m_stream->eof () :
true; }
76 std::string
name (
void)
const {
return m_name; }
80 return (m_mode & std::ios::in) ? m_stream :
nullptr;
85 return (m_mode & std::ios::out) ? m_stream :
nullptr;
91 return m_stream ? (
const_cast<STREAM_T *
> (m_stream))->rdbuf () :
nullptr;
96 bool bad (
void)
const {
return m_stream ? m_stream->bad () :
true; }
107 m_stream->stream_close ();
133 std::ios::openmode
m = std::ios::in | std::ios::out,
135 const std::string& encoding =
"utf-8",
138 (
n,
f,
f ? fileno (
f) : -1,
m, ff, encoding, cf) { }
142 std::ios::openmode
m = std::ios::in | std::ios::out,
144 const std::string& encoding =
"utf-8",
161 #if defined (HAVE_ZLIB)
170 std::ios::openmode
m = std::ios::in | std::ios::out,
172 const std::string& encoding =
"utf-8",
175 (
n,
f, fid,
m, ff, encoding, cf) { }
178 create (
const std::string&
n, gzFile
f =
nullptr,
int fid = 0,
179 std::ios::openmode
m = std::ios::in | std::ios::out,
181 const std::string& encoding =
"utf-8",
202 #if defined (OCTAVE_PROVIDE_DEPRECATED_SYMBOLS)
204 OCTAVE_DEPRECATED (7,
"use 'octave::stdiostream' instead")
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)
stdiostream(const stdiostream &)=delete
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)
~stdiostream(void)=default
std::istream * input_stream(void)
int file_number(void) const
std::ios::openmode m_mode
tstdiostream(const tstdiostream &)=delete
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)
BUF_T * rdbuf(void) const
std::string name(void) const
int seek(off_t offset, int origin)
std::ostream * output_stream(void)
~zstdiostream(void)=default
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)
zstdiostream(const zstdiostream &)=delete
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
F77_RET_T const F77_DBLE const F77_DBLE * f
float_format native_float_format(void)