GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Macros | Typedefs | Functions
oct-stream.cc File Reference
#include <cassert>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <Array.h>
#include "byte-swap.h"
#include "lo-ieee.h"
#include "lo-mappers.h"
#include "lo-utils.h"
#include "quit.h"
#include "singleton-cleanup.h"
#include "str-vec.h"
#include "error.h"
#include "gripes.h"
#include "input.h"
#include "oct-stdstrm.h"
#include "oct-stream.h"
#include "oct-obj.h"
#include "utils.h"
Include dependency graph for oct-stream.cc:

Go to the source code of this file.

Classes

class  printf_value_cache

Macros

#define BEGIN_C_CONVERSION()
#define BEGIN_CHAR_CLASS_CONVERSION()
#define BEGIN_S_CONVERSION()
#define DO_DOUBLE_CONV(TQUAL)
#define DO_LITERAL_CONVERSION()
#define DO_PCT_CONVERSION()
#define DO_WHITESPACE_CONVERSION()
#define FILL_TABLE_ROW(T, V)
#define FINISH_CHARACTER_CONVERSION()
#define INSTANTIATE_WRITE(T)
#define OCTAVE_SCAN(is, fmt, arg)   octave_scan (is, fmt, arg)
#define TABLE_ELT(T, U, V, W)   conv_fptr_table[oct_data_conv::T][oct_data_conv::U] = convert_and_copy<V, W>

Typedefs

typedef octave_value(* conv_fptr )(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, bool swap, bool do_float_fmt_conv, bool do_NA_conv, oct_mach_info::float_format from_flt_fmt)

Functions

template<class SRC_T , class DST_T >
static octave_value convert_and_copy (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, bool swap, bool do_float_fmt_conv, bool do_NA_conv, oct_mach_info::float_format from_flt_fmt)
template<class T >
static bool convert_data (const T *data, void *conv_data, octave_idx_type n_elts, oct_data_conv::data_type output_type, oct_mach_info::float_format flt_fmt)
template<class T , class V >
static void convert_ints (const T *data, void *conv_data, octave_idx_type n_elts, bool swap)
static int convert_to_valid_int (const octave_value &tc, int &conv_err)
template<class T >
int do_printf_conv (std::ostream &os, const char *fmt, int nsa, int sa_1, int sa_2, T arg, const std::string &who)
template<class T >
void do_scanf_conv (std::istream &is, const scanf_format_elt &fmt, T valptr, Matrix &mval, double *data, octave_idx_type &idx, octave_idx_type &conversion_count, octave_idx_type nr, octave_idx_type max_size, bool discard)
template void do_scanf_conv (std::istream &, const scanf_format_elt &, double *, Matrix &, double *, octave_idx_type &, octave_idx_type &, octave_idx_type, octave_idx_type, bool)
static std::string expand_char_class (const std::string &s)
static int get_size (double d, const std::string &who)
static void get_size (const Array< double > &size, octave_idx_type &nr, octave_idx_type &nc, bool &one_elt_size_spec, const std::string &who)
static void gripe_invalid_file_id (int fid, const std::string &who)
template<class T >
std::istream & octave_scan (std::istream &is, const scanf_format_elt &fmt, T *valptr)
template<>
std::istream & octave_scan (std::istream &is, const scanf_format_elt &, char *valptr)
template<>
std::istream & octave_scan (std::istream &is, const scanf_format_elt &fmt, double *valptr)
template<class T >
std::istream & octave_scan_1 (std::istream &is, const scanf_format_elt &fmt, T *valptr)

Macro Definition Documentation

#define BEGIN_C_CONVERSION ( )
Value:
is.unsetf (std::ios::skipws); \
\
int width = elt->width ? elt->width : 1; \
\
std::string tmp (width, '\0'); \
\
int c = EOF; \
int n = 0; \
\
while (is && n < width && (c = is.get ()) != EOF) \
tmp[n++] = static_cast<char> (c); \
if (n > 0 && c == EOF) \
is.clear (); \
\
tmp.resize (n)

Definition at line 1324 of file oct-stream.cc.

Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().

