GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/CPP/CppTraitTypeStream/CppTraitTypeStream.cpp
Date: 2026-10-16 17:52:29
Exec Total Coverage
Lines: 60 77 77.9%
Functions: 12 12 100.0%
Branches: 95 146 65.1%

Line Branch Exec Source
1
2 /***************************************
3 Auteur : Pierre Aubert
4 Mail : pierre.aubert@lapp.in2p3.fr
5 Licence : LGPL-3.0-only
6 ****************************************/
7
8 #include "CppTraitTypeStream.h"
9
10 ///Consctructor of CppTraitTypeStream
11 4 CppTraitTypeStream::CppTraitTypeStream()
12 4 :PAbstractTraitBackend()
13 4 {}
14
15 ///Desctructor of CppTraitTypeStream
16 8 CppTraitTypeStream::~CppTraitTypeStream(){}
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 CppTraitTypeStream::headerExtraInclude(std::ofstream & fs, const GeneratorMode & mode) const{
23
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 6 times.
6 if(!mode.enableTypeStream){return;}
24 6 fs << "#include \"phoenix_type_stream.h\"" << std::endl;
25 }
26
27 ///Declaration of protected 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 7 void CppTraitTypeStream::protectedMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
33
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 7 times.
7 if(!mode.enableTypeStream){return;}
34
35 }
36
37 ///Implementation of protected 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 10 void CppTraitTypeStream::protectedMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
43
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 10 times.
10 if(!mode.enableTypeStream){return;}
44
45 }
46
47 ///Declaration of private 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 7 void CppTraitTypeStream::privateMethodDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
53
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 7 times.
7 if(!mode.enableTypeStream){return;}
54
55 }
56
57 ///Implementation of private methods
58 /** @param[out] fs : file to be completed
59 * @param classConfig : PClassConfig to be used
60 * @param mode : mode of the generator
61 */
62 10 void CppTraitTypeStream::privateMethodImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
63
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 10 times.
10 if(!mode.enableTypeStream){return;}
64
65 }
66
67 ///Declaration of extra functions
68 /** @param[out] fs : file to be completed
69 * @param classConfig : PClassConfig to be used
70 * @param mode : mode of the generator
71 */
72 10 void CppTraitTypeStream::classExtraFunctionDeclaration(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
73
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 10 times.
10 if(!mode.enableTypeStream){return;}
74
2/2
✓ Branch 0 (4→5) taken 10 times.
✓ Branch 2 (5→6) taken 10 times.
10 PString name(classConfig.getName());
75
1/1
✓ Branch 0 (6→7) taken 10 times.
10 PString fullName(classConfig.getFullName());
76
77
3/3
✓ Branch 0 (7→8) taken 10 times.
✓ Branch 2 (8→9) taken 3 times.
✓ Branch 3 (8→15) taken 7 times.
10 if(classConfig.getIsEnum()){
78
3/3
✓ Branch 0 (9→10) taken 3 times.
✓ Branch 2 (10→11) taken 3 times.
✓ Branch 4 (11→12) taken 3 times.
3 name = name + "::" + name;
79 }
80
81
1/1
✓ Branch 0 (15→16) taken 10 times.
10 const PVecString & listTemplate = classConfig.getListTemplate();
82
1/2
✗ Branch 0 (17→18) not taken.
✓ Branch 1 (17→62) taken 10 times.
10 if(listTemplate.size() != 0LU){
83 ✗ fs << "///Get the name of the class " << name << std::endl;
84 ✗ fs << "/**\t@return name of the class " << name << std::endl;
85 ✗ fs << "*/" << std::endl;
86 ✗ fs << mode.templateDeclaration;
87 ✗ fs << "std::string phoenix_getTypeName<"<<fullName << mode.defTemplate <<" >(){" << std::endl;
88 ✗ fs << "\treturn \""<<name<<"\"";
89 ✗ fs << " + \"<\"";
90 ✗ for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
91 ✗ fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()";
92 }
93 ✗ fs << " + \">\"";
94 ✗ fs << ";" << std::endl;
95 ✗ fs << "}" << std::endl << std::endl;
96
97 }else{
98
2/2
✓ Branch 0 (62→63) taken 10 times.
✓ Branch 2 (63→64) taken 10 times.
10 fs << "template<>" << std::endl;
99 //Enums are generated without their namespace (namespace Name{enum Name}), so they keep Name::Name
100
8/8
✓ Branch 0 (64→65) taken 10 times.
✓ Branch 2 (65→66) taken 10 times.
✓ Branch 4 (66→67) taken 3 times.
✓ Branch 5 (66→68) taken 7 times.
✓ Branch 6 (69→70) taken 10 times.
✓ Branch 8 (70→71) taken 10 times.
✓ Branch 10 (71→72) taken 10 times.
✓ Branch 12 (72→73) taken 10 times.
10 fs << "std::string phoenix_getTypeName<"<<(classConfig.getIsEnum() ? name : fullName)<<">();" << std::endl << std::endl;
101 }
102 10 }
103
104 ///Implementation of extra functions
105 /** @param[out] fs : file to be completed
106 * @param classConfig : PClassConfig to be used
107 * @param mode : mode of the generator
108 */
109 10 void CppTraitTypeStream::classExtraFunctionImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
110
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 10 times.
10 if(!mode.enableTypeStream){return;}
111
2/2
✓ Branch 0 (4→5) taken 10 times.
✓ Branch 2 (5→6) taken 10 times.
10 PString name(classConfig.getName());
112
1/1
✓ Branch 0 (6→7) taken 10 times.
10 PString fullName(classConfig.getFullName());
113
4/4
✓ Branch 0 (7→8) taken 10 times.
✓ Branch 2 (8→9) taken 10 times.
✓ Branch 4 (9→10) taken 10 times.
✓ Branch 6 (10→11) taken 10 times.
10 fs << "///Get the name of the class " << name << " for PhoenixTypeStream" << std::endl;
114
4/4
✓ Branch 0 (11→12) taken 10 times.
✓ Branch 2 (12→13) taken 10 times.
✓ Branch 4 (13→14) taken 10 times.
✓ Branch 6 (14→15) taken 10 times.
10 fs << "/**\t@return name of the class " << name << " for PhoenixTypeStream" << std::endl;
115
2/2
✓ Branch 0 (15→16) taken 10 times.
✓ Branch 2 (16→17) taken 10 times.
10 fs << "*/" << std::endl;
116
3/3
✓ Branch 0 (17→18) taken 10 times.
✓ Branch 2 (18→19) taken 3 times.
✓ Branch 3 (18→25) taken 7 times.
10 if(classConfig.getIsEnum()){
117 //Enums are generated without their namespace (namespace Name{enum Name}), so they keep Name::Name
118
3/3
✓ Branch 0 (19→20) taken 3 times.
✓ Branch 2 (20→21) taken 3 times.
✓ Branch 4 (21→22) taken 3 times.
3 name = name + "::" + name;
119
1/1
✓ Branch 0 (24→25) taken 3 times.
3 fullName = name;
120 }
121
1/1
✓ Branch 0 (25→26) taken 10 times.
10 const PVecString & listTemplate = classConfig.getListTemplate();
122
1/2
✓ Branch 0 (27→28) taken 10 times.
✗ Branch 1 (27→30) not taken.
10 if(listTemplate.size() == 0LU){
123
2/2
✓ Branch 0 (28→29) taken 10 times.
✓ Branch 2 (29→31) taken 10 times.
10 fs << "template<>" << std::endl;
124 }else{
125 ✗ fs << mode.templateDeclaration;
126 }
127
5/5
✓ Branch 0 (31→32) taken 10 times.
✓ Branch 2 (32→33) taken 10 times.
✓ Branch 4 (33→34) taken 10 times.
✓ Branch 6 (34→35) taken 10 times.
✓ Branch 8 (35→36) taken 10 times.
10 fs << "std::string phoenix_getTypeName<"<<fullName << mode.defTemplate <<" >(){" << std::endl;
128
3/3
✓ Branch 0 (36→37) taken 10 times.
✓ Branch 2 (37→38) taken 10 times.
✓ Branch 4 (38→39) taken 10 times.
10 fs << "\treturn \""<<name<<"\"";
129
1/2
✗ Branch 0 (40→41) not taken.
✓ Branch 1 (40→63) taken 10 times.
10 if(listTemplate.size() != 0LU){
130 ✗ fs << " + \"<\"";
131 ✗ for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
132 ✗ fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()";
133 }
134 ✗ fs << " + \">\"";
135 }
136
2/2
✓ Branch 0 (63→64) taken 10 times.
✓ Branch 2 (64→65) taken 10 times.
10 fs << ";" << std::endl;
137
3/3
✓ Branch 0 (65→66) taken 10 times.
✓ Branch 2 (66→67) taken 10 times.
✓ Branch 4 (67→68) taken 10 times.
10 fs << "}" << std::endl << std::endl;
138 10 }
139
140 ///Implementation of test function
141 /** @param[out] fs : file to be completed
142 * @param classConfig : PClassConfig to be used
143 * @param mode : mode of the generator
144 */
145 9 void CppTraitTypeStream::testFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
146
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 9 times.
9 if(!mode.enableTypeStream){return;}
147
2/2
✓ Branch 0 (4→5) taken 9 times.
✓ Branch 2 (5→6) taken 9 times.
9 PString name(classConfig.getName());
148
3/3
✓ Branch 0 (6→7) taken 9 times.
✓ Branch 2 (7→8) taken 9 times.
✓ Branch 4 (8→9) taken 9 times.
9 fs << "///Check TypeStream of class "+name+"\n";
149
3/3
✓ Branch 0 (11→12) taken 9 times.
✓ Branch 2 (12→13) taken 9 times.
✓ Branch 4 (13→14) taken 9 times.
9 fs << "void check"+name+"TypeStream(){\n";
150
3/3
✓ Branch 0 (16→17) taken 9 times.
✓ Branch 2 (17→18) taken 3 times.
✓ Branch 3 (17→24) taken 6 times.
9 if(classConfig.getIsEnum()){
151
3/3
✓ Branch 0 (18→19) taken 3 times.
✓ Branch 2 (19→20) taken 3 times.
✓ Branch 4 (20→21) taken 3 times.
3 name = name + "::" + name;
152 }
153
7/7
✓ Branch 0 (24→25) taken 9 times.
✓ Branch 2 (25→26) taken 9 times.
✓ Branch 4 (26→27) taken 9 times.
✓ Branch 6 (27→28) taken 9 times.
✓ Branch 8 (28→29) taken 9 times.
✓ Branch 10 (29→30) taken 9 times.
✓ Branch 12 (30→31) taken 9 times.
9 fs << "\t"<<mode.assertCall<<"(phoenix_getTypeToStr<"<<name<<">() == \""<<name<<"\");\n";
154
1/1
✓ Branch 0 (31→32) taken 9 times.
9 fs << "}\n\n";
155 9 }
156
157 ///Call of the test function
158 /** @param[out] fs : file to be completed
159 * @param classConfig : PClassConfig to be used
160 * @param mode : mode of the generator
161 */
162 9 void CppTraitTypeStream::testCallFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
163
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 9 times.
9 if(!mode.enableTypeStream){return;}
164
2/2
✓ Branch 0 (4→5) taken 9 times.
✓ Branch 2 (5→6) taken 9 times.
9 PString name(classConfig.getName());
165
3/3
✓ Branch 0 (6→7) taken 9 times.
✓ Branch 2 (7→8) taken 9 times.
✓ Branch 4 (8→9) taken 9 times.
9 fs << "\tcheck"+name+"TypeStream();\n";
166 9 }
167
168
169
170