GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/CPP/CppTraitCheckStream/CppTraitCheckStream.cpp
Date: 2026-06-23 11:27:41
Exec Total Coverage
Lines: 57 68 83.8%
Functions: 12 12 100.0%
Branches: 112 161 69.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 #include "CppTraitCheckStream.h"
9
10 ///Consctructor of CppTraitCheckStream
11 4 CppTraitCheckStream::CppTraitCheckStream()
12 4 :PAbstractTraitBackend()
13 4 {}
14
15 ///Desctructor of CppTraitCheckStream
16 8 CppTraitCheckStream::~CppTraitCheckStream(){}
17
18 ///Add extra include on the header
19 /** @param[out] fs : file to be completed
20 * @param mode : mode of the generator
21 */
22 6 void CppTraitCheckStream::headerExtraInclude(std::ofstream & fs, const GeneratorMode & mode) const{
23
2/2
✓ Branch 0 (2→3) taken 2 times.
✓ Branch 1 (2→4) taken 4 times.
6 if(!mode.enableCheckStream){return;}
24 4 fs << "#include \"phoenix_check_stream.h\"" << std::endl;
25 }
26
27 ///Declaration of public methods
28 /** @param[out] fs : file to be completed
29 * @param classConfig : PClassConfig to be used
30 * @param mode : mode of the generator
31 */
32 6 void CppTraitCheckStream::publicMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
33
2/2
✓ Branch 0 (2→3) taken 2 times.
✓ Branch 1 (2→4) taken 4 times.
6 if(!mode.enableCheckStream){return;}
34
35 }
36
37 ///Implementation of public methods
38 /** @param[out] fs : file to be completed
39 * @param classConfig : PClassConfig to be used
40 * @param mode : mode of the generator
41 */
42 7 void CppTraitCheckStream::publicMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
43
2/2
✓ Branch 0 (2→3) taken 2 times.
✓ Branch 1 (2→4) taken 5 times.
7 if(!mode.enableCheckStream){return;}
44
45 }
46
47 ///Declaration of protected methods
48 /** @param[out] fs : file to be completed
49 * @param classConfig : PClassConfig to be used
50 * @param mode : mode of the generator
51 */
52 6 void CppTraitCheckStream::protectedMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
53
54 6 }
55
56 ///Implementation of protected methods
57 /** @param[out] fs : file to be completed
58 * @param classConfig : PClassConfig to be used
59 * @param mode : mode of the generator
60 */
61 7 void CppTraitCheckStream::protectedMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
62
63 7 }
64
65 ///Declaration of private methods
66 /** @param[out] fs : file to be completed
67 * @param classConfig : PClassConfig to be used
68 * @param mode : mode of the generator
69 */
70 6 void CppTraitCheckStream::privateMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
71
72 6 }
73
74 ///Implementation of private methods
75 /** @param[out] fs : file to be completed
76 * @param classConfig : PClassConfig to be used
77 * @param mode : mode of the generator
78 */
79 7 void CppTraitCheckStream::privateMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
80
81 7 }
82
83 ///Declaration of extra functions
84 /** @param[out] fs : file to be completed
85 * @param classConfig : PClassConfig to be used
86 * @param mode : mode of the generator
87 */
88 7 void CppTraitCheckStream::classExtraFunctionDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
89
2/2
✓ Branch 0 (2→3) taken 2 times.
✓ Branch 1 (2→4) taken 5 times.
8 if(!mode.enableCheckStream){return;}
90
2/2
✓ Branch 0 (4→5) taken 5 times.
✓ Branch 2 (5→6) taken 5 times.
5 PString name(classConfig.getName());
91
1/1
✓ Branch 0 (6→7) taken 5 times.
5 PString fullName(classConfig.getFullName());
92
1/1
✓ Branch 0 (7→8) taken 5 times.
5 const PVecString & listTemplate = classConfig.getListTemplate();
93
3/3
✓ Branch 0 (8→9) taken 5 times.
✓ Branch 2 (9→10) taken 1 times.
✓ Branch 3 (9→18) taken 4 times.
5 if(classConfig.getIsEnum()){
94
7/7
✓ Branch 0 (10→11) taken 1 times.
✓ Branch 2 (11→12) taken 1 times.
✓ Branch 4 (12→13) taken 1 times.
✓ Branch 6 (13→14) taken 1 times.
✓ Branch 8 (14→15) taken 1 times.
✓ Branch 10 (15→16) taken 1 times.
✓ Branch 12 (16→17) taken 1 times.
1 fs << "PHOENIX_CHECK_STREAM_ENUM("<<name<<"::"<<name<<")" << std::endl << std::endl;
95 1 return;
96 }
97
1/2
✗ Branch 0 (19→20) not taken.
✓ Branch 1 (19→87) taken 4 times.
4 if(listTemplate.size() != 0lu){
98 fs << "///@brief Generic "<<name<<" check function" << std::endl;
99 fs << mode.templateDeclaration;
100 fs << "struct CheckStream<"<<fullName << mode.defTemplate<<">{" << std::endl;
101 fs << "\tstatic bool check_stream(const std::string & fieldDescription, const "<<fullName << mode.defTemplate<<" & data, const "<<fullName << mode.defTemplate<<" & reference, std::ostream & out);" << std::endl;
102 fs << "\t\tbool b(true);" << std::endl;
103 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
104 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
105 fs << "\t\tb &= CheckStream<"<<it->getType()<<">::check_stream(fieldDescription + \"\\n- "<<name<<"::"<<it->getName()<<"\", data.get"<<it->getName().firstToUpper()<<"(), reference.get"<<it->getName().firstToUpper()<<"(), out);" << std::endl;
106 }
107 fs << "\t\treturn b;" << std::endl;
108 fs << "\t}" << std::endl;
109 fs << "};" << std::endl;
110 }else{
111
4/4
✓ Branch 0 (87→88) taken 4 times.
✓ Branch 2 (88→89) taken 4 times.
✓ Branch 4 (89→90) taken 4 times.
✓ Branch 6 (90→91) taken 4 times.
4 fs << "///@brief Generic "<<name<<" Check function" << std::endl;
112
2/2
✓ Branch 0 (91→92) taken 4 times.
✓ Branch 2 (92→93) taken 4 times.
4 fs << "template<>" << std::endl;
113
4/4
✓ Branch 0 (93→94) taken 4 times.
✓ Branch 2 (94→95) taken 4 times.
✓ Branch 4 (95→96) taken 4 times.
✓ Branch 6 (96→97) taken 4 times.
4 fs << "struct CheckStream<"<<fullName<<">{" << std::endl;
114
6/6
✓ Branch 0 (97→98) taken 4 times.
✓ Branch 2 (98→99) taken 4 times.
✓ Branch 4 (99→100) taken 4 times.
✓ Branch 6 (100→101) taken 4 times.
✓ Branch 8 (101→102) taken 4 times.
✓ Branch 10 (102→103) taken 4 times.
4 fs << "\tstatic bool check_stream(const std::string & fieldDescription, const "<<fullName<<" & data, const "<<fullName<<" & reference, std::ostream & out);" << std::endl;
115
2/2
✓ Branch 0 (103→104) taken 4 times.
✓ Branch 2 (104→105) taken 4 times.
4 fs << "};" << std::endl;
116 }
117
2/2
✓ Branch 0 (105→106) taken 4 times.
✓ Branch 2 (106→107) taken 4 times.
4 fs << std::endl << std::endl;
118
4/4
✓ Branch 0 (109→110) taken 4 times.
✓ Branch 1 (109→111) taken 1 times.
✓ Branch 2 (113→114) taken 4 times.
✓ Branch 3 (113→116) taken 1 times.
6 }
119
120 ///Implementation of extra functions
121 /** @param[out] fs : file to be completed
122 * @param classConfig : PClassConfig to be used
123 * @param mode : mode of the generator
124 */
125 7 void CppTraitCheckStream::classExtraFunctionImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
126
7/7
✓ Branch 0 (2→3) taken 5 times.
✓ Branch 1 (2→5) taken 2 times.
✓ Branch 2 (3→4) taken 5 times.
✓ Branch 4 (4→5) taken 1 times.
✓ Branch 5 (4→6) taken 4 times.
✓ Branch 6 (7→8) taken 3 times.
✓ Branch 7 (7→9) taken 4 times.
7 if(!mode.enableCheckStream || classConfig.getIsEnum()){return;}
127
128
2/2
✓ Branch 0 (9→10) taken 4 times.
✓ Branch 2 (10→11) taken 4 times.
4 PString name(classConfig.getName());
129
1/1
✓ Branch 0 (11→12) taken 4 times.
4 PString fullName(classConfig.getFullName());
130
1/1
✓ Branch 0 (12→13) taken 4 times.
4 const PVecString & listTemplate = classConfig.getListTemplate();
131
1/2
✓ Branch 0 (14→15) taken 4 times.
✗ Branch 1 (14→86) not taken.
4 if(listTemplate.size() == 0lu){
132
4/4
✓ Branch 0 (15→16) taken 4 times.
✓ Branch 2 (16→17) taken 4 times.
✓ Branch 4 (17→18) taken 4 times.
✓ Branch 6 (18→19) taken 4 times.
4 fs << "///Check Stream for a "<<name<<"" << std::endl;
133
2/2
✓ Branch 0 (19→20) taken 4 times.
✓ Branch 2 (20→21) taken 4 times.
4 fs << "/**\t@param fieldDescription : description of the field to be checked" << std::endl;
134
2/2
✓ Branch 0 (21→22) taken 4 times.
✓ Branch 2 (22→23) taken 4 times.
4 fs << " * \t@param data : data to be checked" << std::endl;
135
2/2
✓ Branch 0 (23→24) taken 4 times.
✓ Branch 2 (24→25) taken 4 times.
4 fs << " * \t@param reference : reference of the check" << std::endl;
136
2/2
✓ Branch 0 (25→26) taken 4 times.
✓ Branch 2 (26→27) taken 4 times.
4 fs << " * \t@param out : ostream used to collect feed back in case of error (std::cerr or a logger)" << std::endl;
137
2/2
✓ Branch 0 (27→28) taken 4 times.
✓ Branch 2 (28→29) taken 4 times.
4 fs << " * \t@return true on success, false otherwise" << std::endl;
138
2/2
✓ Branch 0 (29→30) taken 4 times.
✓ Branch 2 (30→31) taken 4 times.
4 fs << "*/" << std::endl;
139
8/8
✓ Branch 0 (31→32) taken 4 times.
✓ Branch 2 (32→33) taken 4 times.
✓ Branch 4 (33→34) taken 4 times.
✓ Branch 6 (34→35) taken 4 times.
✓ Branch 8 (35→36) taken 4 times.
✓ Branch 10 (36→37) taken 4 times.
✓ Branch 12 (37→38) taken 4 times.
✓ Branch 14 (38→39) taken 4 times.
4 fs << "bool CheckStream<"<<fullName<<">::check_stream(const std::string & fieldDescription, const "<<fullName<<" & data, const "<<fullName<<" & reference, std::ostream & out){" << std::endl;
140
2/2
✓ Branch 0 (39→40) taken 4 times.
✓ Branch 2 (40→41) taken 4 times.
4 fs << "\tbool b(true);" << std::endl;
141
1/1
✓ Branch 0 (41→42) taken 4 times.
4 const PVecClassAttribute & vecAttr(classConfig.getListAttribute());
142
2/2
✓ Branch 0 (81→43) taken 10 times.
✓ Branch 1 (81→82) taken 4 times.
28 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
143
18/18
✓ Branch 0 (43→44) taken 10 times.
✓ Branch 2 (46→47) taken 10 times.
✓ Branch 4 (47→48) taken 10 times.
✓ Branch 6 (48→49) taken 10 times.
✓ Branch 8 (49→50) taken 10 times.
✓ Branch 10 (50→51) taken 10 times.
✓ Branch 12 (53→54) taken 10 times.
✓ Branch 14 (54→55) taken 10 times.
✓ Branch 16 (55→56) taken 10 times.
✓ Branch 18 (58→59) taken 10 times.
✓ Branch 20 (59→60) taken 10 times.
✓ Branch 22 (60→61) taken 10 times.
✓ Branch 24 (61→62) taken 10 times.
✓ Branch 26 (64→65) taken 10 times.
✓ Branch 28 (65→66) taken 10 times.
✓ Branch 30 (66→67) taken 10 times.
✓ Branch 32 (67→68) taken 10 times.
✓ Branch 34 (68→69) taken 10 times.
50 fs << "\tb &= CheckStream<"<<it->getType()<<">::check_stream(fieldDescription + \"\\n- "<<name<<"::"<<it->getName()<<"\", data.get"<<it->getName().firstToUpper()<<"(), reference.get"<<it->getName().firstToUpper()<<"(), out);" << std::endl;
144 }
145
2/2
✓ Branch 0 (82→83) taken 4 times.
✓ Branch 2 (83→84) taken 4 times.
4 fs << "\treturn b;" << std::endl;
146
2/2
✓ Branch 0 (84→85) taken 4 times.
✓ Branch 2 (85→86) taken 4 times.
4 fs << "}" << std::endl;
147 }
148
2/2
✓ Branch 0 (86→87) taken 4 times.
✓ Branch 2 (87→88) taken 4 times.
4 fs << std::endl << std::endl;
149 4 }
150
151
152
153
154