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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_data_conv_h) |
|
24 #define octave_data_conv_h 1 |
|
25 |
|
26 #include <climits> |
|
27 |
2317
|
28 #include "mach-info.h" |
1960
|
29 |
|
30 // Not all of the following are currently used. |
|
31 |
|
32 #if CHAR_BIT != 8 |
|
33 #error "CHAR_BIT is not 8!" |
|
34 #endif |
|
35 |
|
36 #if SIZEOF_SHORT == 2 |
|
37 #define TWO_BYTE_INT short |
|
38 #elif SIZEOF_INT == 2 |
|
39 #define TWO_BYTE_INT int |
|
40 #else |
|
41 #error "No 2 byte integer type found!" |
|
42 #endif |
|
43 |
|
44 #if SIZEOF_INT == 4 |
|
45 #define FOUR_BYTE_INT int |
|
46 #elif SIZEOF_LONG == 4 |
|
47 #define FOUR_BYTE_INT long |
|
48 #else |
|
49 #error "No 4 byte integer type found!" |
|
50 #endif |
|
51 |
3688
|
52 #if SIZEOF_LONG == 8 |
|
53 #define EIGHT_BYTE_INT long |
|
54 #else |
|
55 #if SIZEOF_LONG_LONG == 8 |
|
56 // if `long long' is not implemented, then SIZEOF_LONG_LONG will be 0 |
|
57 #define EIGHT_BYTE_INT long long |
|
58 // if no 8 byte integer type is found, then EIGHT_BYTE_INT is not defined |
|
59 #endif |
|
60 #endif |
|
61 |
2317
|
62 class |
|
63 oct_data_conv |
|
64 { |
|
65 public: |
|
66 |
|
67 enum data_type |
|
68 { |
|
69 dt_unknown, |
|
70 dt_char, |
|
71 dt_schar, |
|
72 dt_uchar, |
|
73 dt_short, |
|
74 dt_ushort, |
|
75 dt_int, |
|
76 dt_uint, |
|
77 dt_long, |
|
78 dt_ulong, |
|
79 dt_float, |
|
80 dt_double, |
|
81 dt_float_complex, |
|
82 dt_double_complex |
|
83 }; |
|
84 |
3504
|
85 static data_type string_to_data_type (const std::string& s); |
2317
|
86 }; |
|
87 |
3739
|
88 // Add new entries to the end of this enum, otherwise Octave will not |
|
89 // be able to read binary data files stored in Octave's binary data |
|
90 // format that were created with previous versions of Octave. |
|
91 |
1960
|
92 enum save_type |
|
93 { |
3739
|
94 LS_U_CHAR = 0, |
|
95 LS_U_SHORT = 1, |
|
96 LS_U_INT = 2, |
|
97 LS_CHAR = 3, |
|
98 LS_SHORT = 4, |
|
99 LS_INT = 5, |
|
100 LS_FLOAT = 6, |
|
101 LS_DOUBLE = 7, |
|
102 LS_U_LONG = 8, |
|
103 LS_LONG = 9 |
1960
|
104 }; |
|
105 |
|
106 extern void |
2317
|
107 do_double_format_conversion (double *data, int len, |
|
108 oct_mach_info::float_format fmt); |
1960
|
109 |
|
110 extern void |
2317
|
111 do_float_format_conversion (float *data, int len, |
|
112 oct_mach_info::float_format fmt); |
1960
|
113 |
|
114 extern void |
3504
|
115 read_doubles (std::istream& is, double *data, save_type type, int len, |
2317
|
116 int swap, oct_mach_info::float_format fmt); |
1960
|
117 extern void |
3504
|
118 write_doubles (std::ostream& os, const double *data, save_type type, int len); |
1960
|
119 |
|
120 #endif |
|
121 |
|
122 /* |
|
123 ;;; Local Variables: *** |
|
124 ;;; mode: C++ *** |
|
125 ;;; End: *** |
|
126 */ |