annotate liboctave/data-conv.h @ 6196:4942c93e37e3

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