GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
data-conv.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if ! defined (octave_data_conv_h)
27#define octave_data_conv_h 1
28
29#include "octave-config.h"
30
31#include "mach-info.h"
32#include "oct-inttypes-fwd.h"
33
35{
36public:
37
39 {
40 dt_int8 = 0,
41 dt_uint8 = 1,
42 dt_int16 = 2,
43 dt_uint16 = 3,
44 dt_int32 = 4,
45 dt_uint32 = 5,
46 dt_int64 = 6,
47 dt_uint64 = 7,
48 dt_single = 8,
49 dt_double = 9,
50 dt_char = 10,
51 dt_schar = 11,
52 dt_uchar = 12,
53 dt_logical = 13,
54 dt_short = 14,
55 dt_ushort = 15,
56 dt_int = 16,
57 dt_uint = 17,
58 dt_long = 18,
59 dt_ulong = 19,
60 dt_longlong = 20,
61 dt_ulonglong = 21,
62 dt_float = 22,
63 dt_unknown = 23 // Must be last, have largest value!
64 };
65
66 static std::size_t data_type_size (data_type dt);
67
68 static data_type string_to_data_type (const std::string& s);
69
70 static void string_to_data_type (const std::string& s, int& block_size,
71 data_type& input_type,
72 data_type& output_type);
73
74 static void string_to_data_type (const std::string& s, int& block_size,
75 data_type& output_type);
76
77 static std::string data_type_as_string (data_type dt);
78};
79
80// Add new entries to the end of this enum, otherwise Octave will not
81// be able to read binary data files stored in Octave's binary data
82// format that were created with previous versions of Octave.
83
97
98extern OCTAVE_API void
100 octave::mach_info::float_format from_fmt,
101 octave::mach_info::float_format to_fmt
102 = octave::mach_info::native_float_format ());
103
104extern OCTAVE_API void
106 octave::mach_info::float_format from_fmt,
107 octave::mach_info::float_format to_fmt
108 = octave::mach_info::native_float_format ());
109
110extern OCTAVE_API void
111do_float_format_conversion (void *data, std::size_t sz, octave_idx_type len,
112 octave::mach_info::float_format from_fmt,
113 octave::mach_info::float_format to_fmt
114 = octave::mach_info::native_float_format ());
115
116extern OCTAVE_API void
117read_doubles (std::istream& is, double *data, save_type type,
118 octave_idx_type len, bool swap, octave::mach_info::float_format fmt);
119
120extern OCTAVE_API void
121write_doubles (std::ostream& os, const double *data, save_type type,
123
124extern OCTAVE_API void
125read_floats (std::istream& is, float *data, save_type type,
126 octave_idx_type len, bool swap, octave::mach_info::float_format fmt);
127
128extern OCTAVE_API void
129write_floats (std::ostream& os, const float *data, save_type type,
131
132template <typename T>
133inline bool
135{
136 return false;
137}
138
139template <>
145
146template <>
152
153template <>
159
160template <>
166
167template <>
173
174template <>
180
181template <>
187
188template <>
194
195template <>
201
202template <>
208
209template <>
215
216template <>
222
223template <>
229
230template <>
236
237template <>
243
244template <>
250
251template <>
257
258template <>
264
265#endif
bool is_equivalent_type< octave_uint8 >(oct_data_conv::data_type t)
Definition data-conv.h:225
bool is_equivalent_type< float >(oct_data_conv::data_type t)
Definition data-conv.h:260
bool is_equivalent_type< int16_t >(oct_data_conv::data_type t)
Definition data-conv.h:148
bool is_equivalent_type< octave_int64 >(oct_data_conv::data_type t)
Definition data-conv.h:218
bool is_equivalent_type< octave_int8 >(oct_data_conv::data_type t)
Definition data-conv.h:197
void do_float_format_conversion(void *data, octave_idx_type len, octave::mach_info::float_format from_fmt, octave::mach_info::float_format to_fmt=octave::mach_info::native_float_format())
Definition data-conv.cc:732
bool is_equivalent_type(oct_data_conv::data_type)
Definition data-conv.h:134
void do_double_format_conversion(void *data, octave_idx_type len, octave::mach_info::float_format from_fmt, octave::mach_info::float_format to_fmt=octave::mach_info::native_float_format())
Definition data-conv.cc:685
bool is_equivalent_type< double >(oct_data_conv::data_type t)
Definition data-conv.h:253
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Definition data-conv.cc:802
save_type
Definition data-conv.h:85
@ LS_U_CHAR
Definition data-conv.h:86
@ LS_DOUBLE
Definition data-conv.h:93
@ LS_LONG
Definition data-conv.h:95
@ LS_U_LONG
Definition data-conv.h:94
@ LS_U_SHORT
Definition data-conv.h:87
@ LS_FLOAT
Definition data-conv.h:92
@ LS_SHORT
Definition data-conv.h:90
@ LS_CHAR
Definition data-conv.h:89
@ LS_INT
Definition data-conv.h:91
@ LS_U_INT
Definition data-conv.h:88
bool is_equivalent_type< uint16_t >(oct_data_conv::data_type t)
Definition data-conv.h:176
bool is_equivalent_type< octave_uint32 >(oct_data_conv::data_type t)
Definition data-conv.h:239
bool is_equivalent_type< octave_int16 >(oct_data_conv::data_type t)
Definition data-conv.h:204
bool is_equivalent_type< octave_uint64 >(oct_data_conv::data_type t)
Definition data-conv.h:246
bool is_equivalent_type< octave_int32 >(oct_data_conv::data_type t)
Definition data-conv.h:211
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
Definition data-conv.cc:918
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
Definition data-conv.cc:968
bool is_equivalent_type< int64_t >(oct_data_conv::data_type t)
Definition data-conv.h:162
bool is_equivalent_type< int32_t >(oct_data_conv::data_type t)
Definition data-conv.h:155
bool is_equivalent_type< octave_uint16 >(oct_data_conv::data_type t)
Definition data-conv.h:232
bool is_equivalent_type< uint32_t >(oct_data_conv::data_type t)
Definition data-conv.h:183
bool is_equivalent_type< uint64_t >(oct_data_conv::data_type t)
Definition data-conv.h:190
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Definition data-conv.cc:862
bool is_equivalent_type< int8_t >(oct_data_conv::data_type t)
Definition data-conv.h:141
bool is_equivalent_type< uint8_t >(oct_data_conv::data_type t)
Definition data-conv.h:169
#define OCTAVE_API
Definition main.in.cc:55
F77_RET_T len
Definition xerbla.cc:61