#define BEGIN_CHAR_CLASS_CONVERSION ( )

Definition at line 1392 of file oct-stream.cc.

Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().

#define BEGIN_S_CONVERSION ( )

Definition at line 1344 of file oct-stream.cc.

Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().

#define DO_DOUBLE_CONV (   TQUAL)
Value:
do \
{ \
{ \
std::string tfmt = fmt; \
\
tfmt.replace (tfmt.rfind (elt->type), 1, ".f"); \
if (elt->modifier == 'l') \
tfmt.replace (tfmt.rfind (elt->modifier), 1, ""); \
\
retval += do_printf_conv (os, tfmt.c_str (), nsa, sa_1, sa_2, \
val, who); \
} \
else \
retval += do_printf_conv (os, fmt, nsa, sa_1, sa_2, \
static_cast<TQUAL long> (val), who); \
} \
while (0)

Definition at line 2360 of file oct-stream.cc.

Referenced by octave_base_stream::do_printf().

#define DO_LITERAL_CONVERSION ( )
Value:
do \
{ \
int c = EOF; \
\
int n = strlen (fmt); \
int i = 0; \
\
while (i < n && is && (c = is.get ()) != EOF) \
{ \
if (c == static_cast<unsigned char> (fmt[i])) \
{ \
i++; \
continue; \
} \
else \
{ \
is.putback (c); \
break; \
} \
} \
if (i != n) \
is.setstate (std::ios::failbit); \
} \
while (0)

Definition at line 1279 of file oct-stream.cc.

Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().

#define DO_PCT_CONVERSION ( )
Value:
do \
{ \
int c = is.get (); \
if (c != EOF) \
{ \
if (c != '%') \
{ \
is.putback (c); \
is.setstate (std::ios::failbit); \
} \
} \
else \
is.setstate (std::ios::failbit); \
} \
while (0)

Definition at line 1306 of file oct-stream.cc.

Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().

#define DO_WHITESPACE_CONVERSION ( )
Value:
do \
{ \
int c = EOF; \
\
while (is && (c = is.get ()) != EOF && isspace (c)) \
/* skip whitespace */; \
if (c != EOF) \
is.putback (c); \
} \
while (0)

Definition at line 1266 of file oct-stream.cc.

Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().

#define FILL_TABLE_ROW (   T,
  V 
)
Value:
TABLE_ELT (T, dt_int8, V, int8NDArray); \
TABLE_ELT (T, dt_uint8, V, uint8NDArray); \
TABLE_ELT (T, dt_int16, V, int16NDArray); \
TABLE_ELT (T, dt_uint16, V, uint16NDArray); \
TABLE_ELT (T, dt_int32, V, int32NDArray); \
TABLE_ELT (T, dt_uint32, V, uint32NDArray); \
TABLE_ELT (T, dt_int64, V, int64NDArray); \
TABLE_ELT (T, dt_uint64, V, uint64NDArray); \
TABLE_ELT (T, dt_single, V, FloatNDArray); \
TABLE_ELT (T, dt_double, V, NDArray); \
TABLE_ELT (T, dt_char, V, charNDArray); \
TABLE_ELT (T, dt_schar, V, charNDArray); \
TABLE_ELT (T, dt_uchar, V, charNDArray); \
TABLE_ELT (T, dt_logical, V, boolNDArray);

Definition at line 3054 of file oct-stream.cc.

Referenced by octave_stream::finalize_read().

#define FINISH_CHARACTER_CONVERSION ( )

Definition at line 1436 of file oct-stream.cc.

Referenced by octave_base_stream::do_scanf().

#define INSTANTIATE_WRITE (   T)
Value:
template \
octave_idx_type \
octave_stream::write (const Array<T>& data, octave_idx_type block_size, \
oct_data_conv::data_type output_type, \

Definition at line 3584 of file oct-stream.cc.

#define OCTAVE_SCAN (   is,
  fmt,
  arg 
)    octave_scan (is, fmt, arg)

Definition at line 1094 of file oct-stream.cc.

Referenced by octave_base_stream::do_oscanf(), and do_scanf_conv().

