00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_data_conv_h)
00024 #define octave_data_conv_h 1
00025
00026 #include <climits>
00027
00028 #include "mach-info.h"
00029
00030 class
00031 OCTAVE_API
00032 oct_data_conv
00033 {
00034 public:
00035
00036 enum data_type
00037 {
00038 dt_int8 = 0,
00039 dt_uint8 = 1,
00040 dt_int16 = 2,
00041 dt_uint16 = 3,
00042 dt_int32 = 4,
00043 dt_uint32 = 5,
00044 dt_int64 = 6,
00045 dt_uint64 = 7,
00046 dt_single = 8,
00047 dt_double = 9,
00048 dt_char = 10,
00049 dt_schar = 11,
00050 dt_uchar = 12,
00051 dt_logical = 13,
00052 dt_short = 14,
00053 dt_ushort = 15,
00054 dt_int = 16,
00055 dt_uint = 17,
00056 dt_long = 18,
00057 dt_ulong = 19,
00058 dt_longlong = 20,
00059 dt_ulonglong = 21,
00060 dt_float = 22,
00061 dt_unknown = 23
00062 };
00063
00064 static data_type string_to_data_type (const std::string& s);
00065
00066 static void string_to_data_type (const std::string& s, int& block_size,
00067 data_type& input_type,
00068 data_type& output_type);
00069
00070 static void string_to_data_type (const std::string& s, int& block_size,
00071 data_type& output_type);
00072
00073 static std::string data_type_as_string (data_type dt);
00074 };
00075
00076
00077
00078
00079
00080 enum save_type
00081 {
00082 LS_U_CHAR = 0,
00083 LS_U_SHORT = 1,
00084 LS_U_INT = 2,
00085 LS_CHAR = 3,
00086 LS_SHORT = 4,
00087 LS_INT = 5,
00088 LS_FLOAT = 6,
00089 LS_DOUBLE = 7,
00090 LS_U_LONG = 8,
00091 LS_LONG = 9
00092 };
00093
00094 extern OCTAVE_API void
00095 do_double_format_conversion (void *data, int len,
00096 oct_mach_info::float_format from_fmt,
00097 oct_mach_info::float_format to_fmt
00098 = oct_mach_info::native_float_format ());
00099
00100 extern OCTAVE_API void
00101 do_float_format_conversion (void *data, int len,
00102 oct_mach_info::float_format from_fmt,
00103 oct_mach_info::float_format to_fmt
00104 = oct_mach_info::native_float_format ());
00105
00106 extern OCTAVE_API void
00107 do_float_format_conversion (void *data, size_t sz, int len,
00108 oct_mach_info::float_format from_fmt,
00109 oct_mach_info::float_format to_fmt
00110 = oct_mach_info::native_float_format ());
00111
00112 extern OCTAVE_API void
00113 read_doubles (std::istream& is, double *data, save_type type, int len,
00114 bool swap, oct_mach_info::float_format fmt);
00115 extern OCTAVE_API void
00116 write_doubles (std::ostream& os, const double *data, save_type type, int len);
00117
00118 extern OCTAVE_API void
00119 read_floats (std::istream& is, float *data, save_type type, int len,
00120 bool swap, oct_mach_info::float_format fmt);
00121 extern OCTAVE_API void
00122 write_floats (std::ostream& os, const float *data, save_type type, int len);
00123
00124 #endif
00125
00126
00127
00128
00129
00130