#include <cctype>
#include <cstdlib>
#include <iostream>
#include <vector>
#include "byte-swap.h"
#include "data-conv.h"
#include "lo-error.h"
#include "lo-ieee.h"
#include "oct-locbuf.h"
Go to the source code of this file.
#define FIND_SIZED_FLOAT_TYPE | ( | VAL, | ||
BITS | ||||
) |
do \ { \ int sz = BITS / CHAR_BIT; \ if (sizeof (float) == sz) \ VAL = oct_data_conv::dt_float; \ else if (sizeof (double) == sz) \ VAL = oct_data_conv::dt_double; \ else \ VAL = oct_data_conv::dt_unknown; \ } \ while (0)
Definition at line 81 of file data-conv.cc.
Referenced by init_sized_type_lookup_table().
#define FIND_SIZED_INT_TYPE | ( | VAL, | ||
BITS, | ||||
TQ, | ||||
Q | ||||
) |
do \ { \ int sz = BITS / CHAR_BIT; \ if (sizeof (TQ char) == sz) \ VAL = oct_data_conv::dt_ ## Q ## char; \ else if (sizeof (TQ short) == sz) \ VAL = oct_data_conv::dt_ ## Q ## short; \ else if (sizeof (TQ int) == sz) \ VAL = oct_data_conv::dt_ ## Q ## int; \ else if (sizeof (TQ long) == sz) \ VAL = oct_data_conv::dt_ ## Q ## long; \ else \ VAL = oct_data_conv::dt_unknown; \ } \ while (0)
Definition at line 63 of file data-conv.cc.
Referenced by init_sized_type_lookup_table().
#define GET_SIZED_INT_TYPE | ( | T, | ||
U | ||||
) |
do \ { \ switch (sizeof (T)) \ { \ case 1: \ retval = dt_ ## U ## int8; \ break; \ \ case 2: \ retval = dt_ ## U ## int16; \ break; \ \ case 4: \ retval = dt_ ## U ## int32; \ break; \ \ case 8: \ retval = dt_ ## U ## int64; \ break; \ \ default: \ retval = dt_unknown; \ break; \ } \ } \ while (0)
Definition at line 151 of file data-conv.cc.
Referenced by oct_data_conv::string_to_data_type().
#define LS_DO_READ | ( | TYPE, | ||
swap, | ||||
data, | ||||
size, | ||||
len, | ||||
stream | ||||
) |
do \ { \ if (len > 0) \ { \ OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \ stream.read (reinterpret_cast<char *> (ptr), size * len); \ if (swap) \ swap_bytes< size > (ptr, len); \ for (octave_idx_type i = 0; i < len; i++) \ data[i] = ptr[i]; \ } \ } \ while (0)
Definition at line 483 of file data-conv.cc.
Referenced by read_doubles(), and read_floats().
#define LS_DO_WRITE | ( | TYPE, | ||
data, | ||||
size, | ||||
len, | ||||
stream | ||||
) |
do \ { \ if (len > 0) \ { \ char tmp_type = type; \ stream.write (&tmp_type, 1); \ OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \ for (octave_idx_type i = 0; i < len; i++) \ ptr[i] = static_cast <TYPE> (data[i]); \ stream.write (reinterpret_cast<char *> (ptr), size * len); \ } \ } \ while (0)
Definition at line 501 of file data-conv.cc.
Referenced by write_doubles(), and write_floats().
static void Cray_to_IEEE_big_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 608 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void Cray_to_IEEE_big_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 632 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void Cray_to_IEEE_little_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 560 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void Cray_to_IEEE_little_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 584 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void Cray_to_VAX_D_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 656 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void Cray_to_VAX_D_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 680 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void Cray_to_VAX_G_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 704 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void Cray_to_VAX_G_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 728 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
void do_double_format_conversion | ( | void * | data, | |
octave_idx_type | len, | |||
oct_mach_info::float_format | from_fmt, | |||
oct_mach_info::float_format | to_fmt | |||
) |
Definition at line 734 of file data-conv.cc.
References Cray_to_IEEE_big_double(), Cray_to_IEEE_little_double(), Cray_to_VAX_D_double(), Cray_to_VAX_G_double(), oct_mach_info::flt_fmt_cray, oct_mach_info::flt_fmt_ieee_big_endian, oct_mach_info::flt_fmt_ieee_little_endian, oct_mach_info::flt_fmt_vax_d, oct_mach_info::flt_fmt_vax_g, gripe_unrecognized_float_fmt(), IEEE_big_double_to_IEEE_little_double(), IEEE_big_double_to_VAX_D_double(), IEEE_big_double_to_VAX_G_double(), IEEE_little_double_to_IEEE_big_double(), IEEE_little_double_to_VAX_D_double(), IEEE_little_double_to_VAX_G_double(), VAX_D_double_to_IEEE_big_double(), VAX_D_double_to_IEEE_little_double(), VAX_D_double_to_VAX_G_double(), VAX_G_double_to_IEEE_big_double(), VAX_G_double_to_IEEE_little_double(), and VAX_G_double_to_VAX_D_double().
Referenced by do_float_format_conversion(), do_write(), read_doubles(), and read_floats().
void do_float_format_conversion | ( | void * | data, | |
octave_idx_type | len, | |||
oct_mach_info::float_format | from_fmt, | |||
oct_mach_info::float_format | to_fmt | |||
) |
Definition at line 861 of file data-conv.cc.
References Cray_to_IEEE_big_float(), Cray_to_IEEE_little_float(), Cray_to_VAX_D_float(), Cray_to_VAX_G_float(), oct_mach_info::flt_fmt_cray, oct_mach_info::flt_fmt_ieee_big_endian, oct_mach_info::flt_fmt_ieee_little_endian, oct_mach_info::flt_fmt_vax_d, oct_mach_info::flt_fmt_vax_g, gripe_unrecognized_float_fmt(), IEEE_big_float_to_IEEE_little_float(), IEEE_big_float_to_VAX_D_float(), IEEE_big_float_to_VAX_G_float(), IEEE_little_float_to_IEEE_big_float(), IEEE_little_float_to_VAX_D_float(), IEEE_little_float_to_VAX_G_float(), VAX_D_float_to_IEEE_big_float(), VAX_D_float_to_IEEE_little_float(), VAX_D_float_to_VAX_G_float(), VAX_G_float_to_IEEE_big_float(), VAX_G_float_to_IEEE_little_float(), and VAX_G_float_to_VAX_D_float().
Referenced by do_float_format_conversion(), do_read(), do_write(), read_doubles(), and read_floats().
void do_float_format_conversion | ( | void * | data, | |
size_t | sz, | |||
octave_idx_type | len, | |||
oct_mach_info::float_format | from_fmt, | |||
oct_mach_info::float_format | to_fmt | |||
) |
Definition at line 988 of file data-conv.cc.
References do_double_format_conversion(), and do_float_format_conversion().
Definition at line 526 of file data-conv.cc.
static void gripe_unrecognized_float_fmt | ( | void | ) | [static] |
Definition at line 519 of file data-conv.cc.
static void IEEE_big_double_to_IEEE_little_double | ( | void * | d, | |
octave_idx_type | len | |||
) | [static] |
Definition at line 542 of file data-conv.cc.
References swap_bytes< 8 >().
Referenced by do_double_format_conversion().
static void IEEE_big_double_to_VAX_D_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 644 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void IEEE_big_double_to_VAX_G_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 692 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void IEEE_big_float_to_IEEE_little_float | ( | void * | d, | |
octave_idx_type | len | |||
) | [static] |
Definition at line 566 of file data-conv.cc.
References swap_bytes< 4 >().
Referenced by do_float_format_conversion().
static void IEEE_big_float_to_VAX_D_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 668 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void IEEE_big_float_to_VAX_G_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 716 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void IEEE_little_double_to_IEEE_big_double | ( | void * | d, | |
octave_idx_type | len | |||
) | [static] |
Definition at line 590 of file data-conv.cc.
References swap_bytes< 8 >().
Referenced by do_double_format_conversion().
static void IEEE_little_double_to_VAX_D_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 638 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void IEEE_little_double_to_VAX_G_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 686 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void IEEE_little_float_to_IEEE_big_float | ( | void * | d, | |
octave_idx_type | len | |||
) | [static] |
Definition at line 614 of file data-conv.cc.
References swap_bytes< 4 >().
Referenced by do_float_format_conversion().
static void IEEE_little_float_to_VAX_D_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 662 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void IEEE_little_float_to_VAX_G_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 710 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void init_sized_type_lookup_table | ( | oct_data_conv::data_type | table[3][4] | ) | [static] |
Definition at line 117 of file data-conv.cc.
References FIND_SIZED_FLOAT_TYPE, and FIND_SIZED_INT_TYPE.
Referenced by oct_data_conv::string_to_data_type().
void read_doubles | ( | std::istream & | is, | |
double * | data, | |||
save_type | type, | |||
octave_idx_type | len, | |||
bool | swap, | |||
oct_mach_info::float_format | fmt | |||
) |
Definition at line 1012 of file data-conv.cc.
References __lo_ieee_replace_old_NA(), do_double_format_conversion(), do_float_format_conversion(), LS_CHAR, LS_DO_READ, LS_DOUBLE, LS_FLOAT, LS_INT, LS_SHORT, LS_U_CHAR, LS_U_INT, LS_U_SHORT, and OCTAVE_LOCAL_BUFFER.
Referenced by octave_scalar::load_binary(), octave_sparse_matrix::load_binary(), octave_matrix::load_binary(), octave_diag_matrix::load_binary(), octave_sparse_complex_matrix::load_binary(), octave_complex_matrix::load_binary(), octave_complex_diag_matrix::load_binary(), octave_complex::load_binary(), read_mat5_binary_data(), and read_mat_binary_data().
void read_floats | ( | std::istream & | is, | |
float * | data, | |||
save_type | type, | |||
octave_idx_type | len, | |||
bool | swap, | |||
oct_mach_info::float_format | fmt | |||
) |
Definition at line 1069 of file data-conv.cc.
References do_double_format_conversion(), do_float_format_conversion(), LS_CHAR, LS_DO_READ, LS_DOUBLE, LS_FLOAT, LS_INT, LS_SHORT, LS_U_CHAR, LS_U_INT, LS_U_SHORT, and OCTAVE_LOCAL_BUFFER.
Referenced by octave_float_matrix::load_binary(), octave_float_diag_matrix::load_binary(), octave_float_complex_matrix::load_binary(), octave_float_complex_diag_matrix::load_binary(), octave_float_complex::load_binary(), octave_float_scalar::load_binary(), and read_mat5_binary_data().
static std::string strip_spaces | ( | const std::string & | str | ) | [static] |
Definition at line 134 of file data-conv.cc.
Referenced by oct_data_conv::string_to_data_type().
template void swap_bytes< 2 > | ( | volatile void * | , | |
int | ||||
) |
template void swap_bytes< 4 > | ( | volatile void * | , | |
int | ||||
) |
template void swap_bytes< 8 > | ( | volatile void * | , | |
int | ||||
) |
static void VAX_D_double_to_IEEE_big_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 596 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void VAX_D_double_to_IEEE_little_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 548 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void VAX_D_double_to_VAX_G_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 698 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void VAX_D_float_to_IEEE_big_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 620 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void VAX_D_float_to_IEEE_little_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 572 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void VAX_D_float_to_VAX_G_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 722 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void VAX_G_double_to_IEEE_big_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 602 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void VAX_G_double_to_IEEE_little_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 554 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void VAX_G_double_to_VAX_D_double | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 650 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_double_format_conversion().
static void VAX_G_float_to_IEEE_big_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 626 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void VAX_G_float_to_IEEE_little_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 578 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
static void VAX_G_float_to_VAX_D_float | ( | void * | , | |
octave_idx_type | ||||
) | [static] |
Definition at line 674 of file data-conv.cc.
References gripe_data_conversion().
Referenced by do_float_format_conversion().
void write_doubles | ( | std::ostream & | os, | |
const double * | data, | |||
save_type | type, | |||
octave_idx_type | len | |||
) |
Definition at line 1121 of file data-conv.cc.
References LS_CHAR, LS_DO_WRITE, LS_DOUBLE, LS_FLOAT, LS_INT, LS_SHORT, LS_U_CHAR, LS_U_INT, and LS_U_SHORT.
Referenced by octave_sparse_matrix::save_binary(), octave_matrix::save_binary(), octave_diag_matrix::save_binary(), octave_sparse_complex_matrix::save_binary(), octave_complex_matrix::save_binary(), and octave_complex_diag_matrix::save_binary().
void write_floats | ( | std::ostream & | os, | |
const float * | data, | |||
save_type | type, | |||
octave_idx_type | len | |||
) |
Definition at line 1170 of file data-conv.cc.
References LS_CHAR, LS_DO_WRITE, LS_DOUBLE, LS_FLOAT, LS_INT, LS_SHORT, LS_U_CHAR, LS_U_INT, and LS_U_SHORT.
Referenced by octave_float_matrix::save_binary(), octave_float_diag_matrix::save_binary(), octave_float_complex_matrix::save_binary(), and octave_float_complex_diag_matrix::save_binary().