#define TABLE_ELT (   T,
  U,
  V,
 
)    conv_fptr_table[oct_data_conv::T][oct_data_conv::U] = convert_and_copy<V, W>

Definition at line 3051 of file oct-stream.cc.

Typedef Documentation

typedef octave_value(* conv_fptr)(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, bool swap, bool do_float_fmt_conv, bool do_NA_conv, oct_mach_info::float_format from_flt_fmt)

Definition at line 3046 of file oct-stream.cc.

Function Documentation

template<class SRC_T , class DST_T >
static octave_value convert_and_copy ( 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,
bool  swap,
bool  do_float_fmt_conv,
bool  do_NA_conv,
oct_mach_info::float_format  from_flt_fmt 
)
static
template<class T >
static bool convert_data ( const T *  data,
void conv_data,
octave_idx_type  n_elts,
oct_data_conv::data_type  output_type,
oct_mach_info::float_format  flt_fmt 
)
static
template<class T , class V >
static void convert_ints ( const T *  data,
void conv_data,
octave_idx_type  n_elts,
bool  swap 
)
static

Definition at line 3335 of file oct-stream.cc.

References V.

static int convert_to_valid_int ( const octave_value tc,
int conv_err 
)
static
template<class T >
int do_printf_conv ( std::ostream &  os,
const char fmt,
int  nsa,
int  sa_1,
int  sa_2,
arg,
const std::string &  who 
)

Definition at line 2333 of file oct-stream.cc.

References error(), and octave_format().

Referenced by octave_base_stream::do_printf().

template<class T >
void do_scanf_conv ( std::istream &  is,
const scanf_format_elt fmt,
valptr,
Matrix mval,
double data,
octave_idx_type idx,
octave_idx_type conversion_count,
octave_idx_type  nr,
octave_idx_type  max_size,
bool  discard 
)

Definition at line 1232 of file oct-stream.cc.

References Array< T >::fortran_vec(), OCTAVE_SCAN, and Matrix::resize().

Referenced by octave_base_stream::do_scanf().

template void do_scanf_conv ( std::istream &  ,
const scanf_format_elt ,
double ,
Matrix ,
double ,
octave_idx_type ,
octave_idx_type ,
octave_idx_type  ,
octave_idx_type  ,
bool   
)
static std::string expand_char_class ( const std::string &  s)
static

Definition at line 274 of file oct-stream.cc.

Referenced by scanf_format_list::finish_conversion().

static int get_size ( double  d,
const std::string &  who 
)
static

Definition at line 91 of file oct-stream.cc.

References error(), lo_ieee_isnan, NINT(), and xisinf().

Referenced by get_size(), octave_stream::read(), and octave_base_stream::scanf().

static void get_size ( const Array< double > &  size,
octave_idx_type nr,
octave_idx_type nc,
bool one_elt_size_spec,
const std::string &  who 
)
static

Definition at line 115 of file oct-stream.cc.

References error(), error_state, get_size(), Array< T >::length(), size(), and xisinf().

static void gripe_invalid_file_id ( int  fid,
const std::string &  who 
)
static

Definition at line 3974 of file oct-stream.cc.

References error().

Referenced by octave_stream_list::do_lookup(), and octave_stream_list::do_remove().

template<class T >
std::istream& octave_scan ( std::istream &  is,
const scanf_format_elt fmt,
T *  valptr 
)

Definition at line 1163 of file oct-stream.cc.

References octave_scan_1(), and scanf_format_elt::width.

template<>
std::istream& octave_scan ( std::istream &  is,
const scanf_format_elt ,
char valptr 
)

Definition at line 1190 of file oct-stream.cc.

template<>
std::istream& octave_scan ( std::istream &  is,
const scanf_format_elt fmt,
double valptr 
)

Definition at line 1198 of file oct-stream.cc.

References c1, and panic_impossible.

template<class T >
std::istream& octave_scan_1 ( std::istream &  is,
const scanf_format_elt fmt,
T *  valptr 
)

Definition at line 1098 of file oct-stream.cc.

References c1, and scanf_format_elt::type.

Referenced by octave_scan().