23 #if !defined (octave_oct_stream_h)
24 #define octave_oct_stream_h 1
51 whitespace_conversion = 1,
52 literal_conversion = 2
56 char typ =
'\0',
char mod =
'\0',
57 const std::string& ch_class = std::string ())
59 modifier (
mod), char_class (ch_class) { }
63 type (e.
type), modifier (e.modifier), char_class (e.char_class) { }
128 {
return list.length () > 0 ? list.elem (curr_idx) : 0; }
134 if (curr_idx >= list.length ())
144 void printme (
void)
const;
146 bool ok (
void)
const {
return (nconv >= 0); }
148 operator bool ()
const {
return ok (); }
150 bool all_character_conversions (
void);
152 bool all_numeric_conversions (
void);
170 void add_elt_to_list (
int width,
bool discard,
char type,
char modifier,
172 const std::string& char_class = std::string ());
174 void process_conversion (
const std::string& s,
size_t& i,
size_t n,
175 int& width,
bool& discard,
char& type,
178 int finish_conversion (
const std::string& s,
size_t& i,
size_t n,
179 int& width,
bool discard,
char& type,
194 int p = -1,
const std::string&
f = std::string (),
195 char typ =
'\0',
char mod =
'\0')
196 :
text (
strsave (txt)), args (n), fw (
w), prec (p), flags (
f),
201 flags (e.flags),
type (e.
type), modifier (e.modifier) { }
263 {
return list.
length () > 0 ? list.
elem (curr_idx) : 0; }
269 if (curr_idx >= list.
length ())
282 void printme (
void)
const;
284 bool ok (
void)
const {
return (nconv >= 0); }
286 operator bool ()
const {
return ok (); }
304 void add_elt_to_list (
int args,
const std::string& flags,
int fw,
305 int prec,
char type,
char modifier,
308 void process_conversion (
const std::string& s,
size_t& i,
size_t n,
309 int& args, std::string& flags,
int& fw,
310 int& prec,
char& modifier,
char&
type,
313 void finish_conversion (
const std::string& s,
size_t& i,
int args,
314 const std::string& flags,
int fw,
int prec,
315 char modifier,
char&
type,
338 : count (0), md (arg_md), flt_fmt (ff), fail (false), open_state (true),
349 virtual int seek (off_t offset,
int origin) = 0;
353 virtual off_t
tell (
void) = 0;
357 virtual bool eof (
void)
const = 0;
361 virtual std::string
name (
void)
const = 0;
377 bool is_open (
void)
const {
return open_state; }
394 if (
name () ==
"stdin")
396 else if (
name () ==
"stdout")
398 else if (
name () ==
"stderr")
404 bool ok (
void)
const {
return ! fail; }
412 int mode (
void)
const {
return md; }
418 void error (
const std::string& msg);
419 void error (
const std::string& who,
const std::string& msg);
453 std::string do_gets (
octave_idx_type max_len,
bool& err,
bool strip_newline,
454 const std::string& who );
457 const std::string& who );
459 const std::string& who );
460 off_t
skipl (off_t count,
bool& err,
const std::string& who );
465 const std::string& who );
471 const std::string& who );
474 const std::string& who );
482 int nsa,
int sa_1,
int sa_2,
484 const std::string& who);
487 const std::string& who );
490 const std::string& who );
492 int puts (
const std::string& s,
const std::string& who );
523 const std::string& who );
525 const std::string& who );
528 const std::string& who );
530 const std::string& who );
532 off_t
skipl (off_t count,
bool& err,
const std::string& who );
534 const std::string& who );
536 int seek (off_t offset,
int origin);
558 bool write_bytes (
const void *data,
size_t n_elts);
575 const std::string& who );
578 const std::string& who );
581 const std::string& who );
584 const std::string& who );
586 int puts (
const std::string& s,
const std::string& who );
589 bool eof (
void)
const;
593 std::string
error (
bool clear =
false)
596 return error (clear, err_num);
617 std::string
name (
void)
const;
619 int mode (
void)
const;
685 static bool instance_ok (
void);
690 lookup (
int fid,
const std::string& who = std::string ());
695 static int remove (
int fid,
const std::string& who = std::string ());
697 const std::string& who = std::string ());
704 static std::string list_open_files (
void);
725 const std::string& who = std::string ())
const;
727 const std::string& who = std::string ())
const;
729 int do_remove (
int fid,
const std::string& who = std::string ());
731 const std::string& who = std::string ());
733 void do_clear (
bool flush =
true);
738 std::string do_list_open_files (
void)
const;
void invalid_operation(const std::string &who, const char *rw)
static void clear(octave_shlib &oct_file)
virtual ~octave_base_stream(void)
bool skip_bytes(size_t n_elts)
octave_value read(const Array< double > &size, octave_idx_type block_size, oct_data_conv::data_type input_type, oct_data_conv::data_type output_type, octave_idx_type skip, oct_mach_info::float_format flt_fmt, octave_idx_type &count)
octave_base_stream(std::ios::openmode arg_md=std::ios::in|std::ios::out, oct_mach_info::float_format ff=oct_mach_info::native_float_format())
static octave_stream_list * instance
std::string gets(octave_idx_type max_len, bool &err, const std::string &who)
int seek(off_t offset, int origin)
virtual std::istream * input_stream(void)
octave_int< T > mod(const octave_int< T > &x, const octave_int< T > &y)
static char * strsave(const char *s)
oct_mach_info::float_format flt_fmt
void error(const char *fmt,...)
off_t skipl(off_t count, bool &err, const std::string &who)
T & elem(octave_idx_type n)
octave_idx_type lookup(const T *x, octave_idx_type n, T y)
void error(const char *msg)
virtual void do_close(void)
std::istream * input_stream(void)
F77_RET_T const double const double double * d
virtual std::ostream * output_stream(void)
int printf(const std::string &fmt, const octave_value_list &args, const std::string &who)
F77_RET_T const double const double * f
bool write_bytes(const void *data, size_t n_elts)
std::complex< double > w(std::complex< double > z, double relerr=0)
int puts(const std::string &s, const std::string &who)
std::ostream * output_stream(void)
virtual int file_number(void) const
static void cleanup_instance(void)
octave_value_list oscanf(const std::string &fmt, const std::string &who)
size_t size(T const (&)[z])
octave_value scanf(const std::string &fmt, const Array< double > &size, octave_idx_type &count, const std::string &who)
oct_mach_info::float_format float_format(void) const
std::string error(bool clear, int &err_num)
std::string error(bool clear=false)
bool stream_ok(bool clear=true) const
octave_stream(octave_base_stream *bs=0)
octave_idx_type length(void) const
Number of elements in the array.
bool is_valid(void) const
static float_format native_float_format(void)
octave_stream & operator=(const octave_stream &)
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, oct_mach_info::float_format flt_fmt)
octave_refcount< octave_idx_type > count
octave_value finalize_read(std::list< void * > &input_buf_list, octave_idx_type input_buf_elts, octave_idx_type elts_read, octave_idx_type nr, octave_idx_type nc, oct_data_conv::data_type input_type, oct_data_conv::data_type output_type, oct_mach_info::float_format ffmt)
oct_mach_info::float_format float_format(void) const
ostrl_map::const_iterator lookup_cache
~octave_stream_list(void)
void error(const std::string &msg)
std::string name(void) const
void invalid_operation(const std::string &who, const char *rw)
std::string getl(octave_idx_type max_len, bool &err, const std::string &who)
static std::string mode_as_string(int mode)
std::map< int, octave_stream > ostrl_map
octave_value_list & operator=(const octave_value_list &obj)