comparison armadillo-2.4.4/include/armadillo_bits/diskio_bones.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2011 Conrad Sanderson
3 // Copyright (C) 2009-2010 Ian Cullinan
4 //
5 // This file is part of the Armadillo C++ library.
6 // It is provided without any warranty of fitness
7 // for any purpose. You can redistribute this file
8 // and/or modify it under the terms of the GNU
9 // Lesser General Public License (LGPL) as published
10 // by the Free Software Foundation, either version 3
11 // of the License or (at your option) any later version.
12 // (see http://www.opensource.org/licenses for more info)
13
14
15 //! \addtogroup diskio
16 //! @{
17
18
19 //! class for saving and loading matrices and fields
20 class diskio
21 {
22 public:
23
24 template<typename eT> inline static std::string gen_txt_header(const Mat<eT>& x);
25 template<typename eT> inline static std::string gen_bin_header(const Mat<eT>& x);
26
27 template<typename eT> inline static std::string gen_txt_header(const Cube<eT>& x);
28 template<typename eT> inline static std::string gen_bin_header(const Cube<eT>& x);
29
30 inline static file_type guess_file_type(std::istream& f);
31
32 inline static char conv_to_hex_char(const u8 x);
33 inline static void conv_to_hex(char* out, const u8 x);
34
35 inline static std::string gen_tmp_name(const std::string& x);
36
37 inline static bool safe_rename(const std::string& old_name, const std::string& new_name);
38
39
40 //
41 // matrix saving
42
43 template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, const std::string& final_name);
44 template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, const std::string& final_name);
45 template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, const std::string& final_name);
46 template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, const std::string& final_name);
47 template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, const std::string& final_name);
48 template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, const std::string& final_name);
49 template<typename T> inline static bool save_pgm_binary (const Mat< std::complex<T> >& x, const std::string& final_name);
50
51 template<typename eT> inline static bool save_raw_ascii (const Mat<eT>& x, std::ostream& f);
52 template<typename eT> inline static bool save_raw_binary (const Mat<eT>& x, std::ostream& f);
53 template<typename eT> inline static bool save_arma_ascii (const Mat<eT>& x, std::ostream& f);
54 template<typename eT> inline static bool save_csv_ascii (const Mat<eT>& x, std::ostream& f);
55 template<typename eT> inline static bool save_arma_binary(const Mat<eT>& x, std::ostream& f);
56 template<typename eT> inline static bool save_pgm_binary (const Mat<eT>& x, std::ostream& f);
57 template<typename T> inline static bool save_pgm_binary (const Mat< std::complex<T> >& x, std::ostream& f);
58
59
60 //
61 // matrix loading
62
63 template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
64 template<typename eT> inline static bool load_raw_binary (Mat<eT>& x, const std::string& name, std::string& err_msg);
65 template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
66 template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, const std::string& name, std::string& err_msg);
67 template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, const std::string& name, std::string& err_msg);
68 template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, const std::string& name, std::string& err_msg);
69 template<typename T> inline static bool load_pgm_binary (Mat< std::complex<T> >& x, const std::string& name, std::string& err_msg);
70 template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, const std::string& name, std::string& err_msg);
71
72 template<typename eT> inline static bool load_raw_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
73 template<typename eT> inline static bool load_raw_binary (Mat<eT>& x, std::istream& f, std::string& err_msg);
74 template<typename eT> inline static bool load_arma_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
75 template<typename eT> inline static bool load_csv_ascii (Mat<eT>& x, std::istream& f, std::string& err_msg);
76 template<typename eT> inline static bool load_arma_binary(Mat<eT>& x, std::istream& f, std::string& err_msg);
77 template<typename eT> inline static bool load_pgm_binary (Mat<eT>& x, std::istream& is, std::string& err_msg);
78 template<typename T> inline static bool load_pgm_binary (Mat< std::complex<T> >& x, std::istream& is, std::string& err_msg);
79 template<typename eT> inline static bool load_auto_detect(Mat<eT>& x, std::istream& f, std::string& err_msg);
80
81 inline static void pnm_skip_comments(std::istream& f);
82
83
84 //
85 // cube saving
86
87 template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, const std::string& name);
88 template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, const std::string& name);
89 template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, const std::string& name);
90 template<typename eT> inline static bool save_arma_binary(const Cube<eT>& x, const std::string& name);
91
92 template<typename eT> inline static bool save_raw_ascii (const Cube<eT>& x, std::ostream& f);
93 template<typename eT> inline static bool save_raw_binary (const Cube<eT>& x, std::ostream& f);
94 template<typename eT> inline static bool save_arma_ascii (const Cube<eT>& x, std::ostream& f);
95 template<typename eT> inline static bool save_arma_binary(const Cube<eT>& x, std::ostream& f);
96
97
98 //
99 // cube loading
100
101 template<typename eT> inline static bool load_raw_ascii (Cube<eT>& x, const std::string& name, std::string& err_msg);
102 template<typename eT> inline static bool load_raw_binary (Cube<eT>& x, const std::string& name, std::string& err_msg);
103 template<typename eT> inline static bool load_arma_ascii (Cube<eT>& x, const std::string& name, std::string& err_msg);
104 template<typename eT> inline static bool load_arma_binary(Cube<eT>& x, const std::string& name, std::string& err_msg);
105 template<typename eT> inline static bool load_auto_detect(Cube<eT>& x, const std::string& name, std::string& err_msg);
106
107 template<typename eT> inline static bool load_raw_ascii (Cube<eT>& x, std::istream& f, std::string& err_msg);
108 template<typename eT> inline static bool load_raw_binary (Cube<eT>& x, std::istream& f, std::string& err_msg);
109 template<typename eT> inline static bool load_arma_ascii (Cube<eT>& x, std::istream& f, std::string& err_msg);
110 template<typename eT> inline static bool load_arma_binary(Cube<eT>& x, std::istream& f, std::string& err_msg);
111 template<typename eT> inline static bool load_auto_detect(Cube<eT>& x, std::istream& f, std::string& err_msg);
112
113
114 //
115 // field saving and loading
116
117 template<typename T1> inline static bool save_arma_binary(const field<T1>& x, const std::string& name);
118 template<typename T1> inline static bool save_arma_binary(const field<T1>& x, std::ostream& f);
119
120 template<typename T1> inline static bool load_arma_binary( field<T1>& x, const std::string& name, std::string& err_msg);
121 template<typename T1> inline static bool load_arma_binary( field<T1>& x, std::istream& f, std::string& err_msg);
122
123 template<typename T1> inline static bool load_auto_detect( field<T1>& x, const std::string& name, std::string& err_msg);
124 template<typename T1> inline static bool load_auto_detect( field<T1>& x, std::istream& f, std::string& err_msg);
125
126 inline static bool save_std_string(const field<std::string>& x, const std::string& name);
127 inline static bool save_std_string(const field<std::string>& x, std::ostream& f);
128
129 inline static bool load_std_string( field<std::string>& x, const std::string& name, std::string& err_msg);
130 inline static bool load_std_string( field<std::string>& x, std::istream& f, std::string& err_msg);
131
132
133
134 //
135 // handling of PPM images by cubes
136
137 template<typename T1> inline static bool save_ppm_binary(const Cube<T1>& x, const std::string& final_name);
138 template<typename T1> inline static bool save_ppm_binary(const Cube<T1>& x, std::ostream& f);
139
140 template<typename T1> inline static bool load_ppm_binary( Cube<T1>& x, const std::string& final_name, std::string& err_msg);
141 template<typename T1> inline static bool load_ppm_binary( Cube<T1>& x, std::istream& f, std::string& err_msg);
142
143
144 //
145 // handling of PPM images by fields
146
147 template<typename T1> inline static bool save_ppm_binary(const field<T1>& x, const std::string& final_name);
148 template<typename T1> inline static bool save_ppm_binary(const field<T1>& x, std::ostream& f);
149
150 template<typename T1> inline static bool load_ppm_binary( field<T1>& x, const std::string& final_name, std::string& err_msg);
151 template<typename T1> inline static bool load_ppm_binary( field<T1>& x, std::istream& f, std::string& err_msg);
152
153
154
155 };
156
157
158
159 //! @}