1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
// SPDX-License-Identifier: Apache-2.0
//
// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
// Copyright 2008-2016 National ICT Australia (NICTA)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
//! \addtogroup diskio
//! @{
//! class for saving and loading matrices and fields - INTERNAL USE ONLY!
class diskio
{
public:
arma_deprecated inline static file_type guess_file_type(std::istream& f);
private:
template<typename eT> friend class Mat;
template<typename eT> friend class Cube;
template<typename eT> friend class SpMat;
template<typename oT> friend class field;
friend class Mat_aux;
friend class Cube_aux;
friend class SpMat_aux;
friend class field_aux;
template<typename eT> arma_cold inline static std::string gen_txt_header(const Mat<eT>&);
template<typename eT> arma_cold inline static std::string gen_bin_header(const Mat<eT>&);
template<typename eT> arma_cold inline static std::string gen_bin_header(const SpMat<eT>&);
template<typename eT> arma_cold inline static std::string gen_txt_header(const Cube<eT>&);
template<typename eT> arma_cold inline static std::string gen_bin_header(const Cube<eT>&);
arma_cold inline static file_type guess_file_type_internal(std::istream& f);
arma_cold inline static std::string gen_tmp_name(const std::string& x);
arma_cold inline static bool safe_rename(const std::string& old_name, const std::string& new_name);
arma_cold inline static bool is_readable(const std::string& name);
arma_cold inline static void sanitise_token(std::string& token);
template<typename eT> inline static bool convert_token(eT& val, const std::string& token);
template<typename T> inline static bool convert_token(std::complex<T>& val, const std::string& token);
template<typename eT> inline static bool convert_token_strict(eT& val, const std::string& token);
template<typename eT> inline static std::streamsize prepare_stream(std::ostream& f);
//
// matrix saving
template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, const std::string& final_name, const field<std::string>& header, const bool with_header, const char separator);
template<typename eT> inline static bool save_coord_ascii(const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, const std::string& final_name);
template<typename T> inline static bool save_pgm_binary (const Mat< std::complex<T> >& x, const std::string& final_name);
template<typename eT> inline static bool save_hdf5_binary(const Mat<eT>& x, const hdf5_name& spec, std::string& err_msg);
template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, std::ostream& f, const char separator);
template<typename T> inline static bool save_csv_ascii (const Mat< std::complex<T> >& x, std::ostream& f, const char separator);
template<typename eT> inline static bool save_coord_ascii(const Mat<eT>& x, std::ostream& f);
template<typename T> inline static bool save_coord_ascii(const Mat< std::complex<T> >& x, std::ostream& f);
template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, std::ostream& f);
template<typename T> inline static bool save_pgm_binary (const Mat< std::complex<T> >& x, std::ostream& f);
//
// matrix loading
template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg, field<std::string>& header, const bool with_header, const char separator, const bool strict);
template<typename eT> inline static bool load_coord_ascii(Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename T> inline static bool load_pgm_binary (Mat< std::complex<T> >& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_hdf5_binary(Mat<eT>& x, const hdf5_name& spec, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg, const char separator, const bool strict);
template<typename T> inline static bool load_csv_ascii (Mat< std::complex<T> >& x, std::istream& f, std::string& err_msg, const char separator, const bool strict);
template<typename eT> inline static bool load_coord_ascii(Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename T> inline static bool load_coord_ascii(Mat< std::complex<T> >& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, std::istream& is, std::string& err_msg);
template<typename T> inline static bool load_pgm_binary (Mat< std::complex<T> >& x, std::istream& is, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, std::istream& f, std::string& err_msg);
inline static void pnm_skip_comments(std::istream& f);
//
// sparse matrix saving
template<typename eT> inline static bool save_csv_ascii (const SpMat<eT>& x, const std::string& final_name, const field<std::string>& header, const bool with_header, const char separator);
template<typename eT> inline static bool save_coord_ascii(const SpMat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_arma_binary(const SpMat<eT>& x, const std::string& final_name);
template<typename eT> inline static bool save_csv_ascii (const SpMat<eT>& x, std::ostream& f, const char separator);
template<typename T> inline static bool save_csv_ascii (const SpMat< std::complex<T> >& x, std::ostream& f, const char separator);
template<typename eT> inline static bool save_coord_ascii(const SpMat<eT>& x, std::ostream& f);
template<typename T> inline static bool save_coord_ascii(const SpMat< std::complex<T> >& x, std::ostream& f);
template<typename eT> inline static bool save_arma_binary(const SpMat<eT>& x, std::ostream& f);
//
// sparse matrix loading
template<typename eT> inline static bool load_csv_ascii (SpMat<eT>& x, const std::string& name, std::string& err_msg, field<std::string>& header, const bool with_header, const char separator);
template<typename eT> inline static bool load_coord_ascii(SpMat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(SpMat<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_csv_ascii (SpMat<eT>& x, std::istream& f, std::string& err_msg, const char separator);
template<typename T> inline static bool load_csv_ascii (SpMat< std::complex<T> >& x, std::istream& f, std::string& err_msg, const char separator);
template<typename eT> inline static bool load_coord_ascii(SpMat<eT>& x, std::istream& f, std::string& err_msg);
template<typename T> inline static bool load_coord_ascii(SpMat< std::complex<T> >& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(SpMat<eT>& x, std::istream& f, std::string& err_msg);
//
// cube saving
template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_arma_binary(const Cube<eT>& x, const std::string& name);
template<typename eT> inline static bool save_hdf5_binary(const Cube<eT>& x, const hdf5_name& spec, std::string& err_msg);
template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, std::ostream& f);
template<typename eT> inline static bool save_arma_binary(const Cube<eT>& x, std::ostream& f);
//
// cube loading
template<typename eT> inline static bool load_raw_ascii (Cube<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (Cube<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_ascii (Cube<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(Cube<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_hdf5_binary(Cube<eT>& x, const hdf5_name& spec, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(Cube<eT>& x, const std::string& name, std::string& err_msg);
template<typename eT> inline static bool load_raw_ascii (Cube<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_raw_binary (Cube<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_ascii (Cube<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_arma_binary(Cube<eT>& x, std::istream& f, std::string& err_msg);
template<typename eT> inline static bool load_auto_detect(Cube<eT>& x, std::istream& f, std::string& err_msg);
//
// field saving and loading
template<typename T1> inline static bool save_arma_binary(const field<T1>& x, const std::string& name);
template<typename T1> inline static bool save_arma_binary(const field<T1>& x, std::ostream& f);
template<typename T1> inline static bool load_arma_binary( field<T1>& x, const std::string& name, std::string& err_msg);
template<typename T1> inline static bool load_arma_binary( field<T1>& x, std::istream& f, std::string& err_msg);
template<typename T1> inline static bool load_auto_detect( field<T1>& x, const std::string& name, std::string& err_msg);
template<typename T1> inline static bool load_auto_detect( field<T1>& x, std::istream& f, std::string& err_msg);
inline static bool save_std_string(const field<std::string>& x, const std::string& name);
inline static bool save_std_string(const field<std::string>& x, std::ostream& f);
inline static bool load_std_string( field<std::string>& x, const std::string& name, std::string& err_msg);
inline static bool load_std_string( field<std::string>& x, std::istream& f, std::string& err_msg);
//
// handling of PPM images by cubes
template<typename T1> inline static bool save_ppm_binary(const Cube<T1>& x, const std::string& final_name);
template<typename T1> inline static bool save_ppm_binary(const Cube<T1>& x, std::ostream& f);
template<typename T1> inline static bool load_ppm_binary( Cube<T1>& x, const std::string& final_name, std::string& err_msg);
template<typename T1> inline static bool load_ppm_binary( Cube<T1>& x, std::istream& f, std::string& err_msg);
//
// handling of PPM images by fields
template<typename T1> inline static bool save_ppm_binary(const field<T1>& x, const std::string& final_name);
template<typename T1> inline static bool save_ppm_binary(const field<T1>& x, std::ostream& f);
template<typename T1> inline static bool load_ppm_binary( field<T1>& x, const std::string& final_name, std::string& err_msg);
template<typename T1> inline static bool load_ppm_binary( field<T1>& x, std::istream& f, std::string& err_msg);
};
//! @}
|