1960
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1960
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
1960
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_data_conv_h) |
|
25 #define octave_data_conv_h 1 |
|
26 |
|
27 #include <climits> |
|
28 |
2317
|
29 #include "mach-info.h" |
1960
|
30 |
2317
|
31 class |
6108
|
32 OCTAVE_API |
2317
|
33 oct_data_conv |
|
34 { |
|
35 public: |
|
36 |
|
37 enum data_type |
|
38 { |
4944
|
39 dt_int8 = 0, |
|
40 dt_uint8 = 1, |
|
41 dt_int16 = 2, |
|
42 dt_uint16 = 3, |
|
43 dt_int32 = 4, |
|
44 dt_uint32 = 5, |
|
45 dt_int64 = 6, |
|
46 dt_uint64 = 7, |
|
47 dt_single = 8, |
|
48 dt_double = 9, |
|
49 dt_char = 10, |
|
50 dt_schar = 11, |
|
51 dt_uchar = 12, |
4970
|
52 dt_logical = 13, |
|
53 dt_short = 14, |
|
54 dt_ushort = 15, |
|
55 dt_int = 16, |
|
56 dt_uint = 17, |
|
57 dt_long = 18, |
|
58 dt_ulong = 19, |
|
59 dt_longlong = 20, |
|
60 dt_ulonglong = 21, |
|
61 dt_float = 22, |
|
62 dt_unknown = 23 // Must be last, have largest value! |
2317
|
63 }; |
|
64 |
3504
|
65 static data_type string_to_data_type (const std::string& s); |
4944
|
66 |
|
67 static void string_to_data_type (const std::string& s, int& block_size, |
|
68 data_type& input_type, |
|
69 data_type& output_type); |
|
70 |
|
71 static void string_to_data_type (const std::string& s, int& block_size, |
|
72 data_type& output_type); |
|
73 |
|
74 static std::string data_type_as_string (data_type dt); |
2317
|
75 }; |
|
76 |
3739
|
77 // Add new entries to the end of this enum, otherwise Octave will not |
|
78 // be able to read binary data files stored in Octave's binary data |
|
79 // format that were created with previous versions of Octave. |
|
80 |
1960
|
81 enum save_type |
|
82 { |
3739
|
83 LS_U_CHAR = 0, |
|
84 LS_U_SHORT = 1, |
|
85 LS_U_INT = 2, |
|
86 LS_CHAR = 3, |
|
87 LS_SHORT = 4, |
|
88 LS_INT = 5, |
|
89 LS_FLOAT = 6, |
|
90 LS_DOUBLE = 7, |
|
91 LS_U_LONG = 8, |
|
92 LS_LONG = 9 |
1960
|
93 }; |
|
94 |
6108
|
95 extern OCTAVE_API void |
4944
|
96 do_double_format_conversion (void *data, int len, |
|
97 oct_mach_info::float_format from_fmt, |
|
98 oct_mach_info::float_format to_fmt |
|
99 = oct_mach_info::native_float_format ()); |
1960
|
100 |
6108
|
101 extern OCTAVE_API void |
4944
|
102 do_float_format_conversion (void *data, int len, |
|
103 oct_mach_info::float_format from_fmt, |
|
104 oct_mach_info::float_format to_fmt |
|
105 = oct_mach_info::native_float_format ()); |
|
106 |
6108
|
107 extern OCTAVE_API void |
4944
|
108 do_float_format_conversion (void *data, size_t sz, int len, |
|
109 oct_mach_info::float_format from_fmt, |
|
110 oct_mach_info::float_format to_fmt |
|
111 = oct_mach_info::native_float_format ()); |
1960
|
112 |
6108
|
113 extern OCTAVE_API void |
3504
|
114 read_doubles (std::istream& is, double *data, save_type type, int len, |
4944
|
115 bool swap, oct_mach_info::float_format fmt); |
6108
|
116 extern OCTAVE_API void |
3504
|
117 write_doubles (std::ostream& os, const double *data, save_type type, int len); |
1960
|
118 |
|
119 #endif |
|
120 |
|
121 /* |
|
122 ;;; Local Variables: *** |
|
123 ;;; mode: C++ *** |
|
124 ;;; End: *** |
|
125 */ |