Directory: | ./ |
---|---|
File: | build/tmp_project/PhoenixDataStream/src/data_stream_file_simple_type.cpp |
Date: | 2025-03-14 12:18:05 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 495 | 495 | 100.0% |
Branches: | 101 | 143 | 70.6% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | |||
2 | /*************************************** | ||
3 | Auteur : Pierre Aubert | ||
4 | Mail : pierre.aubert@lapp.in2p3.fr | ||
5 | Licence : CeCILL-C | ||
6 | ****************************************/ | ||
7 | |||
8 | |||
9 | #include "data_stream_file_simple_type.h" | ||
10 | |||
11 | ///Read the data char in the file | ||
12 | /** @param[out] ds : file to be read | ||
13 | * @param[out] data : data to be set | ||
14 | * @return true on success, false otherwise | ||
15 | */ | ||
16 | 723 | bool DataStream<FILE*, DataStreamMode::READ, char>::data_stream(FILE* & ds, char & data){ | |
17 | 723 | return fread((void*)&data, sizeof(char), 1lu, ds) == 1lu; | |
18 | } | ||
19 | |||
20 | ///Read the data char in the file | ||
21 | /** @param[out] ds : file to be read | ||
22 | * @param[out] data : data to be set | ||
23 | * @param nbElement : number of element of this data | ||
24 | * @return true on success, false otherwise | ||
25 | */ | ||
26 | 98 | bool DataStream<FILE*, DataStreamMode::READ, char>::data_stream(FILE* & ds, char * data, size_t nbElement){ | |
27 | 98 | return fread((void*)data, sizeof(char), nbElement, ds) == nbElement; | |
28 | } | ||
29 | |||
30 | ///Read the data std::vector of char in the file | ||
31 | /** @param[out] ds : file to be read | ||
32 | * @param[out] data : data to be set | ||
33 | * @return true on success, false otherwise | ||
34 | */ | ||
35 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<char> >::data_stream(FILE* & ds, std::vector<char> & data){ | |
36 | 1 | size_t nbElement(data.size()); | |
37 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
38 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
39 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
40 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(char), nbElement, ds) == nbElement; |
41 | } | ||
42 | |||
43 | ///Save the data char in the file | ||
44 | /** @param[out] ds : file to be written | ||
45 | * @param data : data to be saved in the file | ||
46 | * @return true on success, false otherwise | ||
47 | */ | ||
48 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, char>::data_stream(FILE* & ds, char & data){ | |
49 | 723 | return fwrite((const void*)&data, sizeof(char), 1lu, ds) == 1lu; | |
50 | } | ||
51 | |||
52 | ///Save the data char in the file | ||
53 | /** @param[out] ds : file to be written | ||
54 | * @param data : data to be saved in the file | ||
55 | * @param nbElement : number of element of this data | ||
56 | * @return true on success, false otherwise | ||
57 | */ | ||
58 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, char>::data_stream(FILE* & ds, char * data, size_t nbElement){ | |
59 | 98 | return fwrite((const void*)data, sizeof(char), nbElement, ds) == nbElement; | |
60 | } | ||
61 | |||
62 | ///Save the data std::vector of data in the file | ||
63 | /** @param[out] ds : file to be written | ||
64 | * @param data : data to be saved in the file | ||
65 | * @return true on success, false otherwise | ||
66 | */ | ||
67 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<char> >::data_stream(FILE* & ds, std::vector<char> & data){ | |
68 | 1 | size_t nbElement(data.size()); | |
69 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
70 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
71 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(char), nbElement, ds) == nbElement; |
72 | } | ||
73 | |||
74 | |||
75 | |||
76 | |||
77 | ///Read the char in the message | ||
78 | /** @param[out] ds : message to be read | ||
79 | * @param[out] data : data to be set | ||
80 | * @return true on success, false otherwise | ||
81 | */ | ||
82 | 81 | bool DataStream<DataStreamIter, DataStreamMode::READ, char>::data_stream(DataStreamIter & ds, char & data){ | |
83 | 81 | char* srcByte = (char*)&data; | |
84 | 81 | memcpy(srcByte, ds, sizeof(char)); | |
85 | 81 | ds += sizeof(char); | |
86 | 81 | return true; | |
87 | } | ||
88 | |||
89 | ///Read the char in the message | ||
90 | /** @param[out] ds : message to be read | ||
91 | * @param[out] data : data to be set | ||
92 | * @param nbElement : number of element of the data | ||
93 | * @return true on success, false otherwise | ||
94 | */ | ||
95 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, char>::data_stream(DataStreamIter & ds, char * data, size_t nbElement){ | |
96 | 98 | char* srcByte = (char*)data; | |
97 | 98 | memcpy(srcByte, ds, sizeof(char)*nbElement); | |
98 | 98 | ds += sizeof(char)*nbElement; | |
99 | 98 | return true; | |
100 | } | ||
101 | |||
102 | ///Save the char in the message | ||
103 | /** @param[out] ds : message to be written | ||
104 | * @param data : data to be saved in the message | ||
105 | * @return true on success, false otherwise | ||
106 | */ | ||
107 | 81 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, char>::data_stream(DataStreamIter & ds, char & data){ | |
108 | 81 | const char* srcByte = (const char*)&data; | |
109 | 81 | memcpy(ds, srcByte, sizeof(char)); | |
110 | 81 | ds += sizeof(char); | |
111 | 81 | return true; | |
112 | } | ||
113 | |||
114 | ///Save the char in the message | ||
115 | /** @param[out] ds : message to be written | ||
116 | * @param data : data to be saved in the message | ||
117 | * @param nbElement : number of element of the data | ||
118 | * @return true on success, false otherwise | ||
119 | */ | ||
120 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, char>::data_stream(DataStreamIter & ds, char * data, size_t nbElement){ | |
121 | 98 | const char* srcByte = (const char*)data; | |
122 | 98 | memcpy(ds, srcByte, sizeof(char)*nbElement); | |
123 | 98 | ds += sizeof(char)*nbElement; | |
124 | 98 | return true; | |
125 | } | ||
126 | |||
127 | |||
128 | |||
129 | ///Get the size of a type char | ||
130 | /** @param[out] ds : size of the type | ||
131 | * @param data : data to be used | ||
132 | * @return true on success, false otherwise | ||
133 | */ | ||
134 | 162 | bool DataStream<size_t, DataStreamMode::WRITE, char>::data_stream(size_t & ds, char & data){ | |
135 | 162 | ds += sizeof(char); | |
136 | 162 | return true; | |
137 | } | ||
138 | |||
139 | ///Get the size of a type char | ||
140 | /** @param[out] ds : size of the type | ||
141 | * @param data : data to be used | ||
142 | * @param nbElement : number of element of the data | ||
143 | * @return true on success, false otherwise | ||
144 | */ | ||
145 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, char>::data_stream(size_t & ds, char * data, size_t nbElement){ | |
146 | 138 | ds += sizeof(char)*nbElement; | |
147 | 138 | return true; | |
148 | } | ||
149 | |||
150 | |||
151 | |||
152 | |||
153 | |||
154 | ///Read the data short in the file | ||
155 | /** @param[out] ds : file to be read | ||
156 | * @param[out] data : data to be set | ||
157 | * @return true on success, false otherwise | ||
158 | */ | ||
159 | 723 | bool DataStream<FILE*, DataStreamMode::READ, short>::data_stream(FILE* & ds, short & data){ | |
160 | 723 | return fread((void*)&data, sizeof(short), 1lu, ds) == 1lu; | |
161 | } | ||
162 | |||
163 | ///Read the data short in the file | ||
164 | /** @param[out] ds : file to be read | ||
165 | * @param[out] data : data to be set | ||
166 | * @param nbElement : number of element of this data | ||
167 | * @return true on success, false otherwise | ||
168 | */ | ||
169 | 98 | bool DataStream<FILE*, DataStreamMode::READ, short>::data_stream(FILE* & ds, short * data, size_t nbElement){ | |
170 | 98 | return fread((void*)data, sizeof(short), nbElement, ds) == nbElement; | |
171 | } | ||
172 | |||
173 | ///Read the data std::vector of short in the file | ||
174 | /** @param[out] ds : file to be read | ||
175 | * @param[out] data : data to be set | ||
176 | * @return true on success, false otherwise | ||
177 | */ | ||
178 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<short> >::data_stream(FILE* & ds, std::vector<short> & data){ | |
179 | 1 | size_t nbElement(data.size()); | |
180 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
181 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
182 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
183 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(short), nbElement, ds) == nbElement; |
184 | } | ||
185 | |||
186 | ///Save the data short in the file | ||
187 | /** @param[out] ds : file to be written | ||
188 | * @param data : data to be saved in the file | ||
189 | * @return true on success, false otherwise | ||
190 | */ | ||
191 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, short>::data_stream(FILE* & ds, short & data){ | |
192 | 723 | return fwrite((const void*)&data, sizeof(short), 1lu, ds) == 1lu; | |
193 | } | ||
194 | |||
195 | ///Save the data short in the file | ||
196 | /** @param[out] ds : file to be written | ||
197 | * @param data : data to be saved in the file | ||
198 | * @param nbElement : number of element of this data | ||
199 | * @return true on success, false otherwise | ||
200 | */ | ||
201 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, short>::data_stream(FILE* & ds, short * data, size_t nbElement){ | |
202 | 98 | return fwrite((const void*)data, sizeof(short), nbElement, ds) == nbElement; | |
203 | } | ||
204 | |||
205 | ///Save the data std::vector of data in the file | ||
206 | /** @param[out] ds : file to be written | ||
207 | * @param data : data to be saved in the file | ||
208 | * @return true on success, false otherwise | ||
209 | */ | ||
210 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<short> >::data_stream(FILE* & ds, std::vector<short> & data){ | |
211 | 1 | size_t nbElement(data.size()); | |
212 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
213 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
214 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(short), nbElement, ds) == nbElement; |
215 | } | ||
216 | |||
217 | |||
218 | |||
219 | |||
220 | ///Read the short in the message | ||
221 | /** @param[out] ds : message to be read | ||
222 | * @param[out] data : data to be set | ||
223 | * @return true on success, false otherwise | ||
224 | */ | ||
225 | 82 | bool DataStream<DataStreamIter, DataStreamMode::READ, short>::data_stream(DataStreamIter & ds, short & data){ | |
226 | 82 | char* srcByte = (char*)&data; | |
227 | 82 | memcpy(srcByte, ds, sizeof(short)); | |
228 | 82 | ds += sizeof(short); | |
229 | 82 | return true; | |
230 | } | ||
231 | |||
232 | ///Read the short in the message | ||
233 | /** @param[out] ds : message to be read | ||
234 | * @param[out] data : data to be set | ||
235 | * @param nbElement : number of element of the data | ||
236 | * @return true on success, false otherwise | ||
237 | */ | ||
238 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, short>::data_stream(DataStreamIter & ds, short * data, size_t nbElement){ | |
239 | 98 | char* srcByte = (char*)data; | |
240 | 98 | memcpy(srcByte, ds, sizeof(short)*nbElement); | |
241 | 98 | ds += sizeof(short)*nbElement; | |
242 | 98 | return true; | |
243 | } | ||
244 | |||
245 | ///Save the short in the message | ||
246 | /** @param[out] ds : message to be written | ||
247 | * @param data : data to be saved in the message | ||
248 | * @return true on success, false otherwise | ||
249 | */ | ||
250 | 82 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, short>::data_stream(DataStreamIter & ds, short & data){ | |
251 | 82 | const char* srcByte = (const char*)&data; | |
252 | 82 | memcpy(ds, srcByte, sizeof(short)); | |
253 | 82 | ds += sizeof(short); | |
254 | 82 | return true; | |
255 | } | ||
256 | |||
257 | ///Save the short in the message | ||
258 | /** @param[out] ds : message to be written | ||
259 | * @param data : data to be saved in the message | ||
260 | * @param nbElement : number of element of the data | ||
261 | * @return true on success, false otherwise | ||
262 | */ | ||
263 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, short>::data_stream(DataStreamIter & ds, short * data, size_t nbElement){ | |
264 | 98 | const char* srcByte = (const char*)data; | |
265 | 98 | memcpy(ds, srcByte, sizeof(short)*nbElement); | |
266 | 98 | ds += sizeof(short)*nbElement; | |
267 | 98 | return true; | |
268 | } | ||
269 | |||
270 | |||
271 | |||
272 | ///Get the size of a type short | ||
273 | /** @param[out] ds : size of the type | ||
274 | * @param data : data to be used | ||
275 | * @return true on success, false otherwise | ||
276 | */ | ||
277 | 163 | bool DataStream<size_t, DataStreamMode::WRITE, short>::data_stream(size_t & ds, short & data){ | |
278 | 163 | ds += sizeof(short); | |
279 | 163 | return true; | |
280 | } | ||
281 | |||
282 | ///Get the size of a type short | ||
283 | /** @param[out] ds : size of the type | ||
284 | * @param data : data to be used | ||
285 | * @param nbElement : number of element of the data | ||
286 | * @return true on success, false otherwise | ||
287 | */ | ||
288 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, short>::data_stream(size_t & ds, short * data, size_t nbElement){ | |
289 | 138 | ds += sizeof(short)*nbElement; | |
290 | 138 | return true; | |
291 | } | ||
292 | |||
293 | |||
294 | |||
295 | |||
296 | |||
297 | ///Read the data int in the file | ||
298 | /** @param[out] ds : file to be read | ||
299 | * @param[out] data : data to be set | ||
300 | * @return true on success, false otherwise | ||
301 | */ | ||
302 | 726 | bool DataStream<FILE*, DataStreamMode::READ, int>::data_stream(FILE* & ds, int & data){ | |
303 | 726 | return fread((void*)&data, sizeof(int), 1lu, ds) == 1lu; | |
304 | } | ||
305 | |||
306 | ///Read the data int in the file | ||
307 | /** @param[out] ds : file to be read | ||
308 | * @param[out] data : data to be set | ||
309 | * @param nbElement : number of element of this data | ||
310 | * @return true on success, false otherwise | ||
311 | */ | ||
312 | 98 | bool DataStream<FILE*, DataStreamMode::READ, int>::data_stream(FILE* & ds, int * data, size_t nbElement){ | |
313 | 98 | return fread((void*)data, sizeof(int), nbElement, ds) == nbElement; | |
314 | } | ||
315 | |||
316 | ///Read the data std::vector of int in the file | ||
317 | /** @param[out] ds : file to be read | ||
318 | * @param[out] data : data to be set | ||
319 | * @return true on success, false otherwise | ||
320 | */ | ||
321 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<int> >::data_stream(FILE* & ds, std::vector<int> & data){ | |
322 | 1 | size_t nbElement(data.size()); | |
323 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
324 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
325 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
326 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(int), nbElement, ds) == nbElement; |
327 | } | ||
328 | |||
329 | ///Save the data int in the file | ||
330 | /** @param[out] ds : file to be written | ||
331 | * @param data : data to be saved in the file | ||
332 | * @return true on success, false otherwise | ||
333 | */ | ||
334 | 726 | bool DataStream<FILE*, DataStreamMode::WRITE, int>::data_stream(FILE* & ds, int & data){ | |
335 | 726 | return fwrite((const void*)&data, sizeof(int), 1lu, ds) == 1lu; | |
336 | } | ||
337 | |||
338 | ///Save the data int in the file | ||
339 | /** @param[out] ds : file to be written | ||
340 | * @param data : data to be saved in the file | ||
341 | * @param nbElement : number of element of this data | ||
342 | * @return true on success, false otherwise | ||
343 | */ | ||
344 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, int>::data_stream(FILE* & ds, int * data, size_t nbElement){ | |
345 | 98 | return fwrite((const void*)data, sizeof(int), nbElement, ds) == nbElement; | |
346 | } | ||
347 | |||
348 | ///Save the data std::vector of data in the file | ||
349 | /** @param[out] ds : file to be written | ||
350 | * @param data : data to be saved in the file | ||
351 | * @return true on success, false otherwise | ||
352 | */ | ||
353 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<int> >::data_stream(FILE* & ds, std::vector<int> & data){ | |
354 | 1 | size_t nbElement(data.size()); | |
355 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
356 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
357 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(int), nbElement, ds) == nbElement; |
358 | } | ||
359 | |||
360 | |||
361 | |||
362 | |||
363 | ///Read the int in the message | ||
364 | /** @param[out] ds : message to be read | ||
365 | * @param[out] data : data to be set | ||
366 | * @return true on success, false otherwise | ||
367 | */ | ||
368 | 176 | bool DataStream<DataStreamIter, DataStreamMode::READ, int>::data_stream(DataStreamIter & ds, int & data){ | |
369 | 176 | char* srcByte = (char*)&data; | |
370 | 176 | memcpy(srcByte, ds, sizeof(int)); | |
371 | 176 | ds += sizeof(int); | |
372 | 176 | return true; | |
373 | } | ||
374 | |||
375 | ///Read the int in the message | ||
376 | /** @param[out] ds : message to be read | ||
377 | * @param[out] data : data to be set | ||
378 | * @param nbElement : number of element of the data | ||
379 | * @return true on success, false otherwise | ||
380 | */ | ||
381 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, int>::data_stream(DataStreamIter & ds, int * data, size_t nbElement){ | |
382 | 98 | char* srcByte = (char*)data; | |
383 | 98 | memcpy(srcByte, ds, sizeof(int)*nbElement); | |
384 | 98 | ds += sizeof(int)*nbElement; | |
385 | 98 | return true; | |
386 | } | ||
387 | |||
388 | ///Save the int in the message | ||
389 | /** @param[out] ds : message to be written | ||
390 | * @param data : data to be saved in the message | ||
391 | * @return true on success, false otherwise | ||
392 | */ | ||
393 | 182 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, int>::data_stream(DataStreamIter & ds, int & data){ | |
394 | 182 | const char* srcByte = (const char*)&data; | |
395 | 182 | memcpy(ds, srcByte, sizeof(int)); | |
396 | 182 | ds += sizeof(int); | |
397 | 182 | return true; | |
398 | } | ||
399 | |||
400 | ///Save the int in the message | ||
401 | /** @param[out] ds : message to be written | ||
402 | * @param data : data to be saved in the message | ||
403 | * @param nbElement : number of element of the data | ||
404 | * @return true on success, false otherwise | ||
405 | */ | ||
406 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, int>::data_stream(DataStreamIter & ds, int * data, size_t nbElement){ | |
407 | 98 | const char* srcByte = (const char*)data; | |
408 | 98 | memcpy(ds, srcByte, sizeof(int)*nbElement); | |
409 | 98 | ds += sizeof(int)*nbElement; | |
410 | 98 | return true; | |
411 | } | ||
412 | |||
413 | |||
414 | |||
415 | ///Get the size of a type int | ||
416 | /** @param[out] ds : size of the type | ||
417 | * @param data : data to be used | ||
418 | * @return true on success, false otherwise | ||
419 | */ | ||
420 | 266 | bool DataStream<size_t, DataStreamMode::WRITE, int>::data_stream(size_t & ds, int & data){ | |
421 | 266 | ds += sizeof(int); | |
422 | 266 | return true; | |
423 | } | ||
424 | |||
425 | ///Get the size of a type int | ||
426 | /** @param[out] ds : size of the type | ||
427 | * @param data : data to be used | ||
428 | * @param nbElement : number of element of the data | ||
429 | * @return true on success, false otherwise | ||
430 | */ | ||
431 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, int>::data_stream(size_t & ds, int * data, size_t nbElement){ | |
432 | 138 | ds += sizeof(int)*nbElement; | |
433 | 138 | return true; | |
434 | } | ||
435 | |||
436 | |||
437 | |||
438 | |||
439 | |||
440 | ///Read the data long in the file | ||
441 | /** @param[out] ds : file to be read | ||
442 | * @param[out] data : data to be set | ||
443 | * @return true on success, false otherwise | ||
444 | */ | ||
445 | 724 | bool DataStream<FILE*, DataStreamMode::READ, long>::data_stream(FILE* & ds, long & data){ | |
446 | 724 | return fread((void*)&data, sizeof(long), 1lu, ds) == 1lu; | |
447 | } | ||
448 | |||
449 | ///Read the data long in the file | ||
450 | /** @param[out] ds : file to be read | ||
451 | * @param[out] data : data to be set | ||
452 | * @param nbElement : number of element of this data | ||
453 | * @return true on success, false otherwise | ||
454 | */ | ||
455 | 98 | bool DataStream<FILE*, DataStreamMode::READ, long>::data_stream(FILE* & ds, long * data, size_t nbElement){ | |
456 | 98 | return fread((void*)data, sizeof(long), nbElement, ds) == nbElement; | |
457 | } | ||
458 | |||
459 | ///Read the data std::vector of long in the file | ||
460 | /** @param[out] ds : file to be read | ||
461 | * @param[out] data : data to be set | ||
462 | * @return true on success, false otherwise | ||
463 | */ | ||
464 | 3 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<long> >::data_stream(FILE* & ds, std::vector<long> & data){ | |
465 | 3 | size_t nbElement(data.size()); | |
466 |
1/1✓ Branch 1 taken 3 times.
|
3 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
467 |
2/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
3 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
468 |
1/1✓ Branch 1 taken 3 times.
|
3 | data.resize(nbElement); |
469 |
1/1✓ Branch 2 taken 3 times.
|
3 | return fread((void*)data.data(), sizeof(long), nbElement, ds) == nbElement; |
470 | } | ||
471 | |||
472 | ///Save the data long in the file | ||
473 | /** @param[out] ds : file to be written | ||
474 | * @param data : data to be saved in the file | ||
475 | * @return true on success, false otherwise | ||
476 | */ | ||
477 | 724 | bool DataStream<FILE*, DataStreamMode::WRITE, long>::data_stream(FILE* & ds, long & data){ | |
478 | 724 | return fwrite((const void*)&data, sizeof(long), 1lu, ds) == 1lu; | |
479 | } | ||
480 | |||
481 | ///Save the data long in the file | ||
482 | /** @param[out] ds : file to be written | ||
483 | * @param data : data to be saved in the file | ||
484 | * @param nbElement : number of element of this data | ||
485 | * @return true on success, false otherwise | ||
486 | */ | ||
487 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, long>::data_stream(FILE* & ds, long * data, size_t nbElement){ | |
488 | 98 | return fwrite((const void*)data, sizeof(long), nbElement, ds) == nbElement; | |
489 | } | ||
490 | |||
491 | ///Save the data std::vector of data in the file | ||
492 | /** @param[out] ds : file to be written | ||
493 | * @param data : data to be saved in the file | ||
494 | * @return true on success, false otherwise | ||
495 | */ | ||
496 | 8 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<long> >::data_stream(FILE* & ds, std::vector<long> & data){ | |
497 | 8 | size_t nbElement(data.size()); | |
498 |
1/1✓ Branch 1 taken 8 times.
|
8 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
499 |
2/4✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
8 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
500 |
1/1✓ Branch 2 taken 8 times.
|
8 | return fwrite((const void*)data.data(), sizeof(long), nbElement, ds) == nbElement; |
501 | } | ||
502 | |||
503 | |||
504 | |||
505 | |||
506 | ///Read the long in the message | ||
507 | /** @param[out] ds : message to be read | ||
508 | * @param[out] data : data to be set | ||
509 | * @return true on success, false otherwise | ||
510 | */ | ||
511 | 88 | bool DataStream<DataStreamIter, DataStreamMode::READ, long>::data_stream(DataStreamIter & ds, long & data){ | |
512 | 88 | char* srcByte = (char*)&data; | |
513 | 88 | memcpy(srcByte, ds, sizeof(long)); | |
514 | 88 | ds += sizeof(long); | |
515 | 88 | return true; | |
516 | } | ||
517 | |||
518 | ///Read the long in the message | ||
519 | /** @param[out] ds : message to be read | ||
520 | * @param[out] data : data to be set | ||
521 | * @param nbElement : number of element of the data | ||
522 | * @return true on success, false otherwise | ||
523 | */ | ||
524 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, long>::data_stream(DataStreamIter & ds, long * data, size_t nbElement){ | |
525 | 98 | char* srcByte = (char*)data; | |
526 | 98 | memcpy(srcByte, ds, sizeof(long)*nbElement); | |
527 | 98 | ds += sizeof(long)*nbElement; | |
528 | 98 | return true; | |
529 | } | ||
530 | |||
531 | ///Save the long in the message | ||
532 | /** @param[out] ds : message to be written | ||
533 | * @param data : data to be saved in the message | ||
534 | * @return true on success, false otherwise | ||
535 | */ | ||
536 | 93 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, long>::data_stream(DataStreamIter & ds, long & data){ | |
537 | 93 | const char* srcByte = (const char*)&data; | |
538 | 93 | memcpy(ds, srcByte, sizeof(long)); | |
539 | 93 | ds += sizeof(long); | |
540 | 93 | return true; | |
541 | } | ||
542 | |||
543 | ///Save the long in the message | ||
544 | /** @param[out] ds : message to be written | ||
545 | * @param data : data to be saved in the message | ||
546 | * @param nbElement : number of element of the data | ||
547 | * @return true on success, false otherwise | ||
548 | */ | ||
549 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, long>::data_stream(DataStreamIter & ds, long * data, size_t nbElement){ | |
550 | 98 | const char* srcByte = (const char*)data; | |
551 | 98 | memcpy(ds, srcByte, sizeof(long)*nbElement); | |
552 | 98 | ds += sizeof(long)*nbElement; | |
553 | 98 | return true; | |
554 | } | ||
555 | |||
556 | |||
557 | |||
558 | ///Get the size of a type long | ||
559 | /** @param[out] ds : size of the type | ||
560 | * @param data : data to be used | ||
561 | * @return true on success, false otherwise | ||
562 | */ | ||
563 | 254 | bool DataStream<size_t, DataStreamMode::WRITE, long>::data_stream(size_t & ds, long & data){ | |
564 | 254 | ds += sizeof(long); | |
565 | 254 | return true; | |
566 | } | ||
567 | |||
568 | ///Get the size of a type long | ||
569 | /** @param[out] ds : size of the type | ||
570 | * @param data : data to be used | ||
571 | * @param nbElement : number of element of the data | ||
572 | * @return true on success, false otherwise | ||
573 | */ | ||
574 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, long>::data_stream(size_t & ds, long * data, size_t nbElement){ | |
575 | 138 | ds += sizeof(long)*nbElement; | |
576 | 138 | return true; | |
577 | } | ||
578 | |||
579 | |||
580 | |||
581 | |||
582 | |||
583 | ///Read the data int8_t in the file | ||
584 | /** @param[out] ds : file to be read | ||
585 | * @param[out] data : data to be set | ||
586 | * @return true on success, false otherwise | ||
587 | */ | ||
588 | 723 | bool DataStream<FILE*, DataStreamMode::READ, int8_t>::data_stream(FILE* & ds, int8_t & data){ | |
589 | 723 | return fread((void*)&data, sizeof(int8_t), 1lu, ds) == 1lu; | |
590 | } | ||
591 | |||
592 | ///Read the data int8_t in the file | ||
593 | /** @param[out] ds : file to be read | ||
594 | * @param[out] data : data to be set | ||
595 | * @param nbElement : number of element of this data | ||
596 | * @return true on success, false otherwise | ||
597 | */ | ||
598 | 98 | bool DataStream<FILE*, DataStreamMode::READ, int8_t>::data_stream(FILE* & ds, int8_t * data, size_t nbElement){ | |
599 | 98 | return fread((void*)data, sizeof(int8_t), nbElement, ds) == nbElement; | |
600 | } | ||
601 | |||
602 | ///Read the data std::vector of int8_t in the file | ||
603 | /** @param[out] ds : file to be read | ||
604 | * @param[out] data : data to be set | ||
605 | * @return true on success, false otherwise | ||
606 | */ | ||
607 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<int8_t> >::data_stream(FILE* & ds, std::vector<int8_t> & data){ | |
608 | 1 | size_t nbElement(data.size()); | |
609 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
610 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
611 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
612 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(int8_t), nbElement, ds) == nbElement; |
613 | } | ||
614 | |||
615 | ///Save the data int8_t in the file | ||
616 | /** @param[out] ds : file to be written | ||
617 | * @param data : data to be saved in the file | ||
618 | * @return true on success, false otherwise | ||
619 | */ | ||
620 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, int8_t>::data_stream(FILE* & ds, int8_t & data){ | |
621 | 723 | return fwrite((const void*)&data, sizeof(int8_t), 1lu, ds) == 1lu; | |
622 | } | ||
623 | |||
624 | ///Save the data int8_t in the file | ||
625 | /** @param[out] ds : file to be written | ||
626 | * @param data : data to be saved in the file | ||
627 | * @param nbElement : number of element of this data | ||
628 | * @return true on success, false otherwise | ||
629 | */ | ||
630 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, int8_t>::data_stream(FILE* & ds, int8_t * data, size_t nbElement){ | |
631 | 98 | return fwrite((const void*)data, sizeof(int8_t), nbElement, ds) == nbElement; | |
632 | } | ||
633 | |||
634 | ///Save the data std::vector of data in the file | ||
635 | /** @param[out] ds : file to be written | ||
636 | * @param data : data to be saved in the file | ||
637 | * @return true on success, false otherwise | ||
638 | */ | ||
639 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<int8_t> >::data_stream(FILE* & ds, std::vector<int8_t> & data){ | |
640 | 1 | size_t nbElement(data.size()); | |
641 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
642 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
643 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(int8_t), nbElement, ds) == nbElement; |
644 | } | ||
645 | |||
646 | |||
647 | |||
648 | |||
649 | ///Read the int8_t in the message | ||
650 | /** @param[out] ds : message to be read | ||
651 | * @param[out] data : data to be set | ||
652 | * @return true on success, false otherwise | ||
653 | */ | ||
654 | 81 | bool DataStream<DataStreamIter, DataStreamMode::READ, int8_t>::data_stream(DataStreamIter & ds, int8_t & data){ | |
655 | 81 | char* srcByte = (char*)&data; | |
656 | 81 | memcpy(srcByte, ds, sizeof(int8_t)); | |
657 | 81 | ds += sizeof(int8_t); | |
658 | 81 | return true; | |
659 | } | ||
660 | |||
661 | ///Read the int8_t in the message | ||
662 | /** @param[out] ds : message to be read | ||
663 | * @param[out] data : data to be set | ||
664 | * @param nbElement : number of element of the data | ||
665 | * @return true on success, false otherwise | ||
666 | */ | ||
667 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, int8_t>::data_stream(DataStreamIter & ds, int8_t * data, size_t nbElement){ | |
668 | 98 | char* srcByte = (char*)data; | |
669 | 98 | memcpy(srcByte, ds, sizeof(int8_t)*nbElement); | |
670 | 98 | ds += sizeof(int8_t)*nbElement; | |
671 | 98 | return true; | |
672 | } | ||
673 | |||
674 | ///Save the int8_t in the message | ||
675 | /** @param[out] ds : message to be written | ||
676 | * @param data : data to be saved in the message | ||
677 | * @return true on success, false otherwise | ||
678 | */ | ||
679 | 81 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, int8_t>::data_stream(DataStreamIter & ds, int8_t & data){ | |
680 | 81 | const char* srcByte = (const char*)&data; | |
681 | 81 | memcpy(ds, srcByte, sizeof(int8_t)); | |
682 | 81 | ds += sizeof(int8_t); | |
683 | 81 | return true; | |
684 | } | ||
685 | |||
686 | ///Save the int8_t in the message | ||
687 | /** @param[out] ds : message to be written | ||
688 | * @param data : data to be saved in the message | ||
689 | * @param nbElement : number of element of the data | ||
690 | * @return true on success, false otherwise | ||
691 | */ | ||
692 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, int8_t>::data_stream(DataStreamIter & ds, int8_t * data, size_t nbElement){ | |
693 | 98 | const char* srcByte = (const char*)data; | |
694 | 98 | memcpy(ds, srcByte, sizeof(int8_t)*nbElement); | |
695 | 98 | ds += sizeof(int8_t)*nbElement; | |
696 | 98 | return true; | |
697 | } | ||
698 | |||
699 | |||
700 | |||
701 | ///Get the size of a type int8_t | ||
702 | /** @param[out] ds : size of the type | ||
703 | * @param data : data to be used | ||
704 | * @return true on success, false otherwise | ||
705 | */ | ||
706 | 162 | bool DataStream<size_t, DataStreamMode::WRITE, int8_t>::data_stream(size_t & ds, int8_t & data){ | |
707 | 162 | ds += sizeof(int8_t); | |
708 | 162 | return true; | |
709 | } | ||
710 | |||
711 | ///Get the size of a type int8_t | ||
712 | /** @param[out] ds : size of the type | ||
713 | * @param data : data to be used | ||
714 | * @param nbElement : number of element of the data | ||
715 | * @return true on success, false otherwise | ||
716 | */ | ||
717 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, int8_t>::data_stream(size_t & ds, int8_t * data, size_t nbElement){ | |
718 | 138 | ds += sizeof(int8_t)*nbElement; | |
719 | 138 | return true; | |
720 | } | ||
721 | |||
722 | |||
723 | |||
724 | |||
725 | |||
726 | ///Read the data unsigned char in the file | ||
727 | /** @param[out] ds : file to be read | ||
728 | * @param[out] data : data to be set | ||
729 | * @return true on success, false otherwise | ||
730 | */ | ||
731 | 723 | bool DataStream<FILE*, DataStreamMode::READ, unsigned char>::data_stream(FILE* & ds, unsigned char & data){ | |
732 | 723 | return fread((void*)&data, sizeof(unsigned char), 1lu, ds) == 1lu; | |
733 | } | ||
734 | |||
735 | ///Read the data unsigned char in the file | ||
736 | /** @param[out] ds : file to be read | ||
737 | * @param[out] data : data to be set | ||
738 | * @param nbElement : number of element of this data | ||
739 | * @return true on success, false otherwise | ||
740 | */ | ||
741 | 98 | bool DataStream<FILE*, DataStreamMode::READ, unsigned char>::data_stream(FILE* & ds, unsigned char * data, size_t nbElement){ | |
742 | 98 | return fread((void*)data, sizeof(unsigned char), nbElement, ds) == nbElement; | |
743 | } | ||
744 | |||
745 | ///Read the data std::vector of unsigned char in the file | ||
746 | /** @param[out] ds : file to be read | ||
747 | * @param[out] data : data to be set | ||
748 | * @return true on success, false otherwise | ||
749 | */ | ||
750 | 40 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<unsigned char> >::data_stream(FILE* & ds, std::vector<unsigned char> & data){ | |
751 | 40 | size_t nbElement(data.size()); | |
752 |
1/1✓ Branch 1 taken 40 times.
|
40 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
753 |
3/4✓ Branch 0 taken 36 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
|
40 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
754 |
1/1✓ Branch 1 taken 36 times.
|
36 | data.resize(nbElement); |
755 |
1/1✓ Branch 2 taken 36 times.
|
36 | return fread((void*)data.data(), sizeof(unsigned char), nbElement, ds) == nbElement; |
756 | } | ||
757 | |||
758 | ///Save the data unsigned char in the file | ||
759 | /** @param[out] ds : file to be written | ||
760 | * @param data : data to be saved in the file | ||
761 | * @return true on success, false otherwise | ||
762 | */ | ||
763 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned char>::data_stream(FILE* & ds, unsigned char & data){ | |
764 | 723 | return fwrite((const void*)&data, sizeof(unsigned char), 1lu, ds) == 1lu; | |
765 | } | ||
766 | |||
767 | ///Save the data unsigned char in the file | ||
768 | /** @param[out] ds : file to be written | ||
769 | * @param data : data to be saved in the file | ||
770 | * @param nbElement : number of element of this data | ||
771 | * @return true on success, false otherwise | ||
772 | */ | ||
773 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned char>::data_stream(FILE* & ds, unsigned char * data, size_t nbElement){ | |
774 | 98 | return fwrite((const void*)data, sizeof(unsigned char), nbElement, ds) == nbElement; | |
775 | } | ||
776 | |||
777 | ///Save the data std::vector of data in the file | ||
778 | /** @param[out] ds : file to be written | ||
779 | * @param data : data to be saved in the file | ||
780 | * @return true on success, false otherwise | ||
781 | */ | ||
782 | 32 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<unsigned char> >::data_stream(FILE* & ds, std::vector<unsigned char> & data){ | |
783 | 32 | size_t nbElement(data.size()); | |
784 |
1/1✓ Branch 1 taken 32 times.
|
32 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
785 |
3/4✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
|
32 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
786 |
1/1✓ Branch 2 taken 30 times.
|
30 | return fwrite((const void*)data.data(), sizeof(unsigned char), nbElement, ds) == nbElement; |
787 | } | ||
788 | |||
789 | |||
790 | |||
791 | |||
792 | ///Read the unsigned char in the message | ||
793 | /** @param[out] ds : message to be read | ||
794 | * @param[out] data : data to be set | ||
795 | * @return true on success, false otherwise | ||
796 | */ | ||
797 | 81 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned char>::data_stream(DataStreamIter & ds, unsigned char & data){ | |
798 | 81 | char* srcByte = (char*)&data; | |
799 | 81 | memcpy(srcByte, ds, sizeof(unsigned char)); | |
800 | 81 | ds += sizeof(unsigned char); | |
801 | 81 | return true; | |
802 | } | ||
803 | |||
804 | ///Read the unsigned char in the message | ||
805 | /** @param[out] ds : message to be read | ||
806 | * @param[out] data : data to be set | ||
807 | * @param nbElement : number of element of the data | ||
808 | * @return true on success, false otherwise | ||
809 | */ | ||
810 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned char>::data_stream(DataStreamIter & ds, unsigned char * data, size_t nbElement){ | |
811 | 98 | char* srcByte = (char*)data; | |
812 | 98 | memcpy(srcByte, ds, sizeof(unsigned char)*nbElement); | |
813 | 98 | ds += sizeof(unsigned char)*nbElement; | |
814 | 98 | return true; | |
815 | } | ||
816 | |||
817 | ///Save the unsigned char in the message | ||
818 | /** @param[out] ds : message to be written | ||
819 | * @param data : data to be saved in the message | ||
820 | * @return true on success, false otherwise | ||
821 | */ | ||
822 | 85 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned char>::data_stream(DataStreamIter & ds, unsigned char & data){ | |
823 | 85 | const char* srcByte = (const char*)&data; | |
824 | 85 | memcpy(ds, srcByte, sizeof(unsigned char)); | |
825 | 85 | ds += sizeof(unsigned char); | |
826 | 85 | return true; | |
827 | } | ||
828 | |||
829 | ///Save the unsigned char in the message | ||
830 | /** @param[out] ds : message to be written | ||
831 | * @param data : data to be saved in the message | ||
832 | * @param nbElement : number of element of the data | ||
833 | * @return true on success, false otherwise | ||
834 | */ | ||
835 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned char>::data_stream(DataStreamIter & ds, unsigned char * data, size_t nbElement){ | |
836 | 98 | const char* srcByte = (const char*)data; | |
837 | 98 | memcpy(ds, srcByte, sizeof(unsigned char)*nbElement); | |
838 | 98 | ds += sizeof(unsigned char)*nbElement; | |
839 | 98 | return true; | |
840 | } | ||
841 | |||
842 | |||
843 | |||
844 | ///Get the size of a type unsigned char | ||
845 | /** @param[out] ds : size of the type | ||
846 | * @param data : data to be used | ||
847 | * @return true on success, false otherwise | ||
848 | */ | ||
849 | 166 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned char>::data_stream(size_t & ds, unsigned char & data){ | |
850 | 166 | ds += sizeof(unsigned char); | |
851 | 166 | return true; | |
852 | } | ||
853 | |||
854 | ///Get the size of a type unsigned char | ||
855 | /** @param[out] ds : size of the type | ||
856 | * @param data : data to be used | ||
857 | * @param nbElement : number of element of the data | ||
858 | * @return true on success, false otherwise | ||
859 | */ | ||
860 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned char>::data_stream(size_t & ds, unsigned char * data, size_t nbElement){ | |
861 | 138 | ds += sizeof(unsigned char)*nbElement; | |
862 | 138 | return true; | |
863 | } | ||
864 | |||
865 | |||
866 | |||
867 | |||
868 | |||
869 | ///Read the data unsigned short in the file | ||
870 | /** @param[out] ds : file to be read | ||
871 | * @param[out] data : data to be set | ||
872 | * @return true on success, false otherwise | ||
873 | */ | ||
874 | 723 | bool DataStream<FILE*, DataStreamMode::READ, unsigned short>::data_stream(FILE* & ds, unsigned short & data){ | |
875 | 723 | return fread((void*)&data, sizeof(unsigned short), 1lu, ds) == 1lu; | |
876 | } | ||
877 | |||
878 | ///Read the data unsigned short in the file | ||
879 | /** @param[out] ds : file to be read | ||
880 | * @param[out] data : data to be set | ||
881 | * @param nbElement : number of element of this data | ||
882 | * @return true on success, false otherwise | ||
883 | */ | ||
884 | 98 | bool DataStream<FILE*, DataStreamMode::READ, unsigned short>::data_stream(FILE* & ds, unsigned short * data, size_t nbElement){ | |
885 | 98 | return fread((void*)data, sizeof(unsigned short), nbElement, ds) == nbElement; | |
886 | } | ||
887 | |||
888 | ///Read the data std::vector of unsigned short in the file | ||
889 | /** @param[out] ds : file to be read | ||
890 | * @param[out] data : data to be set | ||
891 | * @return true on success, false otherwise | ||
892 | */ | ||
893 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<unsigned short> >::data_stream(FILE* & ds, std::vector<unsigned short> & data){ | |
894 | 1 | size_t nbElement(data.size()); | |
895 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
896 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
897 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
898 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(unsigned short), nbElement, ds) == nbElement; |
899 | } | ||
900 | |||
901 | ///Save the data unsigned short in the file | ||
902 | /** @param[out] ds : file to be written | ||
903 | * @param data : data to be saved in the file | ||
904 | * @return true on success, false otherwise | ||
905 | */ | ||
906 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned short>::data_stream(FILE* & ds, unsigned short & data){ | |
907 | 723 | return fwrite((const void*)&data, sizeof(unsigned short), 1lu, ds) == 1lu; | |
908 | } | ||
909 | |||
910 | ///Save the data unsigned short in the file | ||
911 | /** @param[out] ds : file to be written | ||
912 | * @param data : data to be saved in the file | ||
913 | * @param nbElement : number of element of this data | ||
914 | * @return true on success, false otherwise | ||
915 | */ | ||
916 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned short>::data_stream(FILE* & ds, unsigned short * data, size_t nbElement){ | |
917 | 98 | return fwrite((const void*)data, sizeof(unsigned short), nbElement, ds) == nbElement; | |
918 | } | ||
919 | |||
920 | ///Save the data std::vector of data in the file | ||
921 | /** @param[out] ds : file to be written | ||
922 | * @param data : data to be saved in the file | ||
923 | * @return true on success, false otherwise | ||
924 | */ | ||
925 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<unsigned short> >::data_stream(FILE* & ds, std::vector<unsigned short> & data){ | |
926 | 1 | size_t nbElement(data.size()); | |
927 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
928 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
929 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(unsigned short), nbElement, ds) == nbElement; |
930 | } | ||
931 | |||
932 | |||
933 | |||
934 | |||
935 | ///Read the unsigned short in the message | ||
936 | /** @param[out] ds : message to be read | ||
937 | * @param[out] data : data to be set | ||
938 | * @return true on success, false otherwise | ||
939 | */ | ||
940 | 81 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned short>::data_stream(DataStreamIter & ds, unsigned short & data){ | |
941 | 81 | char* srcByte = (char*)&data; | |
942 | 81 | memcpy(srcByte, ds, sizeof(unsigned short)); | |
943 | 81 | ds += sizeof(unsigned short); | |
944 | 81 | return true; | |
945 | } | ||
946 | |||
947 | ///Read the unsigned short in the message | ||
948 | /** @param[out] ds : message to be read | ||
949 | * @param[out] data : data to be set | ||
950 | * @param nbElement : number of element of the data | ||
951 | * @return true on success, false otherwise | ||
952 | */ | ||
953 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned short>::data_stream(DataStreamIter & ds, unsigned short * data, size_t nbElement){ | |
954 | 98 | char* srcByte = (char*)data; | |
955 | 98 | memcpy(srcByte, ds, sizeof(unsigned short)*nbElement); | |
956 | 98 | ds += sizeof(unsigned short)*nbElement; | |
957 | 98 | return true; | |
958 | } | ||
959 | |||
960 | ///Save the unsigned short in the message | ||
961 | /** @param[out] ds : message to be written | ||
962 | * @param data : data to be saved in the message | ||
963 | * @return true on success, false otherwise | ||
964 | */ | ||
965 | 81 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned short>::data_stream(DataStreamIter & ds, unsigned short & data){ | |
966 | 81 | const char* srcByte = (const char*)&data; | |
967 | 81 | memcpy(ds, srcByte, sizeof(unsigned short)); | |
968 | 81 | ds += sizeof(unsigned short); | |
969 | 81 | return true; | |
970 | } | ||
971 | |||
972 | ///Save the unsigned short in the message | ||
973 | /** @param[out] ds : message to be written | ||
974 | * @param data : data to be saved in the message | ||
975 | * @param nbElement : number of element of the data | ||
976 | * @return true on success, false otherwise | ||
977 | */ | ||
978 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned short>::data_stream(DataStreamIter & ds, unsigned short * data, size_t nbElement){ | |
979 | 98 | const char* srcByte = (const char*)data; | |
980 | 98 | memcpy(ds, srcByte, sizeof(unsigned short)*nbElement); | |
981 | 98 | ds += sizeof(unsigned short)*nbElement; | |
982 | 98 | return true; | |
983 | } | ||
984 | |||
985 | |||
986 | |||
987 | ///Get the size of a type unsigned short | ||
988 | /** @param[out] ds : size of the type | ||
989 | * @param data : data to be used | ||
990 | * @return true on success, false otherwise | ||
991 | */ | ||
992 | 162 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned short>::data_stream(size_t & ds, unsigned short & data){ | |
993 | 162 | ds += sizeof(unsigned short); | |
994 | 162 | return true; | |
995 | } | ||
996 | |||
997 | ///Get the size of a type unsigned short | ||
998 | /** @param[out] ds : size of the type | ||
999 | * @param data : data to be used | ||
1000 | * @param nbElement : number of element of the data | ||
1001 | * @return true on success, false otherwise | ||
1002 | */ | ||
1003 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned short>::data_stream(size_t & ds, unsigned short * data, size_t nbElement){ | |
1004 | 138 | ds += sizeof(unsigned short)*nbElement; | |
1005 | 138 | return true; | |
1006 | } | ||
1007 | |||
1008 | |||
1009 | |||
1010 | |||
1011 | |||
1012 | ///Read the data unsigned int in the file | ||
1013 | /** @param[out] ds : file to be read | ||
1014 | * @param[out] data : data to be set | ||
1015 | * @return true on success, false otherwise | ||
1016 | */ | ||
1017 | 723 | bool DataStream<FILE*, DataStreamMode::READ, unsigned int>::data_stream(FILE* & ds, unsigned int & data){ | |
1018 | 723 | return fread((void*)&data, sizeof(unsigned int), 1lu, ds) == 1lu; | |
1019 | } | ||
1020 | |||
1021 | ///Read the data unsigned int in the file | ||
1022 | /** @param[out] ds : file to be read | ||
1023 | * @param[out] data : data to be set | ||
1024 | * @param nbElement : number of element of this data | ||
1025 | * @return true on success, false otherwise | ||
1026 | */ | ||
1027 | 98 | bool DataStream<FILE*, DataStreamMode::READ, unsigned int>::data_stream(FILE* & ds, unsigned int * data, size_t nbElement){ | |
1028 | 98 | return fread((void*)data, sizeof(unsigned int), nbElement, ds) == nbElement; | |
1029 | } | ||
1030 | |||
1031 | ///Read the data std::vector of unsigned int in the file | ||
1032 | /** @param[out] ds : file to be read | ||
1033 | * @param[out] data : data to be set | ||
1034 | * @return true on success, false otherwise | ||
1035 | */ | ||
1036 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<unsigned int> >::data_stream(FILE* & ds, std::vector<unsigned int> & data){ | |
1037 | 1 | size_t nbElement(data.size()); | |
1038 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
1039 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1040 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
1041 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(unsigned int), nbElement, ds) == nbElement; |
1042 | } | ||
1043 | |||
1044 | ///Save the data unsigned int in the file | ||
1045 | /** @param[out] ds : file to be written | ||
1046 | * @param data : data to be saved in the file | ||
1047 | * @return true on success, false otherwise | ||
1048 | */ | ||
1049 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned int>::data_stream(FILE* & ds, unsigned int & data){ | |
1050 | 723 | return fwrite((const void*)&data, sizeof(unsigned int), 1lu, ds) == 1lu; | |
1051 | } | ||
1052 | |||
1053 | ///Save the data unsigned int in the file | ||
1054 | /** @param[out] ds : file to be written | ||
1055 | * @param data : data to be saved in the file | ||
1056 | * @param nbElement : number of element of this data | ||
1057 | * @return true on success, false otherwise | ||
1058 | */ | ||
1059 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned int>::data_stream(FILE* & ds, unsigned int * data, size_t nbElement){ | |
1060 | 98 | return fwrite((const void*)data, sizeof(unsigned int), nbElement, ds) == nbElement; | |
1061 | } | ||
1062 | |||
1063 | ///Save the data std::vector of data in the file | ||
1064 | /** @param[out] ds : file to be written | ||
1065 | * @param data : data to be saved in the file | ||
1066 | * @return true on success, false otherwise | ||
1067 | */ | ||
1068 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<unsigned int> >::data_stream(FILE* & ds, std::vector<unsigned int> & data){ | |
1069 | 1 | size_t nbElement(data.size()); | |
1070 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
1071 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1072 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(unsigned int), nbElement, ds) == nbElement; |
1073 | } | ||
1074 | |||
1075 | |||
1076 | |||
1077 | |||
1078 | ///Read the unsigned int in the message | ||
1079 | /** @param[out] ds : message to be read | ||
1080 | * @param[out] data : data to be set | ||
1081 | * @return true on success, false otherwise | ||
1082 | */ | ||
1083 | 161 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned int>::data_stream(DataStreamIter & ds, unsigned int & data){ | |
1084 | 161 | char* srcByte = (char*)&data; | |
1085 | 161 | memcpy(srcByte, ds, sizeof(unsigned int)); | |
1086 | 161 | ds += sizeof(unsigned int); | |
1087 | 161 | return true; | |
1088 | } | ||
1089 | |||
1090 | ///Read the unsigned int in the message | ||
1091 | /** @param[out] ds : message to be read | ||
1092 | * @param[out] data : data to be set | ||
1093 | * @param nbElement : number of element of the data | ||
1094 | * @return true on success, false otherwise | ||
1095 | */ | ||
1096 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned int>::data_stream(DataStreamIter & ds, unsigned int * data, size_t nbElement){ | |
1097 | 98 | char* srcByte = (char*)data; | |
1098 | 98 | memcpy(srcByte, ds, sizeof(unsigned int)*nbElement); | |
1099 | 98 | ds += sizeof(unsigned int)*nbElement; | |
1100 | 98 | return true; | |
1101 | } | ||
1102 | |||
1103 | ///Save the unsigned int in the message | ||
1104 | /** @param[out] ds : message to be written | ||
1105 | * @param data : data to be saved in the message | ||
1106 | * @return true on success, false otherwise | ||
1107 | */ | ||
1108 | 161 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned int>::data_stream(DataStreamIter & ds, unsigned int & data){ | |
1109 | 161 | const char* srcByte = (const char*)&data; | |
1110 | 161 | memcpy(ds, srcByte, sizeof(unsigned int)); | |
1111 | 161 | ds += sizeof(unsigned int); | |
1112 | 161 | return true; | |
1113 | } | ||
1114 | |||
1115 | ///Save the unsigned int in the message | ||
1116 | /** @param[out] ds : message to be written | ||
1117 | * @param data : data to be saved in the message | ||
1118 | * @param nbElement : number of element of the data | ||
1119 | * @return true on success, false otherwise | ||
1120 | */ | ||
1121 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned int>::data_stream(DataStreamIter & ds, unsigned int * data, size_t nbElement){ | |
1122 | 98 | const char* srcByte = (const char*)data; | |
1123 | 98 | memcpy(ds, srcByte, sizeof(unsigned int)*nbElement); | |
1124 | 98 | ds += sizeof(unsigned int)*nbElement; | |
1125 | 98 | return true; | |
1126 | } | ||
1127 | |||
1128 | |||
1129 | |||
1130 | ///Get the size of a type unsigned int | ||
1131 | /** @param[out] ds : size of the type | ||
1132 | * @param data : data to be used | ||
1133 | * @return true on success, false otherwise | ||
1134 | */ | ||
1135 | 242 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned int>::data_stream(size_t & ds, unsigned int & data){ | |
1136 | 242 | ds += sizeof(unsigned int); | |
1137 | 242 | return true; | |
1138 | } | ||
1139 | |||
1140 | ///Get the size of a type unsigned int | ||
1141 | /** @param[out] ds : size of the type | ||
1142 | * @param data : data to be used | ||
1143 | * @param nbElement : number of element of the data | ||
1144 | * @return true on success, false otherwise | ||
1145 | */ | ||
1146 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned int>::data_stream(size_t & ds, unsigned int * data, size_t nbElement){ | |
1147 | 138 | ds += sizeof(unsigned int)*nbElement; | |
1148 | 138 | return true; | |
1149 | } | ||
1150 | |||
1151 | |||
1152 | |||
1153 | |||
1154 | |||
1155 | ///Read the data unsigned long in the file | ||
1156 | /** @param[out] ds : file to be read | ||
1157 | * @param[out] data : data to be set | ||
1158 | * @return true on success, false otherwise | ||
1159 | */ | ||
1160 | 1234 | bool DataStream<FILE*, DataStreamMode::READ, unsigned long>::data_stream(FILE* & ds, unsigned long & data){ | |
1161 | 1234 | return fread((void*)&data, sizeof(unsigned long), 1lu, ds) == 1lu; | |
1162 | } | ||
1163 | |||
1164 | ///Read the data unsigned long in the file | ||
1165 | /** @param[out] ds : file to be read | ||
1166 | * @param[out] data : data to be set | ||
1167 | * @param nbElement : number of element of this data | ||
1168 | * @return true on success, false otherwise | ||
1169 | */ | ||
1170 | 98 | bool DataStream<FILE*, DataStreamMode::READ, unsigned long>::data_stream(FILE* & ds, unsigned long * data, size_t nbElement){ | |
1171 | 98 | return fread((void*)data, sizeof(unsigned long), nbElement, ds) == nbElement; | |
1172 | } | ||
1173 | |||
1174 | ///Read the data std::vector of unsigned long in the file | ||
1175 | /** @param[out] ds : file to be read | ||
1176 | * @param[out] data : data to be set | ||
1177 | * @return true on success, false otherwise | ||
1178 | */ | ||
1179 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<unsigned long> >::data_stream(FILE* & ds, std::vector<unsigned long> & data){ | |
1180 | 1 | size_t nbElement(data.size()); | |
1181 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
1182 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1183 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
1184 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(unsigned long), nbElement, ds) == nbElement; |
1185 | } | ||
1186 | |||
1187 | ///Save the data unsigned long in the file | ||
1188 | /** @param[out] ds : file to be written | ||
1189 | * @param data : data to be saved in the file | ||
1190 | * @return true on success, false otherwise | ||
1191 | */ | ||
1192 | 1227 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned long>::data_stream(FILE* & ds, unsigned long & data){ | |
1193 | 1227 | return fwrite((const void*)&data, sizeof(unsigned long), 1lu, ds) == 1lu; | |
1194 | } | ||
1195 | |||
1196 | ///Save the data unsigned long in the file | ||
1197 | /** @param[out] ds : file to be written | ||
1198 | * @param data : data to be saved in the file | ||
1199 | * @param nbElement : number of element of this data | ||
1200 | * @return true on success, false otherwise | ||
1201 | */ | ||
1202 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, unsigned long>::data_stream(FILE* & ds, unsigned long * data, size_t nbElement){ | |
1203 | 98 | return fwrite((const void*)data, sizeof(unsigned long), nbElement, ds) == nbElement; | |
1204 | } | ||
1205 | |||
1206 | ///Save the data std::vector of data in the file | ||
1207 | /** @param[out] ds : file to be written | ||
1208 | * @param data : data to be saved in the file | ||
1209 | * @return true on success, false otherwise | ||
1210 | */ | ||
1211 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<unsigned long> >::data_stream(FILE* & ds, std::vector<unsigned long> & data){ | |
1212 | 1 | size_t nbElement(data.size()); | |
1213 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
1214 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1215 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(unsigned long), nbElement, ds) == nbElement; |
1216 | } | ||
1217 | |||
1218 | |||
1219 | |||
1220 | |||
1221 | ///Read the unsigned long in the message | ||
1222 | /** @param[out] ds : message to be read | ||
1223 | * @param[out] data : data to be set | ||
1224 | * @return true on success, false otherwise | ||
1225 | */ | ||
1226 | 202 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned long>::data_stream(DataStreamIter & ds, unsigned long & data){ | |
1227 | 202 | char* srcByte = (char*)&data; | |
1228 | 202 | memcpy(srcByte, ds, sizeof(unsigned long)); | |
1229 | 202 | ds += sizeof(unsigned long); | |
1230 | 202 | return true; | |
1231 | } | ||
1232 | |||
1233 | ///Read the unsigned long in the message | ||
1234 | /** @param[out] ds : message to be read | ||
1235 | * @param[out] data : data to be set | ||
1236 | * @param nbElement : number of element of the data | ||
1237 | * @return true on success, false otherwise | ||
1238 | */ | ||
1239 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, unsigned long>::data_stream(DataStreamIter & ds, unsigned long * data, size_t nbElement){ | |
1240 | 98 | char* srcByte = (char*)data; | |
1241 | 98 | memcpy(srcByte, ds, sizeof(unsigned long)*nbElement); | |
1242 | 98 | ds += sizeof(unsigned long)*nbElement; | |
1243 | 98 | return true; | |
1244 | } | ||
1245 | |||
1246 | ///Save the unsigned long in the message | ||
1247 | /** @param[out] ds : message to be written | ||
1248 | * @param data : data to be saved in the message | ||
1249 | * @return true on success, false otherwise | ||
1250 | */ | ||
1251 | 252 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned long>::data_stream(DataStreamIter & ds, unsigned long & data){ | |
1252 | 252 | const char* srcByte = (const char*)&data; | |
1253 | 252 | memcpy(ds, srcByte, sizeof(unsigned long)); | |
1254 | 252 | ds += sizeof(unsigned long); | |
1255 | 252 | return true; | |
1256 | } | ||
1257 | |||
1258 | ///Save the unsigned long in the message | ||
1259 | /** @param[out] ds : message to be written | ||
1260 | * @param data : data to be saved in the message | ||
1261 | * @param nbElement : number of element of the data | ||
1262 | * @return true on success, false otherwise | ||
1263 | */ | ||
1264 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, unsigned long>::data_stream(DataStreamIter & ds, unsigned long * data, size_t nbElement){ | |
1265 | 98 | const char* srcByte = (const char*)data; | |
1266 | 98 | memcpy(ds, srcByte, sizeof(unsigned long)*nbElement); | |
1267 | 98 | ds += sizeof(unsigned long)*nbElement; | |
1268 | 98 | return true; | |
1269 | } | ||
1270 | |||
1271 | |||
1272 | |||
1273 | ///Get the size of a type unsigned long | ||
1274 | /** @param[out] ds : size of the type | ||
1275 | * @param data : data to be used | ||
1276 | * @return true on success, false otherwise | ||
1277 | */ | ||
1278 | 194 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned long>::data_stream(size_t & ds, unsigned long & data){ | |
1279 | 194 | ds += sizeof(unsigned long); | |
1280 | 194 | return true; | |
1281 | } | ||
1282 | |||
1283 | ///Get the size of a type unsigned long | ||
1284 | /** @param[out] ds : size of the type | ||
1285 | * @param data : data to be used | ||
1286 | * @param nbElement : number of element of the data | ||
1287 | * @return true on success, false otherwise | ||
1288 | */ | ||
1289 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, unsigned long>::data_stream(size_t & ds, unsigned long * data, size_t nbElement){ | |
1290 | 138 | ds += sizeof(unsigned long)*nbElement; | |
1291 | 138 | return true; | |
1292 | } | ||
1293 | |||
1294 | |||
1295 | |||
1296 | |||
1297 | |||
1298 | ///Read the data float in the file | ||
1299 | /** @param[out] ds : file to be read | ||
1300 | * @param[out] data : data to be set | ||
1301 | * @return true on success, false otherwise | ||
1302 | */ | ||
1303 | 723 | bool DataStream<FILE*, DataStreamMode::READ, float>::data_stream(FILE* & ds, float & data){ | |
1304 | 723 | return fread((void*)&data, sizeof(float), 1lu, ds) == 1lu; | |
1305 | } | ||
1306 | |||
1307 | ///Read the data float in the file | ||
1308 | /** @param[out] ds : file to be read | ||
1309 | * @param[out] data : data to be set | ||
1310 | * @param nbElement : number of element of this data | ||
1311 | * @return true on success, false otherwise | ||
1312 | */ | ||
1313 | 98 | bool DataStream<FILE*, DataStreamMode::READ, float>::data_stream(FILE* & ds, float * data, size_t nbElement){ | |
1314 | 98 | return fread((void*)data, sizeof(float), nbElement, ds) == nbElement; | |
1315 | } | ||
1316 | |||
1317 | ///Read the data std::vector of float in the file | ||
1318 | /** @param[out] ds : file to be read | ||
1319 | * @param[out] data : data to be set | ||
1320 | * @return true on success, false otherwise | ||
1321 | */ | ||
1322 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<float> >::data_stream(FILE* & ds, std::vector<float> & data){ | |
1323 | 1 | size_t nbElement(data.size()); | |
1324 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
1325 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1326 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
1327 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(float), nbElement, ds) == nbElement; |
1328 | } | ||
1329 | |||
1330 | ///Save the data float in the file | ||
1331 | /** @param[out] ds : file to be written | ||
1332 | * @param data : data to be saved in the file | ||
1333 | * @return true on success, false otherwise | ||
1334 | */ | ||
1335 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, float>::data_stream(FILE* & ds, float & data){ | |
1336 | 723 | return fwrite((const void*)&data, sizeof(float), 1lu, ds) == 1lu; | |
1337 | } | ||
1338 | |||
1339 | ///Save the data float in the file | ||
1340 | /** @param[out] ds : file to be written | ||
1341 | * @param data : data to be saved in the file | ||
1342 | * @param nbElement : number of element of this data | ||
1343 | * @return true on success, false otherwise | ||
1344 | */ | ||
1345 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, float>::data_stream(FILE* & ds, float * data, size_t nbElement){ | |
1346 | 98 | return fwrite((const void*)data, sizeof(float), nbElement, ds) == nbElement; | |
1347 | } | ||
1348 | |||
1349 | ///Save the data std::vector of data in the file | ||
1350 | /** @param[out] ds : file to be written | ||
1351 | * @param data : data to be saved in the file | ||
1352 | * @return true on success, false otherwise | ||
1353 | */ | ||
1354 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<float> >::data_stream(FILE* & ds, std::vector<float> & data){ | |
1355 | 1 | size_t nbElement(data.size()); | |
1356 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
1357 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1358 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(float), nbElement, ds) == nbElement; |
1359 | } | ||
1360 | |||
1361 | |||
1362 | |||
1363 | |||
1364 | ///Read the float in the message | ||
1365 | /** @param[out] ds : message to be read | ||
1366 | * @param[out] data : data to be set | ||
1367 | * @return true on success, false otherwise | ||
1368 | */ | ||
1369 | 81 | bool DataStream<DataStreamIter, DataStreamMode::READ, float>::data_stream(DataStreamIter & ds, float & data){ | |
1370 | 81 | char* srcByte = (char*)&data; | |
1371 | 81 | memcpy(srcByte, ds, sizeof(float)); | |
1372 | 81 | ds += sizeof(float); | |
1373 | 81 | return true; | |
1374 | } | ||
1375 | |||
1376 | ///Read the float in the message | ||
1377 | /** @param[out] ds : message to be read | ||
1378 | * @param[out] data : data to be set | ||
1379 | * @param nbElement : number of element of the data | ||
1380 | * @return true on success, false otherwise | ||
1381 | */ | ||
1382 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, float>::data_stream(DataStreamIter & ds, float * data, size_t nbElement){ | |
1383 | 98 | char* srcByte = (char*)data; | |
1384 | 98 | memcpy(srcByte, ds, sizeof(float)*nbElement); | |
1385 | 98 | ds += sizeof(float)*nbElement; | |
1386 | 98 | return true; | |
1387 | } | ||
1388 | |||
1389 | ///Save the float in the message | ||
1390 | /** @param[out] ds : message to be written | ||
1391 | * @param data : data to be saved in the message | ||
1392 | * @return true on success, false otherwise | ||
1393 | */ | ||
1394 | 81 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, float>::data_stream(DataStreamIter & ds, float & data){ | |
1395 | 81 | const char* srcByte = (const char*)&data; | |
1396 | 81 | memcpy(ds, srcByte, sizeof(float)); | |
1397 | 81 | ds += sizeof(float); | |
1398 | 81 | return true; | |
1399 | } | ||
1400 | |||
1401 | ///Save the float in the message | ||
1402 | /** @param[out] ds : message to be written | ||
1403 | * @param data : data to be saved in the message | ||
1404 | * @param nbElement : number of element of the data | ||
1405 | * @return true on success, false otherwise | ||
1406 | */ | ||
1407 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, float>::data_stream(DataStreamIter & ds, float * data, size_t nbElement){ | |
1408 | 98 | const char* srcByte = (const char*)data; | |
1409 | 98 | memcpy(ds, srcByte, sizeof(float)*nbElement); | |
1410 | 98 | ds += sizeof(float)*nbElement; | |
1411 | 98 | return true; | |
1412 | } | ||
1413 | |||
1414 | |||
1415 | |||
1416 | ///Get the size of a type float | ||
1417 | /** @param[out] ds : size of the type | ||
1418 | * @param data : data to be used | ||
1419 | * @return true on success, false otherwise | ||
1420 | */ | ||
1421 | 82 | bool DataStream<size_t, DataStreamMode::WRITE, float>::data_stream(size_t & ds, float & data){ | |
1422 | 82 | ds += sizeof(float); | |
1423 | 82 | return true; | |
1424 | } | ||
1425 | |||
1426 | ///Get the size of a type float | ||
1427 | /** @param[out] ds : size of the type | ||
1428 | * @param data : data to be used | ||
1429 | * @param nbElement : number of element of the data | ||
1430 | * @return true on success, false otherwise | ||
1431 | */ | ||
1432 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, float>::data_stream(size_t & ds, float * data, size_t nbElement){ | |
1433 | 138 | ds += sizeof(float)*nbElement; | |
1434 | 138 | return true; | |
1435 | } | ||
1436 | |||
1437 | |||
1438 | |||
1439 | |||
1440 | |||
1441 | ///Read the data double in the file | ||
1442 | /** @param[out] ds : file to be read | ||
1443 | * @param[out] data : data to be set | ||
1444 | * @return true on success, false otherwise | ||
1445 | */ | ||
1446 | 723 | bool DataStream<FILE*, DataStreamMode::READ, double>::data_stream(FILE* & ds, double & data){ | |
1447 | 723 | return fread((void*)&data, sizeof(double), 1lu, ds) == 1lu; | |
1448 | } | ||
1449 | |||
1450 | ///Read the data double in the file | ||
1451 | /** @param[out] ds : file to be read | ||
1452 | * @param[out] data : data to be set | ||
1453 | * @param nbElement : number of element of this data | ||
1454 | * @return true on success, false otherwise | ||
1455 | */ | ||
1456 | 98 | bool DataStream<FILE*, DataStreamMode::READ, double>::data_stream(FILE* & ds, double * data, size_t nbElement){ | |
1457 | 98 | return fread((void*)data, sizeof(double), nbElement, ds) == nbElement; | |
1458 | } | ||
1459 | |||
1460 | ///Read the data std::vector of double in the file | ||
1461 | /** @param[out] ds : file to be read | ||
1462 | * @param[out] data : data to be set | ||
1463 | * @return true on success, false otherwise | ||
1464 | */ | ||
1465 | 1 | bool DataStream<FILE*, DataStreamMode::READ, std::vector<double> >::data_stream(FILE* & ds, std::vector<double> & data){ | |
1466 | 1 | size_t nbElement(data.size()); | |
1467 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::READ, size_t>::data_stream(ds, nbElement); |
1468 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1469 |
1/1✓ Branch 1 taken 1 times.
|
1 | data.resize(nbElement); |
1470 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fread((void*)data.data(), sizeof(double), nbElement, ds) == nbElement; |
1471 | } | ||
1472 | |||
1473 | ///Save the data double in the file | ||
1474 | /** @param[out] ds : file to be written | ||
1475 | * @param data : data to be saved in the file | ||
1476 | * @return true on success, false otherwise | ||
1477 | */ | ||
1478 | 723 | bool DataStream<FILE*, DataStreamMode::WRITE, double>::data_stream(FILE* & ds, double & data){ | |
1479 | 723 | return fwrite((const void*)&data, sizeof(double), 1lu, ds) == 1lu; | |
1480 | } | ||
1481 | |||
1482 | ///Save the data double in the file | ||
1483 | /** @param[out] ds : file to be written | ||
1484 | * @param data : data to be saved in the file | ||
1485 | * @param nbElement : number of element of this data | ||
1486 | * @return true on success, false otherwise | ||
1487 | */ | ||
1488 | 98 | bool DataStream<FILE*, DataStreamMode::WRITE, double>::data_stream(FILE* & ds, double * data, size_t nbElement){ | |
1489 | 98 | return fwrite((const void*)data, sizeof(double), nbElement, ds) == nbElement; | |
1490 | } | ||
1491 | |||
1492 | ///Save the data std::vector of data in the file | ||
1493 | /** @param[out] ds : file to be written | ||
1494 | * @param data : data to be saved in the file | ||
1495 | * @return true on success, false otherwise | ||
1496 | */ | ||
1497 | 1 | bool DataStream<FILE*, DataStreamMode::WRITE, std::vector<double> >::data_stream(FILE* & ds, std::vector<double> & data){ | |
1498 | 1 | size_t nbElement(data.size()); | |
1499 |
1/1✓ Branch 1 taken 1 times.
|
1 | bool b = DataStream<FILE*, DataStreamMode::WRITE, size_t>::data_stream(ds, nbElement); |
1500 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if(nbElement == 0lu || !b){return b;} //If there is no element, quit now |
1501 |
1/1✓ Branch 2 taken 1 times.
|
1 | return fwrite((const void*)data.data(), sizeof(double), nbElement, ds) == nbElement; |
1502 | } | ||
1503 | |||
1504 | |||
1505 | |||
1506 | |||
1507 | ///Read the double in the message | ||
1508 | /** @param[out] ds : message to be read | ||
1509 | * @param[out] data : data to be set | ||
1510 | * @return true on success, false otherwise | ||
1511 | */ | ||
1512 | 81 | bool DataStream<DataStreamIter, DataStreamMode::READ, double>::data_stream(DataStreamIter & ds, double & data){ | |
1513 | 81 | char* srcByte = (char*)&data; | |
1514 | 81 | memcpy(srcByte, ds, sizeof(double)); | |
1515 | 81 | ds += sizeof(double); | |
1516 | 81 | return true; | |
1517 | } | ||
1518 | |||
1519 | ///Read the double in the message | ||
1520 | /** @param[out] ds : message to be read | ||
1521 | * @param[out] data : data to be set | ||
1522 | * @param nbElement : number of element of the data | ||
1523 | * @return true on success, false otherwise | ||
1524 | */ | ||
1525 | 98 | bool DataStream<DataStreamIter, DataStreamMode::READ, double>::data_stream(DataStreamIter & ds, double * data, size_t nbElement){ | |
1526 | 98 | char* srcByte = (char*)data; | |
1527 | 98 | memcpy(srcByte, ds, sizeof(double)*nbElement); | |
1528 | 98 | ds += sizeof(double)*nbElement; | |
1529 | 98 | return true; | |
1530 | } | ||
1531 | |||
1532 | ///Save the double in the message | ||
1533 | /** @param[out] ds : message to be written | ||
1534 | * @param data : data to be saved in the message | ||
1535 | * @return true on success, false otherwise | ||
1536 | */ | ||
1537 | 81 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, double>::data_stream(DataStreamIter & ds, double & data){ | |
1538 | 81 | const char* srcByte = (const char*)&data; | |
1539 | 81 | memcpy(ds, srcByte, sizeof(double)); | |
1540 | 81 | ds += sizeof(double); | |
1541 | 81 | return true; | |
1542 | } | ||
1543 | |||
1544 | ///Save the double in the message | ||
1545 | /** @param[out] ds : message to be written | ||
1546 | * @param data : data to be saved in the message | ||
1547 | * @param nbElement : number of element of the data | ||
1548 | * @return true on success, false otherwise | ||
1549 | */ | ||
1550 | 98 | bool DataStream<DataStreamIter, DataStreamMode::WRITE, double>::data_stream(DataStreamIter & ds, double * data, size_t nbElement){ | |
1551 | 98 | const char* srcByte = (const char*)data; | |
1552 | 98 | memcpy(ds, srcByte, sizeof(double)*nbElement); | |
1553 | 98 | ds += sizeof(double)*nbElement; | |
1554 | 98 | return true; | |
1555 | } | ||
1556 | |||
1557 | |||
1558 | |||
1559 | ///Get the size of a type double | ||
1560 | /** @param[out] ds : size of the type | ||
1561 | * @param data : data to be used | ||
1562 | * @return true on success, false otherwise | ||
1563 | */ | ||
1564 | 82 | bool DataStream<size_t, DataStreamMode::WRITE, double>::data_stream(size_t & ds, double & data){ | |
1565 | 82 | ds += sizeof(double); | |
1566 | 82 | return true; | |
1567 | } | ||
1568 | |||
1569 | ///Get the size of a type double | ||
1570 | /** @param[out] ds : size of the type | ||
1571 | * @param data : data to be used | ||
1572 | * @param nbElement : number of element of the data | ||
1573 | * @return true on success, false otherwise | ||
1574 | */ | ||
1575 | 138 | bool DataStream<size_t, DataStreamMode::WRITE, double>::data_stream(size_t & ds, double * data, size_t nbElement){ | |
1576 | 138 | ds += sizeof(double)*nbElement; | |
1577 | 138 | return true; | |
1578 | } | ||
1579 | |||
1580 | |||
1581 | |||
1582 | |||
1583 | |||
1584 | |||
1585 | |||
1586 |