Mercurial > hg > octave-nkf
annotate liboctave/data-conv.h @ 15283:a95432e7309c stable release-3-6-3
Version 3.6.3 released.
* configure.ac (AC_INIT): Version is now 3.6.3.
(OCTAVE_RELEASE_DATE): Now 2012-09-04.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 04 Sep 2012 13:17:13 -0400 |
parents | 72c96de7a403 |
children | 9020dddc925a |
rev | line source |
---|---|
1960 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1996-2012 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1960 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1960 | 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 |
2317 | 30 class |
6108 | 31 OCTAVE_API |
2317 | 32 oct_data_conv |
33 { | |
34 public: | |
35 | |
36 enum data_type | |
37 { | |
4944 | 38 dt_int8 = 0, |
39 dt_uint8 = 1, | |
40 dt_int16 = 2, | |
41 dt_uint16 = 3, | |
42 dt_int32 = 4, | |
43 dt_uint32 = 5, | |
44 dt_int64 = 6, | |
45 dt_uint64 = 7, | |
46 dt_single = 8, | |
47 dt_double = 9, | |
48 dt_char = 10, | |
49 dt_schar = 11, | |
50 dt_uchar = 12, | |
4970 | 51 dt_logical = 13, |
52 dt_short = 14, | |
53 dt_ushort = 15, | |
54 dt_int = 16, | |
55 dt_uint = 17, | |
56 dt_long = 18, | |
57 dt_ulong = 19, | |
58 dt_longlong = 20, | |
59 dt_ulonglong = 21, | |
60 dt_float = 22, | |
61 dt_unknown = 23 // Must be last, have largest value! | |
2317 | 62 }; |
63 | |
3504 | 64 static data_type string_to_data_type (const std::string& s); |
4944 | 65 |
66 static void string_to_data_type (const std::string& s, int& block_size, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
67 data_type& input_type, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
68 data_type& output_type); |
4944 | 69 |
70 static void string_to_data_type (const std::string& s, int& block_size, | |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
71 data_type& output_type); |
4944 | 72 |
73 static std::string data_type_as_string (data_type dt); | |
2317 | 74 }; |
75 | |
3739 | 76 // Add new entries to the end of this enum, otherwise Octave will not |
77 // be able to read binary data files stored in Octave's binary data | |
78 // format that were created with previous versions of Octave. | |
79 | |
1960 | 80 enum save_type |
81 { | |
3739 | 82 LS_U_CHAR = 0, |
83 LS_U_SHORT = 1, | |
84 LS_U_INT = 2, | |
85 LS_CHAR = 3, | |
86 LS_SHORT = 4, | |
87 LS_INT = 5, | |
88 LS_FLOAT = 6, | |
89 LS_DOUBLE = 7, | |
90 LS_U_LONG = 8, | |
91 LS_LONG = 9 | |
1960 | 92 }; |
93 | |
6108 | 94 extern OCTAVE_API void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
95 do_double_format_conversion (void *data, octave_idx_type len, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
96 oct_mach_info::float_format from_fmt, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
97 oct_mach_info::float_format to_fmt |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
98 = oct_mach_info::native_float_format ()); |
1960 | 99 |
6108 | 100 extern OCTAVE_API void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
101 do_float_format_conversion (void *data, octave_idx_type len, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
102 oct_mach_info::float_format from_fmt, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
103 oct_mach_info::float_format to_fmt |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
104 = oct_mach_info::native_float_format ()); |
4944 | 105 |
6108 | 106 extern OCTAVE_API void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
107 do_float_format_conversion (void *data, size_t sz, octave_idx_type len, |
10312
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
108 oct_mach_info::float_format from_fmt, |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
109 oct_mach_info::float_format to_fmt |
cbc402e64d83
untabify liboctave header files
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
110 = oct_mach_info::native_float_format ()); |
1960 | 111 |
6108 | 112 extern OCTAVE_API void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
113 read_doubles (std::istream& is, double *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
114 octave_idx_type len, bool swap, oct_mach_info::float_format fmt); |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
115 |
6108 | 116 extern OCTAVE_API void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
117 write_doubles (std::ostream& os, const double *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
118 octave_idx_type len); |
1960 | 119 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
120 extern OCTAVE_API void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
121 read_floats (std::istream& is, float *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
122 octave_idx_type len, bool swap, oct_mach_info::float_format fmt); |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
123 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
124 extern OCTAVE_API void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
125 write_floats (std::ostream& os, const float *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
126 octave_idx_type len); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
127 |
1960 | 128 #endif |