GCC Code Coverage Report


Directory: ./
File: src/BackEnd/header_generator.cpp
Date: 2025-12-15 11:32:44
Exec Total Coverage
Lines: 41 42 97.6%
Functions: 6 6 100.0%
Branches: 60 60 100.0%

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 "header_generator.h"
9
10 ///Get the licence in string
11 /** @return licence in string
12 */
13 22 PString licenceSaveStr(){
14 22 PString body("");
15
1/1
✓ Branch 0 (3→4) taken 22 times.
22 body += "/***************************************\n";
16
1/1
✓ Branch 0 (4→5) taken 22 times.
22 body += "\tAuteur : Pierre Aubert\n";
17
1/1
✓ Branch 0 (5→6) taken 22 times.
22 body += "\tMail : pierre.aubert@lapp.in2p3.fr\n";
18
1/1
✓ Branch 0 (6→7) taken 22 times.
22 body += "\tLicence : CeCILL-C\n";
19
1/1
✓ Branch 0 (7→8) taken 22 times.
22 body += "****************************************/\n";
20 22 return body;
21 }
22
23 ///Saves the policy
24 /** @param fs : file in witch to write
25 */
26 22 void licenceSave(std::ofstream & fs){
27
3/3
✓ Branch 0 (2→3) taken 22 times.
✓ Branch 2 (3→4) taken 22 times.
✓ Branch 4 (4→5) taken 22 times.
22 fs << licenceSaveStr() << std::endl;
28 22 }
29
30 ///Create the macro of multi inclusion file name
31 /** @param fileName : header file name
32 * @return macro of multi inclusion file name
33 */
34 8 PString makeMultiIncludeDefineMacro(const PString & fileName){
35
7/7
✓ Branch 0 (2→3) taken 8 times.
✓ Branch 2 (3→4) taken 8 times.
✓ Branch 4 (4→5) taken 8 times.
✓ Branch 6 (5→6) taken 8 times.
✓ Branch 8 (6→7) taken 8 times.
✓ Branch 10 (7→8) taken 8 times.
✓ Branch 12 (8→9) taken 8 times.
8 return "__" + fileName.replace(".", "_").toUpper() + "__";
36 }
37
38 ///Fonction qui sauve le fichier header
39 /** @param fileName : header file name
40 */
41 2 void saveHeaderFile(const PPath & fileName){
42
1/1
✓ Branch 0 (2→3) taken 2 times.
2 std::ofstream fs;
43
1/1
✓ Branch 0 (4→5) taken 2 times.
2 fs.open(fileName.c_str());
44
2/2
✓ Branch 0 (6→7) taken 1 times.
✓ Branch 1 (6→12) taken 1 times.
2 if(!fs.is_open()){
45
4/4
✓ Branch 0 (7→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (9→10) taken 1 times.
✓ Branch 6 (10→11) taken 1 times.
1 std::cerr << "saveHeaderFile : can't open file '" << fileName << "'" << std::endl;
46 1 return;
47 }
48
1/1
✓ Branch 0 (12→13) taken 1 times.
1 PString defineStr(makeMultiIncludeDefineMacro(fileName));
49
1/1
✓ Branch 0 (13→14) taken 1 times.
1 licenceSave(fs);
50
3/3
✓ Branch 0 (14→15) taken 1 times.
✓ Branch 2 (15→16) taken 1 times.
✓ Branch 4 (16→17) taken 1 times.
1 fs << "#ifndef " << defineStr << std::endl;
51
3/3
✓ Branch 0 (17→18) taken 1 times.
✓ Branch 2 (18→19) taken 1 times.
✓ Branch 4 (19→20) taken 1 times.
1 fs << "#define " << defineStr << std::endl;
52
6/6
✓ Branch 0 (20→21) taken 1 times.
✓ Branch 2 (21→22) taken 1 times.
✓ Branch 4 (22→23) taken 1 times.
✓ Branch 6 (23→24) taken 1 times.
✓ Branch 8 (24→25) taken 1 times.
✓ Branch 10 (25→26) taken 1 times.
1 fs << std::endl << std::endl << std::endl << std::endl << std::endl << std::endl;
53
2/2
✓ Branch 0 (26→27) taken 1 times.
✓ Branch 2 (27→28) taken 1 times.
1 fs << "#endif" << std::endl;
54
1/1
✓ Branch 0 (28→29) taken 1 times.
1 fs.close();
55 2 }
56
57 ///Fonction qui sauve le fichier source
58 /** @param fileName : source file name
59 * @param headerName : header file name
60 */
61 2 void saveSourceFile(const PPath & fileName, const PString & headerName){
62
1/1
✓ Branch 0 (2→3) taken 2 times.
2 std::ofstream fs;
63
1/1
✓ Branch 0 (4→5) taken 2 times.
2 fs.open(fileName.c_str());
64
2/2
✓ Branch 0 (6→7) taken 1 times.
✓ Branch 1 (6→12) taken 1 times.
2 if(!fs.is_open()){
65
4/4
✓ Branch 0 (7→8) taken 1 times.
✓ Branch 2 (8→9) taken 1 times.
✓ Branch 4 (9→10) taken 1 times.
✓ Branch 6 (10→11) taken 1 times.
1 std::cerr << "saveSourceFile : can't open file '" << fileName << "'" << std::endl;
66 1 return;
67 }
68
1/1
✓ Branch 0 (12→13) taken 1 times.
1 licenceSave(fs);
69
10/10
✓ Branch 0 (13→14) taken 1 times.
✓ Branch 2 (14→15) taken 1 times.
✓ Branch 4 (15→16) taken 1 times.
✓ Branch 6 (16→17) taken 1 times.
✓ Branch 8 (17→18) taken 1 times.
✓ Branch 10 (18→19) taken 1 times.
✓ Branch 12 (19→20) taken 1 times.
✓ Branch 14 (20→21) taken 1 times.
✓ Branch 16 (21→22) taken 1 times.
✓ Branch 18 (22→23) taken 1 times.
1 fs << std::endl << "#include \"" << headerName << "\"" << std::endl << std::endl << std::endl << std::endl << std::endl << std::endl;
70
1/1
✓ Branch 0 (23→24) taken 1 times.
1 fs.close();
71 2 }
72
73 ///Fonction qui sauve le fichier header
74 /** @param headerName : header file name
75 * @param sourceName : source file name
76 */
77 2 void saveHeaderSourceFile(const PPath & headerName, const PPath & sourceName){
78 2 saveHeaderFile(headerName);
79 2 saveSourceFile(sourceName, headerName);
80 2 }
81
82
83