GCC Code Coverage Report


Directory: ./
File: src/TraitBackEnd/CPP/CppTraitTypeStream/CppTraitTypeStream.cpp
Date: 2025-12-15 11:32:44
Exec Total Coverage
Lines: 57 74 77.0%
Functions: 12 12 100.0%
Branches: 89 140 63.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 "CppTraitTypeStream.h"
9
10 ///Consctructor of CppTraitTypeStream
11 3 CppTraitTypeStream::CppTraitTypeStream()
12 3 :PAbstractTraitBackend()
13 3 {}
14
15 ///Desctructor of CppTraitTypeStream
16 6 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 4 void CppTraitTypeStream::headerExtraInclude(std::ofstream & fs, const GeneratorMode & mode) const{
23
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 4 times.
4 if(!mode.enableTypeStream){return;}
24 4 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 4 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 4 times.
4 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 5 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 5 times.
5 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 4 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 4 times.
4 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 5 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 5 times.
5 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 5 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 5 times.
5 if(!mode.enableTypeStream){return;}
74
2/2
✓ Branch 0 (4→5) taken 5 times.
✓ Branch 2 (5→6) taken 5 times.
5 PString name(classConfig.getName());
75
76
3/3
✓ Branch 0 (6→7) taken 5 times.
✓ Branch 2 (7→8) taken 1 times.
✓ Branch 3 (7→14) taken 4 times.
5 if(classConfig.getIsEnum()){
77
3/3
✓ Branch 0 (8→9) taken 1 times.
✓ Branch 2 (9→10) taken 1 times.
✓ Branch 4 (10→11) taken 1 times.
1 name = name + "::" + name;
78 }
79
80
1/1
✓ Branch 0 (14→15) taken 5 times.
5 const PVecString & listTemplate = classConfig.getListTemplate();
81
1/2
✗ Branch 0 (16→17) not taken.
✓ Branch 1 (16→61) taken 5 times.
5 if(listTemplate.size() != 0lu){
82 fs << "///Get the name of the class " << name << std::endl;
83 fs << "/**\t@return name of the class " << name << std::endl;
84 fs << "*/" << std::endl;
85 fs << mode.templateDeclaration;
86 fs << "std::string phoenix_getTypeName<"<<name << mode.defTemplate <<" >(){" << std::endl;
87 fs << "\treturn \""<<name<<"\"";
88 fs << " + \"<\"";
89 for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
90 fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()";
91 }
92 fs << " + \">\"";
93 fs << ";" << std::endl;
94 fs << "}" << std::endl << std::endl;
95
96 }else{
97
2/2
✓ Branch 0 (61→62) taken 5 times.
✓ Branch 2 (62→63) taken 5 times.
5 fs << "template<>" << std::endl;
98
5/5
✓ Branch 0 (63→64) taken 5 times.
✓ Branch 2 (64→65) taken 5 times.
✓ Branch 4 (65→66) taken 5 times.
✓ Branch 6 (66→67) taken 5 times.
✓ Branch 8 (67→68) taken 5 times.
5 fs << "std::string phoenix_getTypeName<"<<name<<">();" << std::endl << std::endl;
99 }
100 5 }
101
102 ///Implementation of extra functions
103 /** @param[out] fs : file to be completed
104 * @param classConfig : PClassConfig to be used
105 * @param mode : mode of the generator
106 */
107 5 void CppTraitTypeStream::classExtraFunctionImplementation(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
108
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 5 times.
5 if(!mode.enableTypeStream){return;}
109
2/2
✓ Branch 0 (4→5) taken 5 times.
✓ Branch 2 (5→6) taken 5 times.
5 PString name(classConfig.getName());
110
4/4
✓ Branch 0 (6→7) taken 5 times.
✓ Branch 2 (7→8) taken 5 times.
✓ Branch 4 (8→9) taken 5 times.
✓ Branch 6 (9→10) taken 5 times.
5 fs << "///Get the name of the class " << name << " for PhoenixTypeStream" << std::endl;
111
4/4
✓ Branch 0 (10→11) taken 5 times.
✓ Branch 2 (11→12) taken 5 times.
✓ Branch 4 (12→13) taken 5 times.
✓ Branch 6 (13→14) taken 5 times.
5 fs << "/**\t@return name of the class " << name << " for PhoenixTypeStream" << std::endl;
112
2/2
✓ Branch 0 (14→15) taken 5 times.
✓ Branch 2 (15→16) taken 5 times.
5 fs << "*/" << std::endl;
113
3/3
✓ Branch 0 (16→17) taken 5 times.
✓ Branch 2 (17→18) taken 1 times.
✓ Branch 3 (17→24) taken 4 times.
5 if(classConfig.getIsEnum()){
114
3/3
✓ Branch 0 (18→19) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✓ Branch 4 (20→21) taken 1 times.
1 name = name + "::" + name;
115 }
116
1/1
✓ Branch 0 (24→25) taken 5 times.
5 const PVecString & listTemplate = classConfig.getListTemplate();
117
1/2
✓ Branch 0 (26→27) taken 5 times.
✗ Branch 1 (26→29) not taken.
5 if(listTemplate.size() == 0lu){
118
2/2
✓ Branch 0 (27→28) taken 5 times.
✓ Branch 2 (28→30) taken 5 times.
5 fs << "template<>" << std::endl;
119 }else{
120 fs << mode.templateDeclaration;
121 }
122
5/5
✓ Branch 0 (30→31) taken 5 times.
✓ Branch 2 (31→32) taken 5 times.
✓ Branch 4 (32→33) taken 5 times.
✓ Branch 6 (33→34) taken 5 times.
✓ Branch 8 (34→35) taken 5 times.
5 fs << "std::string phoenix_getTypeName<"<<name << mode.defTemplate <<" >(){" << std::endl;
123
3/3
✓ Branch 0 (35→36) taken 5 times.
✓ Branch 2 (36→37) taken 5 times.
✓ Branch 4 (37→38) taken 5 times.
5 fs << "\treturn \""<<name<<"\"";
124
1/2
✗ Branch 0 (39→40) not taken.
✓ Branch 1 (39→62) taken 5 times.
5 if(listTemplate.size() != 0lu){
125 fs << " + \"<\"";
126 for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
127 fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()";
128 }
129 fs << " + \">\"";
130 }
131
2/2
✓ Branch 0 (62→63) taken 5 times.
✓ Branch 2 (63→64) taken 5 times.
5 fs << ";" << std::endl;
132
3/3
✓ Branch 0 (64→65) taken 5 times.
✓ Branch 2 (65→66) taken 5 times.
✓ Branch 4 (66→67) taken 5 times.
5 fs << "}" << std::endl << std::endl;
133 5 }
134
135 ///Implementation of test function
136 /** @param[out] fs : file to be completed
137 * @param classConfig : PClassConfig to be used
138 * @param mode : mode of the generator
139 */
140 4 void CppTraitTypeStream::testFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
141
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 4 times.
4 if(!mode.enableTypeStream){return;}
142
2/2
✓ Branch 0 (4→5) taken 4 times.
✓ Branch 2 (5→6) taken 4 times.
4 PString name(classConfig.getName());
143
3/3
✓ Branch 0 (6→7) taken 4 times.
✓ Branch 2 (7→8) taken 4 times.
✓ Branch 4 (8→9) taken 4 times.
4 fs << "///Check TypeStream of class "+name+"\n";
144
3/3
✓ Branch 0 (11→12) taken 4 times.
✓ Branch 2 (12→13) taken 4 times.
✓ Branch 4 (13→14) taken 4 times.
4 fs << "void check"+name+"TypeStream(){\n";
145
3/3
✓ Branch 0 (16→17) taken 4 times.
✓ Branch 2 (17→18) taken 1 times.
✓ Branch 3 (17→24) taken 3 times.
4 if(classConfig.getIsEnum()){
146
3/3
✓ Branch 0 (18→19) taken 1 times.
✓ Branch 2 (19→20) taken 1 times.
✓ Branch 4 (20→21) taken 1 times.
1 name = name + "::" + name;
147 }
148
7/7
✓ Branch 0 (24→25) taken 4 times.
✓ Branch 2 (25→26) taken 4 times.
✓ Branch 4 (26→27) taken 4 times.
✓ Branch 6 (27→28) taken 4 times.
✓ Branch 8 (28→29) taken 4 times.
✓ Branch 10 (29→30) taken 4 times.
✓ Branch 12 (30→31) taken 4 times.
4 fs << "\t"<<mode.assertCall<<"(phoenix_getTypeToStr<"<<name<<">() == \""<<name<<"\");\n";
149
1/1
✓ Branch 0 (31→32) taken 4 times.
4 fs << "}\n\n";
150 4 }
151
152 ///Call of the test function
153 /** @param[out] fs : file to be completed
154 * @param classConfig : PClassConfig to be used
155 * @param mode : mode of the generator
156 */
157 4 void CppTraitTypeStream::testCallFunction(std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode) const{
158
1/2
✗ Branch 0 (2→3) not taken.
✓ Branch 1 (2→4) taken 4 times.
4 if(!mode.enableTypeStream){return;}
159
2/2
✓ Branch 0 (4→5) taken 4 times.
✓ Branch 2 (5→6) taken 4 times.
4 PString name(classConfig.getName());
160
3/3
✓ Branch 0 (6→7) taken 4 times.
✓ Branch 2 (7→8) taken 4 times.
✓ Branch 4 (8→9) taken 4 times.
4 fs << "\tcheck"+name+"TypeStream();\n";
161 4 }
162
163
164
165