GCC Code Coverage Report


Directory: ./
File: src/data_stream_read_file.h
Date: 2026-01-15 15:51:44
Exec Total Coverage
Lines: 32 32 100.0%
Functions: 588 588 100.0%
Branches: 27 36 75.0%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #ifndef __DATA_STREAM_READ_FILE_H__
8 #define __DATA_STREAM_READ_FILE_H__
9
10 #include "data_stream_include.h"
11
12 ///@brief How to write a class in a file
13 template<typename T>
14 struct DataStream<FILE*,DataStreamMode::READ, std::vector<T> >{
15 ///Get the size of a class std::vector T
16 /** @param[out] ds : file to write the class std::vector T
17 * @param data : data to be saved
18 * @return true on success, false otherwise
19 */
20 144 static bool data_stream(FILE* & ds, std::vector<T> & data){
21 //Get the number of elements
22 144 size_t nbElement(0lu);
23
1/1
✓ Branch 0 (2→3) taken 144 times.
144 bool b = DataStream<FILE*,DataStreamMode::READ, size_t>::data_stream(ds, nbElement);
24
2/4
✓ Branch 0 (3→4) taken 144 times.
✗ Branch 1 (3→5) not taken.
✗ Branch 2 (4→5) not taken.
✓ Branch 3 (4→6) taken 144 times.
144 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
25
3/4
✓ Branch 0 (10→11) taken 1440 times.
✓ Branch 1 (10→12) taken 144 times.
✓ Branch 2 (11→7) taken 1440 times.
✗ Branch 3 (11→12) not taken.
1584 for(size_t i(0lu); i < nbElement && b; ++i){
26 1440 T tmp;
27
1/1
✓ Branch 0 (7→8) taken 1440 times.
1440 b &= DataStream<FILE*,DataStreamMode::READ, T>::data_stream(ds, tmp);
28
1/1
✓ Branch 0 (8→9) taken 1440 times.
1440 data.push_back(tmp);
29 }
30 144 return b;
31 }
32 };
33
34 ///@brief How to write a class in a file
35 template<typename T>
36 struct DataStream<FILE*,DataStreamMode::READ, std::list<T> >{
37 ///Get the size of a class std::list T
38 /** @param[out] ds : file to write the class std::list T
39 * @param data : data to be saved
40 * @return true on success, false otherwise
41 */
42 156 static bool data_stream(FILE* & ds, std::list<T> & data){
43 //Get the number of elements
44 156 size_t nbElement(0lu);
45
1/1
✓ Branch 0 (2→3) taken 156 times.
156 bool b = DataStream<FILE*,DataStreamMode::READ, size_t>::data_stream(ds, nbElement);
46
2/4
✓ Branch 0 (3→4) taken 156 times.
✗ Branch 1 (3→5) not taken.
✗ Branch 2 (4→5) not taken.
✓ Branch 3 (4→6) taken 156 times.
156 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
47
3/4
✓ Branch 0 (10→11) taken 1560 times.
✓ Branch 1 (10→12) taken 156 times.
✓ Branch 2 (11→7) taken 1560 times.
✗ Branch 3 (11→12) not taken.
1716 for(size_t i(0lu); i < nbElement && b; ++i){
48 1440 T tmp;
49
1/1
✓ Branch 0 (7→8) taken 1560 times.
1560 b &= DataStream<FILE*,DataStreamMode::READ, T>::data_stream(ds, tmp);
50
1/1
✓ Branch 0 (8→9) taken 1560 times.
1560 data.push_back(tmp);
51 }
52 156 return b;
53 }
54 };
55
56 ///@brief How to write a class in a file
57 template<typename T, typename U>
58 struct DataStream<FILE*,DataStreamMode::READ, std::map<T, U> >{
59 ///Get the size of a class std::list T
60 /** @param[out] ds : file to write the class std::map T U
61 * @param data : data to be saved
62 * @return true on success, false otherwise
63 */
64 144 static bool data_stream(FILE* & ds, std::map<T, U> & data){
65 //Get the number of elements
66 144 size_t nbElement(0lu);
67
1/1
✓ Branch 0 (2→3) taken 144 times.
144 bool b = DataStream<FILE*,DataStreamMode::READ, size_t>::data_stream(ds, nbElement);
68
2/4
✓ Branch 0 (3→4) taken 144 times.
✗ Branch 1 (3→5) not taken.
✗ Branch 2 (4→5) not taken.
✓ Branch 3 (4→6) taken 144 times.
144 if(nbElement == 0lu || !b){return b;} //If there is no element, quit now
69
3/4
✓ Branch 0 (11→12) taken 1344 times.
✓ Branch 1 (11→13) taken 144 times.
✓ Branch 2 (12→7) taken 1344 times.
✗ Branch 3 (12→13) not taken.
1488 for(size_t i(0lu); i < nbElement && b; ++i){
70 T tmpFirst;
71
1/1
✓ Branch 0 (7→8) taken 1344 times.
1344 b &= DataStream<FILE*,DataStreamMode::READ, T>::data_stream(ds, tmpFirst);
72 U tmpSecond;
73
1/1
✓ Branch 0 (8→9) taken 1344 times.
1344 b &= DataStream<FILE*,DataStreamMode::READ, U>::data_stream(ds, tmpSecond);
74
1/1
✓ Branch 0 (9→10) taken 1344 times.
1344 data[tmpFirst] = tmpSecond; //Add data in map
75 }
76 144 return b;
77 }
78 };
79
80 ///@brief How to write a class in a file
81 template<typename T, typename U>
82 struct DataStream<FILE*,DataStreamMode::READ, std::pair<T, U> >{
83 ///Get the size of a class std::list T
84 /** @param[out] ds : file to write the class std::pair T
85 * @param data : data to be saved
86 * @return true on success, false otherwise
87 */
88 2880 static bool data_stream(FILE* & ds, std::pair<T, U> & data){
89 T tmpFirst;
90
1/1
✓ Branch 0 (2→3) taken 2880 times.
2880 bool b = DataStream<FILE*,DataStreamMode::READ, T>::data_stream(ds, tmpFirst);
91 U tmpSecond;
92
1/1
✓ Branch 0 (3→4) taken 2880 times.
2880 b &= DataStream<FILE*,DataStreamMode::READ, U>::data_stream(ds, tmpSecond);
93 2880 data = std::pair<T, U>(tmpFirst, tmpSecond);
94 2880 return b;
95 }
96 };
97
98
99
100 #endif
101
102
103