gslcpp
Modern-C++ Wrapper for GSL
fread.hpp
Go to the documentation of this file.
1 /// \file include/gslcpp/wrap/fread.hpp
2 /// \copyright 2022 Thomas E. Vaughan, all rights reserved.
3 /// \brief Definition of gsl::w_fread().
4 
5 #pragma once
6 #include "container.hpp" // w_vector
7 
8 namespace gsl {
9 
10 
11 /// Read into `v` from stream `f` in binary format.
12 ///
13 /// Before call to `%w_fread()`, `v` must already have right size because
14 /// `%w_fread()` uses size of `v` to determine number bytes to read.
15 ///
16 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
17 ///
18 /// @param f Pointer to file-stream.
19 /// @param v Pointer to vector that should be initialized from stream.
20 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
21 inline int w_fread(FILE *f, w_vector<double> *v) {
22  return gsl_vector_fread(f, v);
23 }
24 
25 
26 /// Read into `v` from stream `f` in binary format.
27 ///
28 /// Before call to `%w_fread()`, `v` must already have right size because
29 /// `%w_fread()` uses size of `v` to determine number bytes to read.
30 ///
31 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
32 ///
33 /// @param f Pointer to file-stream.
34 /// @param v Pointer to vector that should be initialized from stream.
35 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
36 inline int w_fread(FILE *f, w_vector<float> *v) {
37  return gsl_vector_float_fread(f, v);
38 }
39 
40 
41 /// Read into `v` from stream `f` in binary format.
42 ///
43 /// Before call to `%w_fread()`, `v` must already have right size because
44 /// `%w_fread()` uses size of `v` to determine number bytes to read.
45 ///
46 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
47 ///
48 /// @param f Pointer to file-stream.
49 /// @param v Pointer to vector that should be initialized from stream.
50 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
51 inline int w_fread(FILE *f, w_vector<long double> *v) {
52  return gsl_vector_long_double_fread(f, v);
53 }
54 
55 
56 /// Read into `v` from stream `f` in binary format.
57 ///
58 /// Before call to `%w_fread()`, `v` must already have right size because
59 /// `%w_fread()` uses size of `v` to determine number bytes to read.
60 ///
61 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
62 ///
63 /// @param f Pointer to file-stream.
64 /// @param v Pointer to vector that should be initialized from stream.
65 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
66 inline int w_fread(FILE *f, w_vector<int> *v) {
67  return gsl_vector_int_fread(f, v);
68 }
69 
70 
71 /// Read into `v` from stream `f` in binary format.
72 ///
73 /// Before call to `%w_fread()`, `v` must already have right size because
74 /// `%w_fread()` uses size of `v` to determine number bytes to read.
75 ///
76 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
77 ///
78 /// @param f Pointer to file-stream.
79 /// @param v Pointer to vector that should be initialized from stream.
80 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
81 inline int w_fread(FILE *f, w_vector<unsigned> *v) {
82  return gsl_vector_uint_fread(f, v);
83 }
84 
85 
86 /// Read into `v` from stream `f` in binary format.
87 ///
88 /// Before call to `%w_fread()`, `v` must already have right size because
89 /// `%w_fread()` uses size of `v` to determine number bytes to read.
90 ///
91 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
92 ///
93 /// @param f Pointer to file-stream.
94 /// @param v Pointer to vector that should be initialized from stream.
95 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
96 inline int w_fread(FILE *f, w_vector<long> *v) {
97  return gsl_vector_long_fread(f, v);
98 }
99 
100 
101 /// Read into `v` from stream `f` in binary format.
102 ///
103 /// Before call to `%w_fread()`, `v` must already have right size because
104 /// `%w_fread()` uses size of `v` to determine number bytes to read.
105 ///
106 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
107 ///
108 /// @param f Pointer to file-stream.
109 /// @param v Pointer to vector that should be initialized from stream.
110 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
111 inline int w_fread(FILE *f, w_vector<unsigned long> *v) {
112  return gsl_vector_ulong_fread(f, v);
113 }
114 
115 
116 /// Read into `v` from stream `f` in binary format.
117 ///
118 /// Before call to `%w_fread()`, `v` must already have right size because
119 /// `%w_fread()` uses size of `v` to determine number bytes to read.
120 ///
121 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
122 ///
123 /// @param f Pointer to file-stream.
124 /// @param v Pointer to vector that should be initialized from stream.
125 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
126 inline int w_fread(FILE *f, w_vector<short> *v) {
127  return gsl_vector_short_fread(f, v);
128 }
129 
130 
131 /// Read into `v` from stream `f` in binary format.
132 ///
133 /// Before call to `%w_fread()`, `v` must already have right size because
134 /// `%w_fread()` uses size of `v` to determine number bytes to read.
135 ///
136 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
137 ///
138 /// @param f Pointer to file-stream.
139 /// @param v Pointer to vector that should be initialized from stream.
140 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
141 inline int w_fread(FILE *f, w_vector<unsigned short> *v) {
142  return gsl_vector_ushort_fread(f, v);
143 }
144 
145 
146 /// Read into `v` from stream `f` in binary format.
147 ///
148 /// Before call to `%w_fread()`, `v` must already have right size because
149 /// `%w_fread()` uses size of `v` to determine number bytes to read.
150 ///
151 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
152 ///
153 /// @param f Pointer to file-stream.
154 /// @param v Pointer to vector that should be initialized from stream.
155 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
156 inline int w_fread(FILE *f, w_vector<char> *v) {
157  return gsl_vector_char_fread(f, v);
158 }
159 
160 
161 /// Read into `v` from stream `f` in binary format.
162 ///
163 /// Before call to `%w_fread()`, `v` must already have right size because
164 /// `%w_fread()` uses size of `v` to determine number bytes to read.
165 ///
166 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
167 ///
168 /// @param f Pointer to file-stream.
169 /// @param v Pointer to vector that should be initialized from stream.
170 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
171 inline int w_fread(FILE *f, w_vector<unsigned char> *v) {
172  return gsl_vector_uchar_fread(f, v);
173 }
174 
175 
176 /// Read into `v` from stream `f` in binary format.
177 ///
178 /// Before call to `%w_fread()`, `v` must already have right size because
179 /// `%w_fread()` uses size of `v` to determine number bytes to read.
180 ///
181 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
182 ///
183 /// @param f Pointer to file-stream.
184 /// @param v Pointer to vector that should be initialized from stream.
185 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
186 inline int w_fread(FILE *f, w_vector<complex<double>> *v) {
187  return gsl_vector_complex_fread(f, v);
188 }
189 
190 
191 /// Read into `v` from stream `f` in binary format.
192 ///
193 /// Before call to `%w_fread()`, `v` must already have right size because
194 /// `%w_fread()` uses size of `v` to determine number bytes to read.
195 ///
196 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
197 ///
198 /// @param f Pointer to file-stream.
199 /// @param v Pointer to vector that should be initialized from stream.
200 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
201 inline int w_fread(FILE *f, w_vector<complex<float>> *v) {
202  return gsl_vector_complex_float_fread(f, v);
203 }
204 
205 
206 /// Read into `v` from stream `f` in binary format.
207 ///
208 /// Before call to `%w_fread()`, `v` must already have right size because
209 /// `%w_fread()` uses size of `v` to determine number bytes to read.
210 ///
211 /// https://www.gnu.org/software/gsl/doc/html/vectors.html#c.gsl_vector_fread
212 ///
213 /// @param f Pointer to file-stream.
214 /// @param v Pointer to vector that should be initialized from stream.
215 /// @return 0 on success or GSL_EFAILED on problem reading from stream.
216 inline int w_fread(FILE *f, w_vector<complex<long double>> *v) {
217  return gsl_vector_complex_long_double_fread(f, v);
218 }
219 
220 
221 } // namespace gsl
222 
223 // EOF
gsl::w_fread
int w_fread(FILE *f, w_vector< unsigned char > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:171
gsl::w_fread
int w_fread(FILE *f, w_vector< unsigned long > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:111
gsl::w_fread
int w_fread(FILE *f, w_vector< complex< float >> *v)
Read into v from stream f in binary format.
Definition: fread.hpp:201
gsl::w_fread
int w_fread(FILE *f, w_vector< unsigned > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:81
gsl::w_fread
int w_fread(FILE *f, w_vector< unsigned short > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:141
gsl::w_fread
int w_fread(FILE *f, w_vector< int > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:66
gsl::w_fread
int w_fread(FILE *f, w_vector< float > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:36
gsl::w_fread
int w_fread(FILE *f, w_vector< complex< double >> *v)
Read into v from stream f in binary format.
Definition: fread.hpp:186
gsl::w_fread
int w_fread(FILE *f, w_vector< double > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:21
gsl::w_fread
int w_fread(FILE *f, w_vector< short > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:126
gsl::w_fread
int w_fread(FILE *f, w_vector< long double > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:51
gsl::w_fread
int w_fread(FILE *f, w_vector< complex< long double >> *v)
Read into v from stream f in binary format.
Definition: fread.hpp:216
gsl::w_fread
int w_fread(FILE *f, w_vector< long > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:96
gsl
Namespace for C++-interface to GSL.
Definition: v-iface.hpp:51
gsl::w_fread
int w_fread(FILE *f, w_vector< char > *v)
Read into v from stream f in binary format.
Definition: fread.hpp:156