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