#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"
Go to the source code of this file.
Classes | |
class | printf_value_cache |
Defines | |
#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_READ_VAL_TEMPLATE(RET_T, READ_T) |
#define | DO_WHITESPACE_CONVERSION() |
#define | FILL_TABLE_ROW(R, VAL_T) |
#define | FINISH_CHARACTER_CONVERSION() |
#define | INSTANTIATE_DO_READ(VAL_T) |
#define | OCTAVE_SCAN(is, fmt, arg) octave_scan (is, fmt, arg) |
Typedefs | |
typedef octave_value(* | read_fptr )(octave_stream &, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, bool, oct_mach_info::float_format ffmt, octave_idx_type &) |
Functions | |
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 int | do_printf_conv (std::ostream &, const char *, int, int, int, int, const std::string &) |
template int | do_printf_conv (std::ostream &, const char *, int, int, int, long, const std::string &) |
template int | do_printf_conv (std::ostream &, const char *, int, int, int, unsigned int, const std::string &) |
template int | do_printf_conv (std::ostream &, const char *, int, int, int, double, const std::string &) |
template int | do_printf_conv (std::ostream &, const char *, int, int, int, const char *, const std::string &) |
template<class RET_T , class READ_T > | |
octave_value | do_read (octave_stream &strm, octave_idx_type nr, octave_idx_type nc, octave_idx_type block_size, octave_idx_type skip, bool do_float_fmt_conv, bool do_NA_conv, oct_mach_info::float_format from_flt_fmt, octave_idx_type &count) |
template void | do_scanf_conv (std::istream &, const scanf_format_elt &, long int *, Matrix &, double *, octave_idx_type &, octave_idx_type &, octave_idx_type, octave_idx_type, bool) |
template void | do_scanf_conv (std::istream &, const scanf_format_elt &, short int *, Matrix &, double *, octave_idx_type &, octave_idx_type &, octave_idx_type, octave_idx_type, bool) |
template void | do_scanf_conv (std::istream &, const scanf_format_elt &, unsigned int *, Matrix &, double *, octave_idx_type &, octave_idx_type &, octave_idx_type, octave_idx_type, bool) |
template void | do_scanf_conv (std::istream &, const scanf_format_elt &, int *, Matrix &, double *, octave_idx_type &, octave_idx_type &, octave_idx_type, octave_idx_type, bool) |
template void | do_scanf_conv (std::istream &, const scanf_format_elt &, unsigned short int *, Matrix &, double *, octave_idx_type &, octave_idx_type &, octave_idx_type, octave_idx_type, bool) |
template void | do_scanf_conv (std::istream &, const scanf_format_elt &, unsigned long int *, Matrix &, double *, octave_idx_type &, octave_idx_type &, octave_idx_type, octave_idx_type, bool) |
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) |
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<class T > | |
static bool | do_write (std::ostream &os, const T &val, oct_data_conv::data_type output_type, oct_mach_info::float_format flt_fmt, bool swap, bool do_float_conversion) |
template bool | do_write (std::ostream &, const octave_int8 &, oct_data_conv::data_type, oct_mach_info::float_format, bool, 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) |
INSTANTIATE_DO_READ (NDArray) | |
INSTANTIATE_DO_READ (FloatNDArray) | |
INSTANTIATE_DO_READ (charNDArray) | |
INSTANTIATE_DO_READ (boolNDArray) | |
INSTANTIATE_DO_READ (int8NDArray) | |
template std::istream & | octave_scan (std::istream &, const scanf_format_elt &, int *) |
template std::istream & | octave_scan (std::istream &, const scanf_format_elt &, unsigned int *) |
template<> | |
std::istream & | octave_scan (std::istream &is, const scanf_format_elt &fmt, double *valptr) |
template<> | |
std::istream & | octave_scan (std::istream &is, const scanf_format_elt &, char *valptr) |
template std::istream & | octave_scan (std::istream &, const scanf_format_elt &, short int *) |
template std::istream & | octave_scan (std::istream &, const scanf_format_elt &, long int *) |
template<class T > | |
std::istream & | octave_scan (std::istream &is, const scanf_format_elt &fmt, T *valptr) |
template std::istream & | octave_scan (std::istream &, const scanf_format_elt &, unsigned long int *) |
template std::istream & | octave_scan (std::istream &, const scanf_format_elt &, unsigned short int *) |
template<class T > | |
std::istream & | octave_scan_1 (std::istream &is, const scanf_format_elt &fmt, T *valptr) |
template<class T > | |
void | write_int (std::ostream &os, bool swap, const T &val) |
template void | write_int (std::ostream &, bool, const octave_int8 &) |
#define BEGIN_C_CONVERSION | ( | ) |
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 1369 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 1437 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 1389 of file oct-stream.cc.
Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().
#define DO_DOUBLE_CONV | ( | TQUAL | ) |
do \ { \ if (val > std::numeric_limits<TQUAL long>::max () \ || val < std::numeric_limits<TQUAL long>::min ()) \ { \ 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 2426 of file oct-stream.cc.
Referenced by octave_base_stream::do_printf().
#define DO_LITERAL_CONVERSION | ( | ) |
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 1324 of file oct-stream.cc.
Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().
#define DO_PCT_CONVERSION | ( | ) |
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 1351 of file oct-stream.cc.
Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().
#define DO_READ_VAL_TEMPLATE | ( | RET_T, | ||
READ_T | ||||
) |
template octave_value \ do_read<RET_T, READ_T> (octave_stream&, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, bool, \ oct_mach_info::float_format, octave_idx_type&)
Definition at line 3192 of file oct-stream.cc.
#define DO_WHITESPACE_CONVERSION | ( | ) |
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 1311 of file oct-stream.cc.
Referenced by octave_base_stream::do_oscanf(), and octave_base_stream::do_scanf().
#define FILL_TABLE_ROW | ( | R, | ||
VAL_T | ||||
) |
read_fptr_table[R][oct_data_conv::dt_int8] = do_read<VAL_T, octave_int8>; \ read_fptr_table[R][oct_data_conv::dt_uint8] = do_read<VAL_T, octave_uint8>; \ read_fptr_table[R][oct_data_conv::dt_int16] = do_read<VAL_T, octave_int16>; \ read_fptr_table[R][oct_data_conv::dt_uint16] = do_read<VAL_T, octave_uint16>; \ read_fptr_table[R][oct_data_conv::dt_int32] = do_read<VAL_T, octave_int32>; \ read_fptr_table[R][oct_data_conv::dt_uint32] = do_read<VAL_T, octave_uint32>; \ read_fptr_table[R][oct_data_conv::dt_int64] = do_read<VAL_T, octave_int64>; \ read_fptr_table[R][oct_data_conv::dt_uint64] = do_read<VAL_T, octave_uint64>; \ read_fptr_table[R][oct_data_conv::dt_single] = do_read<VAL_T, float>; \ read_fptr_table[R][oct_data_conv::dt_double] = do_read<VAL_T, double>; \ read_fptr_table[R][oct_data_conv::dt_char] = do_read<VAL_T, char>; \ read_fptr_table[R][oct_data_conv::dt_schar] = do_read<VAL_T, signed char>; \ read_fptr_table[R][oct_data_conv::dt_uchar] = do_read<VAL_T, unsigned char>; \ read_fptr_table[R][oct_data_conv::dt_logical] = do_read<VAL_T, unsigned char>
Definition at line 3231 of file oct-stream.cc.
Referenced by octave_stream::read().
#define FINISH_CHARACTER_CONVERSION | ( | ) |
Definition at line 1481 of file oct-stream.cc.
Referenced by octave_base_stream::do_scanf().
#define INSTANTIATE_DO_READ | ( | VAL_T | ) |
DO_READ_VAL_TEMPLATE (VAL_T, octave_int8); \ DO_READ_VAL_TEMPLATE (VAL_T, octave_uint8); \ DO_READ_VAL_TEMPLATE (VAL_T, octave_int16); \ DO_READ_VAL_TEMPLATE (VAL_T, octave_uint16); \ DO_READ_VAL_TEMPLATE (VAL_T, octave_int32); \ DO_READ_VAL_TEMPLATE (VAL_T, octave_uint32); \ DO_READ_VAL_TEMPLATE (VAL_T, octave_int64); \ DO_READ_VAL_TEMPLATE (VAL_T, octave_uint64); \ DO_READ_VAL_TEMPLATE (VAL_T, float); \ DO_READ_VAL_TEMPLATE (VAL_T, double); \ DO_READ_VAL_TEMPLATE (VAL_T, char); \ DO_READ_VAL_TEMPLATE (VAL_T, signed char); \ DO_READ_VAL_TEMPLATE (VAL_T, unsigned char)
Definition at line 3200 of file oct-stream.cc.
#define OCTAVE_SCAN | ( | is, | ||
fmt, | ||||
arg | ||||
) | octave_scan (is, fmt, arg) |
Definition at line 1090 of file oct-stream.cc.
Referenced by octave_base_stream::do_oscanf(), and do_scanf_conv().
typedef octave_value(* read_fptr)(octave_stream &, octave_idx_type, octave_idx_type, octave_idx_type, octave_idx_type, bool, bool, oct_mach_info::float_format ffmt, octave_idx_type &) |
Definition at line 3228 of file oct-stream.cc.
static int convert_to_valid_int | ( | const octave_value & | tc, | |
int & | conv_err | |||
) | [static] |
Definition at line 62 of file oct-stream.cc.
References octave_value::double_value(), error_state, lo_ieee_isnan, and NINT().
Referenced by octave_stream_list::do_get_file_number(), octave_stream_list::do_get_info(), octave_stream::getl(), octave_stream::gets(), octave_stream::seek(), and octave_stream::skipl().
int do_printf_conv | ( | std::ostream & | os, | |
const char * | fmt, | |||
int | nsa, | |||
int | sa_1, | |||
int | sa_2, | |||
T | arg, | |||
const std::string & | who | |||
) |
Definition at line 2375 of file oct-stream.cc.
References error(), and octave_format().
Referenced by octave_base_stream::do_printf().
template int do_printf_conv | ( | std::ostream & | , | |
const char * | , | |||
int | , | |||
int | , | |||
int | , | |||
int | , | |||
const std::string & | ||||
) |
template int do_printf_conv | ( | std::ostream & | , | |
const char * | , | |||
int | , | |||
int | , | |||
int | , | |||
long | , | |||
const std::string & | ||||
) |
template int do_printf_conv | ( | std::ostream & | , | |
const char * | , | |||
int | , | |||
int | , | |||
int | , | |||
unsigned | int, | |||
const std::string & | ||||
) |
template int do_printf_conv | ( | std::ostream & | , | |
const char * | , | |||
int | , | |||
int | , | |||
int | , | |||
double | , | |||
const std::string & | ||||
) |
template int do_printf_conv | ( | std::ostream & | , | |
const char * | , | |||
int | , | |||
int | , | |||
int | , | |||
const char * | , | |||
const std::string & | ||||
) |
octave_value do_read | ( | octave_stream & | strm, | |
octave_idx_type | nr, | |||
octave_idx_type | nc, | |||
octave_idx_type | block_size, | |||
octave_idx_type | skip, | |||
bool | do_float_fmt_conv, | |||
bool | do_NA_conv, | |||
oct_mach_info::float_format | from_flt_fmt, | |||
octave_idx_type & | count | |||
) |
Definition at line 3026 of file oct-stream.cc.
References __lo_ieee_is_old_NA(), __lo_ieee_replace_old_NA(), do_float_format_conversion(), oct_mach_info::flt_fmt_ieee_little_endian, oct_mach_info::flt_fmt_vax_g, octave_stream::input_stream(), octave_stream::seek(), SEEK_CUR, and oct_mach_info::words_big_endian().
template void do_scanf_conv | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
long int * | , | |||
Matrix & | , | |||
double * | , | |||
octave_idx_type & | , | |||
octave_idx_type & | , | |||
octave_idx_type | , | |||
octave_idx_type | , | |||
bool | ||||
) |
template void do_scanf_conv | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
short int * | , | |||
Matrix & | , | |||
double * | , | |||
octave_idx_type & | , | |||
octave_idx_type & | , | |||
octave_idx_type | , | |||
octave_idx_type | , | |||
bool | ||||
) |
template void do_scanf_conv | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
unsigned int * | , | |||
Matrix & | , | |||
double * | , | |||
octave_idx_type & | , | |||
octave_idx_type & | , | |||
octave_idx_type | , | |||
octave_idx_type | , | |||
bool | ||||
) |
template void do_scanf_conv | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
int * | , | |||
Matrix & | , | |||
double * | , | |||
octave_idx_type & | , | |||
octave_idx_type & | , | |||
octave_idx_type | , | |||
octave_idx_type | , | |||
bool | ||||
) |
template void do_scanf_conv | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
unsigned short int * | , | |||
Matrix & | , | |||
double * | , | |||
octave_idx_type & | , | |||
octave_idx_type & | , | |||
octave_idx_type | , | |||
octave_idx_type | , | |||
bool | ||||
) |
template void do_scanf_conv | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
unsigned long int * | , | |||
Matrix & | , | |||
double * | , | |||
octave_idx_type & | , | |||
octave_idx_type & | , | |||
octave_idx_type | , | |||
octave_idx_type | , | |||
bool | ||||
) |
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 | ||||
) |
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 | |||
) |
Definition at line 1248 of file oct-stream.cc.
References Array< T >::fortran_vec(), OCTAVE_SCAN, and Matrix::resize().
Referenced by octave_base_stream::do_scanf().
static bool do_write | ( | std::ostream & | os, | |
const T & | val, | |||
oct_data_conv::data_type | output_type, | |||
oct_mach_info::float_format | flt_fmt, | |||
bool | swap, | |||
bool | do_float_conversion | |||
) | [inline, static] |
Definition at line 3398 of file oct-stream.cc.
References d, do_double_format_conversion(), do_float_format_conversion(), oct_data_conv::dt_char, oct_data_conv::dt_double, oct_data_conv::dt_int16, oct_data_conv::dt_int32, oct_data_conv::dt_int64, oct_data_conv::dt_int8, oct_data_conv::dt_schar, oct_data_conv::dt_single, oct_data_conv::dt_uchar, oct_data_conv::dt_uint16, oct_data_conv::dt_uint32, oct_data_conv::dt_uint64, oct_data_conv::dt_uint8, f, and write_int().
Referenced by octave_stream::write().
template bool do_write | ( | std::ostream & | , | |
const octave_int8 & | , | |||
oct_data_conv::data_type | , | |||
oct_mach_info::float_format | , | |||
bool | , | |||
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().
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 4038 of file oct-stream.cc.
References error().
Referenced by octave_stream_list::do_lookup(), and octave_stream_list::do_remove().
INSTANTIATE_DO_READ | ( | NDArray | ) |
INSTANTIATE_DO_READ | ( | FloatNDArray | ) |
INSTANTIATE_DO_READ | ( | charNDArray | ) |
INSTANTIATE_DO_READ | ( | boolNDArray | ) |
INSTANTIATE_DO_READ | ( | int8NDArray | ) |
template std::istream& octave_scan | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
int * | ||||
) |
template std::istream& octave_scan | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
unsigned int * | ||||
) |
std::istream& octave_scan | ( | std::istream & | is, | |
const scanf_format_elt & | fmt, | |||
double * | valptr | |||
) |
Definition at line 1214 of file oct-stream.cc.
References c1, and panic_impossible.
std::istream& octave_scan | ( | std::istream & | is, | |
const scanf_format_elt & | , | |||
char * | valptr | |||
) |
Definition at line 1183 of file oct-stream.cc.
template std::istream& octave_scan | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
short int * | ||||
) |
template std::istream& octave_scan | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
long int * | ||||
) |
std::istream& octave_scan | ( | std::istream & | is, | |
const scanf_format_elt & | fmt, | |||
T * | valptr | |||
) |
Definition at line 1156 of file oct-stream.cc.
References octave_scan_1(), and scanf_format_elt::width.
template std::istream& octave_scan | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
unsigned long int * | ||||
) |
template std::istream& octave_scan | ( | std::istream & | , | |
const scanf_format_elt & | , | |||
unsigned short int * | ||||
) |
std::istream& octave_scan_1 | ( | std::istream & | is, | |
const scanf_format_elt & | fmt, | |||
T * | valptr | |||
) |
Definition at line 1094 of file oct-stream.cc.
References c1, and scanf_format_elt::type.
Referenced by octave_scan().
void write_int | ( | std::ostream & | os, | |
bool | swap, | |||
const T & | val | |||
) |
Definition at line 3376 of file oct-stream.cc.
Referenced by do_write().
template void write_int | ( | std::ostream & | , | |
bool | , | |||
const octave_int8 & | ||||
) |