Directory: | ./ |
---|---|
File: | src/saveClassConfig.cpp |
Date: | 2025-04-25 19:10:50 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 440 | 454 | 96.9% |
Branches: | 1047 | 1156 | 90.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 "header_generator.h" | ||
9 | #include "saveClassConfig.h" | ||
10 | |||
11 | ///Check if the given type is a simple type | ||
12 | /** @param varType : type to be checked | ||
13 | * @return true if the given type is a simple type, false otherwise | ||
14 | */ | ||
15 | 821 | bool getIsSimpleType(const PString & varType){ | |
16 |
5/5✓ Branch 1 taken 821 times.
✓ Branch 4 taken 821 times.
✓ Branch 7 taken 821 times.
✓ Branch 10 taken 821 times.
✓ Branch 13 taken 821 times.
|
1642 | PString restVarName(varType.replace("unsigned", "").eraseChar(" \n\t*&")); |
17 |
20/22✓ Branch 1 taken 803 times.
✓ Branch 2 taken 18 times.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 38 times.
✓ Branch 7 taken 533 times.
✓ Branch 8 taken 232 times.
✓ Branch 10 taken 477 times.
✓ Branch 11 taken 56 times.
✓ Branch 13 taken 421 times.
✓ Branch 14 taken 56 times.
✓ Branch 16 taken 380 times.
✓ Branch 17 taken 41 times.
✓ Branch 19 taken 371 times.
✓ Branch 20 taken 9 times.
✓ Branch 22 taken 342 times.
✓ Branch 23 taken 29 times.
✓ Branch 25 taken 322 times.
✓ Branch 26 taken 20 times.
✓ Branch 28 taken 322 times.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 322 times.
|
1642 | return (restVarName == "char" || restVarName == "short" || restVarName == "int" || restVarName == "float" || restVarName == "double" || restVarName == "bool" || restVarName == "long" || restVarName == "longint" || restVarName == "size_t" || restVarName == "ssize_t" || restVarName == "void"); |
18 | 821 | } | |
19 | |||
20 | ///Check if the given type is a pointer or not | ||
21 | /** @param varType : type to be checked | ||
22 | * @return true if the given type is a pointer, false otherwise | ||
23 | */ | ||
24 | 71 | bool getIsPointer(const PString & varType){ | |
25 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
|
71 | if(varType.size() == 0lu){return false;} |
26 |
4/4✓ Branch 1 taken 6 times.
✓ Branch 2 taken 65 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
|
71 | return varType.find('*') && varType.back() == '*'; |
27 | } | ||
28 | |||
29 | ///Get the default value of a type in C++ | ||
30 | /** @param type : type to be converted | ||
31 | * @return default value of the type in C++ | ||
32 | */ | ||
33 | 38 | PString getDefaultValueTypeInCpp(const PString & type){ | |
34 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
|
38 | if(type == "PString"){ |
35 | ✗ | return "\"\""; | |
36 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 37 times.
|
38 | }else if(type == "char"){ |
37 | 1 | return "0"; | |
38 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 36 times.
|
37 | }else if(type == "unsigned char"){ |
39 | 1 | return "0"; | |
40 |
8/8✓ Branch 1 taken 24 times.
✓ Branch 2 taken 12 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 1 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 21 times.
✓ Branch 9 taken 15 times.
✓ Branch 10 taken 21 times.
|
36 | }else if(type == "int" || type == "short" || type == "unsigned short"){ |
41 | 15 | return "0"; | |
42 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 19 times.
|
21 | }else if(type == "unsigned int"){ |
43 | 2 | return "0u"; | |
44 |
6/8✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 18 times.
|
19 | }else if(type == "long int" || type == "long" || type == "ssize_t"){ |
45 | 1 | return "0l"; | |
46 |
6/6✓ Branch 1 taken 17 times.
✓ Branch 2 taken 1 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 15 times.
|
18 | }else if(type == "size_t" || type == "long unsigned int"){ |
47 | 3 | return "0lu"; | |
48 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 10 times.
|
15 | }else if(type == "bool"){ |
49 | 5 | return "false"; | |
50 | }else{ | ||
51 | 10 | return ""; | |
52 | } | ||
53 | } | ||
54 | |||
55 | ///Makes the var type by taking account of the type | ||
56 | /** @param varType : variable type name | ||
57 | * @param isSetter : true if the type is made for a setter | ||
58 | * @param isConst : true if the type must be const | ||
59 | * @param isRef : true if the variable is a reference | ||
60 | * @param isPtr : true if te variable is a pointer | ||
61 | * @return var type by taking account of the type | ||
62 | */ | ||
63 | 426 | PString makeVarType(const PString & varType, bool isSetter, bool isConst, bool isRef, bool isPtr){ | |
64 | 426 | PString varTypeName(""); | |
65 | // std::cout << "makeVarType : varType = '" << varType << "'" << std::endl; | ||
66 |
1/1✓ Branch 1 taken 426 times.
|
426 | bool isSimpleType = getIsSimpleType(varType); |
67 |
3/4✓ Branch 0 taken 180 times.
✓ Branch 1 taken 246 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
|
426 | if(isSimpleType || isPtr){ |
68 |
8/9✓ Branch 0 taken 164 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 70 times.
✓ Branch 9 taken 12 times.
|
246 | if(isConst && !isSetter && (!isSimpleType || isPtr)) varTypeName += "const "; |
69 |
1/1✓ Branch 1 taken 246 times.
|
246 | varTypeName += varType; |
70 |
5/5✓ Branch 0 taken 82 times.
✓ Branch 1 taken 164 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 12 times.
✓ Branch 5 taken 70 times.
|
246 | if(isRef && !isPtr) varTypeName += " &"; |
71 | }else{ | ||
72 |
4/5✓ Branch 0 taken 120 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 120 times.
|
180 | if(isConst && !isPtr) varTypeName += "const "; |
73 |
2/2✓ Branch 1 taken 180 times.
✓ Branch 4 taken 180 times.
|
180 | varTypeName += varType + " &"; |
74 | } | ||
75 | 426 | return varTypeName; | |
76 | } | ||
77 | |||
78 | ///Creates a function decl for setters | ||
79 | /** @param varType : type of the var to set | ||
80 | * @param varName : name of the var to set | ||
81 | * @param className : name of the class | ||
82 | * @param isPtr : true if te variable is a pointer | ||
83 | * @return setters function decl | ||
84 | */ | ||
85 | 142 | PString createSetterDecl(const PString & varType, const PString & varName, const PString & className, bool isPtr){ | |
86 | 142 | PString functionDecl("void "); | |
87 |
4/4✓ Branch 1 taken 71 times.
✓ Branch 2 taken 71 times.
✓ Branch 4 taken 71 times.
✓ Branch 7 taken 71 times.
|
142 | if(className != "") functionDecl += className + "::"; |
88 |
4/4✓ Branch 1 taken 142 times.
✓ Branch 4 taken 142 times.
✓ Branch 7 taken 142 times.
✓ Branch 10 taken 142 times.
|
142 | functionDecl += "set" + varName.firstToUpper() + "("; |
89 |
2/2✓ Branch 1 taken 142 times.
✓ Branch 4 taken 142 times.
|
142 | functionDecl += makeVarType(varType, true, true, false, isPtr); |
90 |
3/3✓ Branch 1 taken 142 times.
✓ Branch 4 taken 142 times.
✓ Branch 7 taken 142 times.
|
142 | functionDecl += " " + varName + ")"; |
91 | 142 | return functionDecl; | |
92 | } | ||
93 | |||
94 | ///Creates a function decl for setters | ||
95 | /** @param varType : type of the var to set | ||
96 | * @param varName : name of the var to set | ||
97 | * @param className : name of the class | ||
98 | * @param isConst : true if the function must be const | ||
99 | * @param isPtr : true if te variable is a pointer | ||
100 | * @return setters function decl | ||
101 | */ | ||
102 | 284 | PString createGetterDecl(const PString & varType, const PString & varName, const PString & className, bool isConst, bool isPtr){ | |
103 | 284 | PString functionDecl(""); | |
104 |
3/3✓ Branch 1 taken 284 times.
✓ Branch 4 taken 284 times.
✓ Branch 7 taken 284 times.
|
284 | functionDecl += makeVarType(varType, false, isConst, !isConst, isPtr) + " "; |
105 |
4/4✓ Branch 1 taken 142 times.
✓ Branch 2 taken 142 times.
✓ Branch 4 taken 142 times.
✓ Branch 7 taken 142 times.
|
284 | if(className != "") functionDecl += className + "::"; |
106 |
4/4✓ Branch 1 taken 284 times.
✓ Branch 4 taken 284 times.
✓ Branch 7 taken 284 times.
✓ Branch 10 taken 284 times.
|
284 | functionDecl += "get" + varName.firstToUpper() + "()"; |
107 | 284 | return functionDecl; | |
108 | } | ||
109 | |||
110 | ///Creates setters header file | ||
111 | /** @param[out] fs : header file name | ||
112 | * @param classConfig : class config we want to save | ||
113 | */ | ||
114 | 24 | void saveDeclSetters(std::ofstream & fs, const PClassConfig & classConfig){ | |
115 | 24 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); | |
116 |
2/2✓ Branch 3 taken 71 times.
✓ Branch 4 taken 24 times.
|
95 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
117 |
9/9✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 12 taken 71 times.
✓ Branch 16 taken 71 times.
✓ Branch 19 taken 71 times.
✓ Branch 22 taken 71 times.
✓ Branch 25 taken 71 times.
✓ Branch 28 taken 71 times.
|
71 | fs << "\t\t" << createSetterDecl(it->getType(), it->getName(), "", it->getIsPointer()) << ";" << std::endl; |
118 | } | ||
119 | 24 | } | |
120 | |||
121 | ///Creates getters header file | ||
122 | /** @param[out] fs : header file name | ||
123 | * @param classConfig : class config we want to save | ||
124 | */ | ||
125 | 24 | void saveDeclGetters(std::ofstream & fs, const PClassConfig & classConfig){ | |
126 | 24 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); | |
127 |
2/2✓ Branch 3 taken 71 times.
✓ Branch 4 taken 24 times.
|
95 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
128 |
9/9✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 12 taken 71 times.
✓ Branch 16 taken 71 times.
✓ Branch 19 taken 71 times.
✓ Branch 22 taken 71 times.
✓ Branch 25 taken 71 times.
✓ Branch 28 taken 71 times.
|
71 | fs << "\t\t" << createGetterDecl(it->getType(), it->getName(), "", true, it->getIsPointer()) << " const;" << std::endl; |
129 |
9/9✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 12 taken 71 times.
✓ Branch 16 taken 71 times.
✓ Branch 19 taken 71 times.
✓ Branch 22 taken 71 times.
✓ Branch 25 taken 71 times.
✓ Branch 28 taken 71 times.
|
71 | fs << "\t\t" << createGetterDecl(it->getType(), it->getName(), "", false, it->getIsPointer()) << ";" << std::endl; |
130 | } | ||
131 | 24 | } | |
132 | |||
133 | ///Creates the method which enable to save/load generated class with any kind of stream/message/file | ||
134 | /** @param[out] fs : header file name | ||
135 | * @param classConfig : class config we want to save | ||
136 | */ | ||
137 | 15 | void saveClassDataStreamMethod(std::ofstream & fs, const PClassConfig & classConfig){ | |
138 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | PString name(classConfig.getName()); |
139 |
1/1✓ Branch 1 taken 15 times.
|
15 | fs << std::endl; |
140 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | fs << "\t\t///Load the current "<<name<<" with a stream" << std::endl; |
141 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\t/** @param[out] ds : stream to be used" << std::endl; |
142 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\t * @return true on success, false otherwise" << std::endl; |
143 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\t*/" << std::endl; |
144 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\ttemplate<typename Stream, DataStreamMode::DataStreamMode Mode>" << std::endl; |
145 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\tbool readWriteStream(Stream & ds){" << std::endl; |
146 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\t\tbool b(true);" << std::endl; |
147 | |||
148 |
1/1✓ Branch 1 taken 15 times.
|
15 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); |
149 |
2/2✓ Branch 4 taken 49 times.
✓ Branch 5 taken 15 times.
|
64 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
150 |
8/8✓ Branch 1 taken 49 times.
✓ Branch 5 taken 49 times.
✓ Branch 8 taken 49 times.
✓ Branch 11 taken 49 times.
✓ Branch 15 taken 49 times.
✓ Branch 18 taken 49 times.
✓ Branch 21 taken 49 times.
✓ Branch 24 taken 49 times.
|
49 | fs << "\t\t\tb &= DataStream<Stream, Mode, "<<it->getType()<<" >::data_stream(ds, p_" << it->getName() << ");" << std::endl; |
151 | } | ||
152 | |||
153 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\t\treturn b;" << std::endl; |
154 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
|
15 | fs << "\t\t}" << std::endl << std::endl; |
155 | 15 | } | |
156 | |||
157 | ///Creates the method which enable to save/load generated class with any kind of stream/message/file | ||
158 | /** @param[out] fs : header file name | ||
159 | * @param classConfig : class config we want to save | ||
160 | */ | ||
161 | 15 | void saveClassDataStreamGenericFunction(std::ofstream & fs, const PClassConfig & classConfig){ | |
162 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | PString name(classConfig.getName()); |
163 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | fs << "///@brief Generic "<<name<<" serialisation/deserialisation, load/save and size function" << std::endl; |
164 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "template<typename Stream, DataStreamMode::DataStreamMode Mode>" << std::endl; |
165 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | fs << "struct DataStream<Stream, Mode, "<<name<<">{" << std::endl; |
166 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
|
15 | fs << "\t///Generic function to load/save/serialise/deserialise "<<name << std::endl; |
167 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | fs << "\t/**\t@param data : "<<name<<" to be used" << std::endl; |
168 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t * \t@return true on success, false otherwise" << std::endl; |
169 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t*/" << std::endl; |
170 |
4/4✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
|
15 | fs << "\tstatic bool data_stream(Stream & ds, "<<name<<" & data){" << std::endl; |
171 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t\treturn data.readWriteStream<Stream, Mode>(ds);" << std::endl; |
172 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << "\t}" << std::endl; |
173 |
3/3✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
|
15 | fs << "};" << std::endl << std::endl; |
174 | 15 | } | |
175 | |||
176 | ///Get the template definition in the class declaration | ||
177 | /** @param listTemplate : list of template def | ||
178 | * @return template definition in the class declaration (template< .... >) | ||
179 | */ | ||
180 | 10 | PString getClassDeclTempalteDef(const PVecString & listTemplate){ | |
181 |
1/4✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
10 | if(listTemplate.size() == 0lu){return "";} |
182 |
1/1✓ Branch 1 taken 10 times.
|
10 | PString templateDef("template<"); |
183 |
1/1✓ Branch 1 taken 10 times.
|
10 | PString comma(""); |
184 |
2/2✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
|
20 | for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){ |
185 |
1/1✓ Branch 1 taken 10 times.
|
10 | templateDef += comma; |
186 |
1/1✓ Branch 2 taken 10 times.
|
10 | templateDef += *it; |
187 |
1/1✓ Branch 1 taken 10 times.
|
10 | comma = ", "; |
188 | } | ||
189 |
1/1✓ Branch 1 taken 10 times.
|
10 | templateDef += ">\n"; |
190 |
1/1✓ Branch 1 taken 10 times.
|
10 | return templateDef; |
191 | 10 | } | |
192 | |||
193 | ///Get the template call in the class declaration | ||
194 | /** @param listTemplate : list of template def | ||
195 | * @return template definition in the class declaration (< T, U, .... >) | ||
196 | */ | ||
197 | 6 | PString getClassDefTemplate(const PVecString & listTemplate){ | |
198 |
2/2✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
|
6 | PString defTemplate("<"), comma(""); |
199 |
2/2✓ Branch 4 taken 6 times.
✓ Branch 5 taken 6 times.
|
12 | for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){ |
200 |
3/3✓ Branch 2 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
|
6 | defTemplate += comma + it->split(' ').back(); |
201 |
1/1✓ Branch 1 taken 6 times.
|
6 | comma = ", "; |
202 | } | ||
203 |
1/1✓ Branch 1 taken 6 times.
|
6 | defTemplate += ">"; |
204 | 12 | return defTemplate; | |
205 | 6 | } | |
206 | |||
207 | ///Creates header file | ||
208 | /** @param[out] fs : header file name | ||
209 | * @param classConfig : class config we want to save | ||
210 | * @param enableDataStream : true to enable the serialization/deserialization with DataStream, false otherwise | ||
211 | * @param enableTypeStream : true to enable the phoenix_getTypeName function creation | ||
212 | */ | ||
213 | 1 | void saveEnumDecl(std::ofstream & fs, const PClassConfig & classConfig, bool enableDataStream, bool enableTypeStream){ | |
214 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PString name(classConfig.getName()); |
215 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | fs << "namespace " << name << " {\n"; |
216 |
5/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | if(classConfig.getClassDocumentation() != "") fs << classConfig.getClassDocumentation() << std::endl; |
217 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | fs << "\tenum " << name << " {\n\t\t"; |
218 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString comma(""); |
219 |
1/1✓ Branch 1 taken 1 times.
|
1 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); |
220 |
2/2✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 times.
|
3 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
221 |
2/11✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
|
2 | if(it->getDocumentation() != "") fs << "\t\t" << it->getDocumentation() << std::endl; |
222 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
|
2 | fs << comma << it->getName(); |
223 |
2/3✓ Branch 2 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
|
2 | if(it->getDefaultValue() != ""){ |
224 | ✗ | fs << " = " << it->getDefaultValue(); | |
225 | } | ||
226 |
1/1✓ Branch 1 taken 2 times.
|
2 | comma = ",\n\t\t"; |
227 | } | ||
228 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\n\t};" << std::endl; |
229 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | fs << "}" << std::endl << std::endl; |
230 | |||
231 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(enableDataStream){ |
232 |
8/8✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 taken 1 times.
|
1 | fs << "///@brief Generic "<<name << " deserialisation, load and size function for a "<<name << "::"<<name << "" << std::endl; |
233 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "template<typename Stream>" << std::endl; |
234 |
6/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | fs << "struct DataStream<Stream, DataStreamMode::READ, "<<name << "::"<<name << ">{" << std::endl; |
235 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | fs << "\t///Generic function to load/deserialise "<<name << "" << std::endl; |
236 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t/**\t@param[out] ds : Stream to be used" << std::endl; |
237 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | fs << "\t * \t@param data : "<<name << " to be loaded" << std::endl; |
238 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t * \t@return true on success, false otherwise" << std::endl; |
239 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t*/" << std::endl; |
240 |
6/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | fs << "\tstatic bool data_stream(Stream & ds, "<<name << "::"<<name << " & data){" << std::endl; |
241 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t\tint value(0);" << std::endl; |
242 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t\tbool b = DataStream<Stream, DataStreamMode::READ, int>::data_stream(ds, value);" << std::endl; |
243 |
6/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | fs << "\t\tdata = ("<<name << "::"<<name << ")value;" << std::endl; |
244 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t\treturn b;" << std::endl; |
245 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t}" << std::endl; |
246 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | fs << "};" << std::endl << std::endl; |
247 | |||
248 |
8/8✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 taken 1 times.
|
1 | fs << "///@brief Generic "<<name << " serialisation, save and size function for a "<<name << "::"<<name << "" << std::endl; |
249 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "template<typename Stream>" << std::endl; |
250 |
6/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | fs << "struct DataStream<Stream, DataStreamMode::WRITE, "<<name << "::"<<name << ">{" << std::endl; |
251 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | fs << "\t///Generic function to save/serialise "<<name << "" << std::endl; |
252 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t/**\t@param[out] ds : Stream to be used" << std::endl; |
253 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | fs << "\t * \t@param data : "<<name << " to be saved" << std::endl; |
254 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t * \t@return true on success, false otherwise" << std::endl; |
255 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t*/" << std::endl; |
256 |
6/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | fs << "\tstatic bool data_stream(Stream & ds, "<<name << "::"<<name << " & data){" << std::endl; |
257 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t\tint value = (int)data;" << std::endl; |
258 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t\treturn DataStream<Stream, DataStreamMode::WRITE, int>::data_stream(ds, value);" << std::endl; |
259 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "\t}" << std::endl; |
260 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | fs << "};" << std::endl << std::endl; |
261 | } | ||
262 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if(enableTypeStream){ |
263 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | fs << "///Get the type name of "<<name << std::endl; |
264 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | fs << "/**\t@return type name of "<<name << " as string" << std::endl; |
265 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "*/" << std::endl; |
266 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | fs << "template<>" << std::endl; |
267 |
6/6✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | fs << "std::string phoenix_getTypeName<"<<name<<"::"<<name<<">(){" << std::endl; |
268 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | fs << "\treturn \""<<name<<"\";" << std::endl; |
269 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | fs << "}" << std::endl << std::endl; |
270 | } | ||
271 | 1 | } | |
272 | |||
273 | ///Creates header file | ||
274 | /** @param[out] fs : header file name | ||
275 | * @param classConfig : class config we want to save | ||
276 | * @param enableDataStream : true to enable the serialization/deserialization with DataStream, false otherwise | ||
277 | * @param enableTypeStream : true to enable the phoenix_getTypeName function creation | ||
278 | */ | ||
279 | 24 | void saveClassDecl(std::ofstream & fs, const PClassConfig & classConfig, bool enableDataStream, bool enableTypeStream){ | |
280 |
5/6✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
|
24 | if(classConfig.getClassDocumentation() != "") fs << classConfig.getClassDocumentation() << std::endl; |
281 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | PString name(classConfig.getName()); |
282 |
1/1✓ Branch 1 taken 24 times.
|
24 | const PVecString & listTemplate = classConfig.getListTemplate(); |
283 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
|
24 | if(listTemplate.size() != 0lu){ |
284 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | fs << getClassDeclTempalteDef(listTemplate); |
285 | } | ||
286 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "class " << name; |
287 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
|
24 | if(classConfig.getListParentClass().size() != 0lu){ |
288 |
1/1✓ Branch 1 taken 1 times.
|
1 | PVecString::const_iterator it(classConfig.getListParentClass().begin()); |
289 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 5 taken 1 times.
|
1 | fs << " : public " << *it; |
290 |
2/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | if(classConfig.getListParentClass().size() > 1lu){ |
291 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 times.
|
4 | while(it != classConfig.getListParentClass().end()){ |
292 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
|
3 | fs << ", " << *it; |
293 | 3 | ++it; | |
294 | } | ||
295 | } | ||
296 | } | ||
297 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "{" << std::endl; |
298 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "\tpublic:" << std::endl; |
299 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "\t\t" << name << "();" << std::endl; |
300 |
6/6✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
|
24 | fs << "\t\t" << name << "(const " << name << " & other);" << std::endl; |
301 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "\t\tvirtual ~" << name << "();" << std::endl; |
302 |
6/6✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
|
24 | fs << "\t\t" << name << " & operator = (const " << name << " & other);" << std::endl; |
303 |
1/1✓ Branch 1 taken 24 times.
|
24 | saveDeclSetters(fs, classConfig); |
304 |
1/1✓ Branch 1 taken 24 times.
|
24 | saveDeclGetters(fs, classConfig); |
305 | |||
306 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 9 times.
|
24 | if(enableDataStream){ |
307 |
1/1✓ Branch 1 taken 15 times.
|
15 | saveClassDataStreamMethod(fs, classConfig); |
308 | } | ||
309 | |||
310 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "\tprotected:" << std::endl; |
311 |
6/6✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
|
24 | fs << "\t\tvoid copy" << name << "(const " << name << " & other);" << std::endl; |
312 | |||
313 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "\tprivate:" << std::endl; |
314 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "\t\tvoid initialisation" << name << "();" << std::endl; |
315 |
1/1✓ Branch 1 taken 24 times.
|
24 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); |
316 |
2/2✓ Branch 4 taken 71 times.
✓ Branch 5 taken 24 times.
|
95 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
317 |
6/7✓ Branch 2 taken 71 times.
✓ Branch 5 taken 71 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 71 times.
✓ Branch 12 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 18 taken 71 times.
|
71 | if(it->getDocumentation() != "") fs << "\t\t" << it->getDocumentation() << std::endl; |
318 | |||
319 |
8/8✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 18 taken 71 times.
✓ Branch 21 taken 71 times.
✓ Branch 24 taken 71 times.
|
71 | fs << "\t\t" << it->getType() << " p_" << it->getName() << ";" << std::endl; |
320 | } | ||
321 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "};" << std::endl << std::endl; |
322 | |||
323 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 9 times.
|
24 | if(enableDataStream){ |
324 |
1/1✓ Branch 1 taken 15 times.
|
15 | saveClassDataStreamGenericFunction(fs, classConfig); |
325 |
2/2✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
|
15 | fs << std::endl << std::endl; |
326 | } | ||
327 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 10 times.
|
24 | if(enableTypeStream){ |
328 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 12 times.
|
14 | if(listTemplate.size() != 0lu){ |
329 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | fs << "///Get the name of the class " << name << std::endl; |
330 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | fs << "/**\t@return name of the class " << name << std::endl; |
331 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | fs << "*/" << std::endl; |
332 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | fs << getClassDeclTempalteDef(listTemplate); |
333 |
6/6✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 13 taken 2 times.
✓ Branch 16 taken 2 times.
|
2 | fs << "std::string phoenix_getTypeName<"<<name << getClassDefTemplate(listTemplate) <<" >(){" << std::endl; |
334 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | fs << "\treturn \""<<name<<"\""; |
335 |
1/1✓ Branch 1 taken 2 times.
|
2 | fs << " + \"<\""; |
336 |
2/2✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){ |
337 |
4/4✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 9 taken 2 times.
✓ Branch 12 taken 2 times.
|
2 | fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()"; |
338 | } | ||
339 |
1/1✓ Branch 1 taken 2 times.
|
2 | fs << " + \">\""; |
340 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | fs << ";" << std::endl; |
341 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | fs << "}" << std::endl << std::endl; |
342 | |||
343 | }else{ | ||
344 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | fs << "template<>" << std::endl; |
345 |
5/5✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
|
12 | fs << "std::string phoenix_getTypeName<"<<name<<">();" << std::endl << std::endl; |
346 | } | ||
347 | } | ||
348 | 24 | } | |
349 | |||
350 | ///Saves constructor of the class | ||
351 | /** @param[out] fs : header file name | ||
352 | * @param classConfig : PClassConfig we vant to save | ||
353 | * @param defTemplate : extra template definition for the class name space | ||
354 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
355 | * @param enableTypeStream : true to enable the phoenix_getTypeName function creation | ||
356 | */ | ||
357 | 20 | void saveClassGetTypeNameImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration, bool enableTypeStream){ | |
358 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 12 times.
|
20 | if(!enableTypeStream){return;} |
359 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | PString name(classConfig.getName()); |
360 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | fs << "///Get the name of the class " << name << std::endl; |
361 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | fs << "/**\t@return name of the class " << name << std::endl; |
362 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | fs << "*/" << std::endl; |
363 |
1/1✓ Branch 1 taken 12 times.
|
12 | const PVecString & listTemplate = classConfig.getListTemplate(); |
364 |
1/2✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
|
12 | if(listTemplate.size() == 0lu){ |
365 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | fs << "template<>" << std::endl; |
366 | }else{ | ||
367 | ✗ | fs << templateDeclaration; | |
368 | } | ||
369 |
5/5✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 13 taken 12 times.
|
12 | fs << "std::string phoenix_getTypeName<"<<name << defTemplate <<" >(){" << std::endl; |
370 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | fs << "\treturn \""<<name<<"\""; |
371 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
|
12 | if(listTemplate.size() != 0lu){ |
372 | ✗ | fs << " + \"<\""; | |
373 | ✗ | for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){ | |
374 | ✗ | fs << " + phoenix_getTypeToStr<"<<it->split(' ').back()<<">()"; | |
375 | } | ||
376 | ✗ | fs << " + \">\""; | |
377 | } | ||
378 |
2/2✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
|
12 | fs << ";" << std::endl; |
379 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | fs << "}" << std::endl << std::endl; |
380 | 12 | } | |
381 | |||
382 | ///Saves constructor of the class | ||
383 | /** @param[out] fs : header file name | ||
384 | * @param classConfig : PClassConfig we vant to save | ||
385 | * @param defTemplate : extra template definition for the class name space | ||
386 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
387 | */ | ||
388 | 24 | void saveClassConstructorImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){ | |
389 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | PString name(classConfig.getName()); |
390 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "///Constructor of class " << name << std::endl; |
391 |
1/1✓ Branch 1 taken 24 times.
|
24 | fs << templateDeclaration; |
392 |
5/5✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
|
24 | fs << name << defTemplate << "::" << name << "()"; |
393 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
|
24 | if(classConfig.getListParentClass().size() != 0lu){ |
394 |
1/1✓ Branch 1 taken 1 times.
|
1 | PVecString::const_iterator it(classConfig.getListParentClass().begin()); |
395 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 11 taken 1 times.
|
1 | fs << std::endl << "\t: " << *it << "()"; |
396 |
2/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | if(classConfig.getListParentClass().size() > 1lu){ |
397 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 1 times.
|
4 | while(it != classConfig.getListParentClass().end()){ |
398 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
|
3 | fs << ", " << *it << "()"; |
399 | 3 | ++it; | |
400 | } | ||
401 | } | ||
402 |
1/1✓ Branch 1 taken 1 times.
|
1 | fs << std::endl; |
403 | } | ||
404 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "{" << std::endl; |
405 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "\tinitialisation" << name << "();" << std::endl; |
406 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "}" << std::endl << std::endl; |
407 | 24 | } | |
408 | |||
409 | ///Saves copy constructor of the class | ||
410 | /** @param[out] fs : header file name | ||
411 | * @param classConfig : PClassConfig we vant to save | ||
412 | * @param defTemplate : extra template definition for the class name space | ||
413 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
414 | */ | ||
415 | 24 | void saveClassCopyConstructorImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){ | |
416 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | PString name(classConfig.getName()); |
417 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "///Copy Constructor of class " << name << std::endl; |
418 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "/**\t@param other : " << name << " we want ot copy" << std::endl; |
419 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "*/" << std::endl; |
420 |
1/1✓ Branch 1 taken 24 times.
|
24 | fs << templateDeclaration; |
421 |
9/9✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
✓ Branch 19 taken 24 times.
✓ Branch 22 taken 24 times.
✓ Branch 25 taken 24 times.
|
24 | fs << name << defTemplate << "::" << name << "(const " << name << defTemplate << " & other){" << std::endl; |
422 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "\tcopy" << name << "(other);" << std::endl; |
423 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "}" << std::endl << std::endl; |
424 | 24 | } | |
425 | |||
426 | ///Saves destructor of the class | ||
427 | /** @param[out] fs : header file name | ||
428 | * @param classConfig : PClassConfig we vant to save | ||
429 | * @param defTemplate : extra template definition for the class name space | ||
430 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
431 | */ | ||
432 | 24 | void saveClassDestructorImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){ | |
433 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | PString name(classConfig.getName()); |
434 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "///Destructor of class " << name << std::endl; |
435 |
1/1✓ Branch 1 taken 24 times.
|
24 | fs << templateDeclaration; |
436 |
6/6✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
|
24 | fs << name << defTemplate << "::~" << name << "(){" << std::endl; |
437 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "\t" << std::endl; |
438 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "}" << std::endl << std::endl; |
439 | 24 | } | |
440 | |||
441 | ///Saves = operator of the class | ||
442 | /** @param[out] fs : header file name | ||
443 | * @param classConfig : PClassConfig we vant to save | ||
444 | * @param defTemplate : extra template definition for the class name space | ||
445 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
446 | */ | ||
447 | 24 | void saveClassEqualOperatorImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){ | |
448 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | PString name(classConfig.getName()); |
449 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "///Operator = of class " << name << std::endl; |
450 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "/**\t@param other : " << name << " we want ot copy" << std::endl; |
451 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << " * \t@return copied class " << name << std::endl; |
452 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "*/" << std::endl; |
453 |
1/1✓ Branch 1 taken 24 times.
|
24 | fs << templateDeclaration; |
454 |
11/11✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
✓ Branch 19 taken 24 times.
✓ Branch 22 taken 24 times.
✓ Branch 25 taken 24 times.
✓ Branch 28 taken 24 times.
✓ Branch 31 taken 24 times.
|
24 | fs << name << defTemplate << " & " << name << defTemplate << "::operator =" << " (const " << name << defTemplate << " & other){" << std::endl; |
455 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "\tcopy" << name << "(other);" << std::endl; |
456 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "\treturn *this;" << std::endl; |
457 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "}" << std::endl << std::endl; |
458 | 24 | } | |
459 | |||
460 | ///Saves the class setters implementation | ||
461 | /** @param[out] fs : header file name | ||
462 | * @param classConfig : PClassConfig we want to save | ||
463 | * @param defTemplate : extra template definition for the class name space | ||
464 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
465 | */ | ||
466 | 24 | void saveClassSettersImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){ | |
467 | 24 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); | |
468 |
2/2✓ Branch 4 taken 71 times.
✓ Branch 5 taken 24 times.
|
95 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
469 |
7/7✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 14 taken 71 times.
✓ Branch 17 taken 71 times.
✓ Branch 20 taken 71 times.
|
71 | fs << "///Sets the " << it->getName() << " of the " << classConfig.getName() << std::endl; |
470 |
10/10✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 18 taken 71 times.
✓ Branch 21 taken 71 times.
✓ Branch 24 taken 71 times.
✓ Branch 27 taken 71 times.
✓ Branch 30 taken 71 times.
|
71 | fs << "/**\t@param " << it->getName() << " : " << it->getName() << " of the " << classConfig.getName() << std::endl; |
471 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | fs << "*/" << std::endl; |
472 |
1/1✓ Branch 1 taken 71 times.
|
71 | fs << templateDeclaration; |
473 |
10/10✓ Branch 2 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 19 taken 71 times.
✓ Branch 22 taken 71 times.
✓ Branch 25 taken 71 times.
✓ Branch 28 taken 71 times.
✓ Branch 31 taken 71 times.
|
71 | fs << createSetterDecl(it->getType(), it->getName(), classConfig.getName() + defTemplate, it->getIsPointer()) << "{" << std::endl; |
474 |
8/8✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 18 taken 71 times.
✓ Branch 21 taken 71 times.
✓ Branch 24 taken 71 times.
|
71 | fs << "\tp_" << it->getName() << " = " << it->getName() << ";" << std::endl; |
475 |
3/3✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
✓ Branch 7 taken 71 times.
|
71 | fs << "}" << std::endl << std::endl; |
476 | } | ||
477 | 24 | } | |
478 | |||
479 | ///Saves the class getters implementation | ||
480 | /** @param[out] fs : header file name | ||
481 | * @param classConfig : PClassConfig we vant to save | ||
482 | * @param defTemplate : extra template definition for the class name space | ||
483 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
484 | */ | ||
485 | 24 | void saveClassGettersImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){ | |
486 | 24 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); | |
487 |
2/2✓ Branch 4 taken 71 times.
✓ Branch 5 taken 24 times.
|
95 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
488 |
7/7✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 14 taken 71 times.
✓ Branch 17 taken 71 times.
✓ Branch 20 taken 71 times.
|
71 | fs << "///Gets the " << it->getName() << " of the " << classConfig.getName() << std::endl; |
489 |
7/7✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 14 taken 71 times.
✓ Branch 17 taken 71 times.
✓ Branch 20 taken 71 times.
|
71 | fs << "/**\t@return " << it->getName() << " of the " << classConfig.getName() << std::endl; |
490 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | fs << "*/" << std::endl; |
491 |
1/1✓ Branch 1 taken 71 times.
|
71 | fs << templateDeclaration; |
492 |
10/10✓ Branch 2 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 19 taken 71 times.
✓ Branch 22 taken 71 times.
✓ Branch 25 taken 71 times.
✓ Branch 28 taken 71 times.
✓ Branch 31 taken 71 times.
|
71 | fs << createGetterDecl(it->getType(), it->getName(), classConfig.getName() + defTemplate, true, it->getIsPointer()) << " const{" << std::endl; |
493 |
5/5✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 14 taken 71 times.
|
71 | fs << "\treturn p_" << it->getName() << ";" << std::endl; |
494 |
3/3✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
✓ Branch 7 taken 71 times.
|
71 | fs << "}" << std::endl << std::endl; |
495 |
7/7✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 14 taken 71 times.
✓ Branch 17 taken 71 times.
✓ Branch 20 taken 71 times.
|
71 | fs << "///Gets the " << it->getName() << " of the " << classConfig.getName() << std::endl; |
496 |
7/7✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 14 taken 71 times.
✓ Branch 17 taken 71 times.
✓ Branch 20 taken 71 times.
|
71 | fs << "/**\t@return " << it->getName() << " of the " << classConfig.getName() << std::endl; |
497 |
2/2✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
|
71 | fs << "*/" << std::endl; |
498 |
1/1✓ Branch 1 taken 71 times.
|
71 | fs << templateDeclaration; |
499 |
10/10✓ Branch 2 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 19 taken 71 times.
✓ Branch 22 taken 71 times.
✓ Branch 25 taken 71 times.
✓ Branch 28 taken 71 times.
✓ Branch 31 taken 71 times.
|
71 | fs << createGetterDecl(it->getType(), it->getName(), classConfig.getName() + defTemplate, false, it->getIsPointer()) << "{" << std::endl; |
500 |
5/5✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 14 taken 71 times.
|
71 | fs << "\treturn p_" << it->getName() << ";" << std::endl; |
501 |
3/3✓ Branch 1 taken 71 times.
✓ Branch 4 taken 71 times.
✓ Branch 7 taken 71 times.
|
71 | fs << "}" << std::endl << std::endl; |
502 | } | ||
503 | 24 | } | |
504 | |||
505 | ///Saves the copy function of a class | ||
506 | /** @param[out] fs : header file name | ||
507 | * @param classConfig : PClassConfig we vant to save | ||
508 | * @param defTemplate : extra template definition for the class name space | ||
509 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
510 | */ | ||
511 | 24 | void saveClassCopyFunctionImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){ | |
512 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | PString name(classConfig.getName()); |
513 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "///Copy Function of class " << name << std::endl; |
514 |
4/4✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
|
24 | fs << "/**\t@param other : " << name << " we want ot copy" << std::endl; |
515 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | fs << "*/" << std::endl; |
516 |
1/1✓ Branch 1 taken 24 times.
|
24 | fs << templateDeclaration; |
517 |
10/10✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
✓ Branch 19 taken 24 times.
✓ Branch 22 taken 24 times.
✓ Branch 25 taken 24 times.
✓ Branch 28 taken 24 times.
|
24 | fs << "void " << name << defTemplate << "::copy" << name << "(const " << name << defTemplate << " & other){" << std::endl; |
518 |
1/1✓ Branch 1 taken 24 times.
|
24 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); |
519 |
2/2✓ Branch 4 taken 71 times.
✓ Branch 5 taken 24 times.
|
95 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
520 |
8/8✓ Branch 1 taken 71 times.
✓ Branch 5 taken 71 times.
✓ Branch 8 taken 71 times.
✓ Branch 11 taken 71 times.
✓ Branch 15 taken 71 times.
✓ Branch 18 taken 71 times.
✓ Branch 21 taken 71 times.
✓ Branch 24 taken 71 times.
|
71 | fs << "\tp_" << it->getName() << " = other.p_" << it->getName() << ";" << std::endl; |
521 | } | ||
522 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "}" << std::endl << std::endl; |
523 | 24 | } | |
524 | |||
525 | ///Saves the copy function of a class | ||
526 | /** @param[out] fs : header file name | ||
527 | * @param classConfig : PClassConfig we vant to save | ||
528 | * @param defTemplate : extra template definition for the class name space | ||
529 | * @param templateDeclaration : basic template declaration before each method (template< ... >) | ||
530 | */ | ||
531 | 24 | void saveClassInitialisationFunctionImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, | |
532 | const PString & templateDeclaration) | ||
533 | { | ||
534 |
2/2✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
|
24 | PString name(classConfig.getName()); |
535 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "///Initialisation Function of class " << name << std::endl; |
536 |
1/1✓ Branch 1 taken 24 times.
|
24 | fs << templateDeclaration; |
537 |
7/7✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
✓ Branch 10 taken 24 times.
✓ Branch 13 taken 24 times.
✓ Branch 16 taken 24 times.
✓ Branch 19 taken 24 times.
|
24 | fs << "void " << name << defTemplate << "::initialisation" << name << "(){" << std::endl; |
538 |
1/1✓ Branch 1 taken 24 times.
|
24 | const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute()); |
539 |
2/2✓ Branch 4 taken 71 times.
✓ Branch 5 taken 24 times.
|
95 | for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){ |
540 |
2/3✓ Branch 2 taken 71 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 71 times.
|
71 | if(it->getDefaultValue() != ""){ |
541 | ✗ | fs << "\tp_" << it->getName() << " = "<<it->getDefaultValue()<<";" << std::endl; | |
542 | }else{ | ||
543 |
2/2✓ Branch 2 taken 71 times.
✓ Branch 5 taken 71 times.
|
71 | PString varType(it->getType()); |
544 |
1/1✓ Branch 1 taken 71 times.
|
71 | bool isSimpleType = getIsSimpleType(varType); |
545 |
1/1✓ Branch 1 taken 71 times.
|
71 | bool isPtr(getIsPointer(varType)); |
546 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 68 times.
|
71 | if(isPtr){ |
547 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
✓ Branch 11 taken 3 times.
✓ Branch 14 taken 3 times.
|
3 | fs << "\tp_" << it->getName() << " = NULL;" << std::endl; |
548 |
2/2✓ Branch 0 taken 38 times.
✓ Branch 1 taken 30 times.
|
68 | }else if(isSimpleType){ |
549 |
1/1✓ Branch 1 taken 38 times.
|
38 | PString defaultValue(getDefaultValueTypeInCpp(varType)); |
550 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 2 taken 10 times.
|
38 | if(defaultValue != ""){ |
551 |
7/7✓ Branch 1 taken 28 times.
✓ Branch 5 taken 28 times.
✓ Branch 8 taken 28 times.
✓ Branch 11 taken 28 times.
✓ Branch 14 taken 28 times.
✓ Branch 17 taken 28 times.
✓ Branch 20 taken 28 times.
|
28 | fs << "\tp_" << it->getName() << " = "<<defaultValue<<";" << std::endl; |
552 | } | ||
553 |
2/2✓ Branch 2 taken 1 times.
✓ Branch 3 taken 29 times.
|
68 | }else if(varType == "PString"){ |
554 |
5/5✓ Branch 1 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 11 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | fs << "\tp_" << it->getName() << " = \"\";" << std::endl; |
555 | } | ||
556 | 71 | } | |
557 | } | ||
558 |
3/3✓ Branch 1 taken 24 times.
✓ Branch 4 taken 24 times.
✓ Branch 7 taken 24 times.
|
24 | fs << "}" << std::endl << std::endl; |
559 | 24 | } | |
560 | |||
561 | ///Creates source file | ||
562 | /** @param[out] fs : source file | ||
563 | * @param classConfig : PClassConfig we vant to save | ||
564 | * @param enableTypeStream : true to enable the phoenix_getTypeName function creation | ||
565 | */ | ||
566 | 20 | void saveClassImpl(std::ofstream & fs, const PClassConfig & classConfig, bool enableTypeStream){ | |
567 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassGetTypeNameImpl(fs, classConfig, "", "", enableTypeStream); |
568 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassConstructorImpl(fs, classConfig, "", ""); |
569 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassCopyConstructorImpl(fs, classConfig, "", ""); |
570 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassDestructorImpl(fs, classConfig, "", ""); |
571 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassEqualOperatorImpl(fs, classConfig, "", ""); |
572 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassSettersImpl(fs, classConfig, "", ""); |
573 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassGettersImpl(fs, classConfig, "", ""); |
574 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassCopyFunctionImpl(fs, classConfig, "", ""); |
575 |
2/2✓ Branch 2 taken 20 times.
✓ Branch 5 taken 20 times.
|
20 | saveClassInitialisationFunctionImpl(fs, classConfig, "", ""); |
576 | 20 | } | |
577 | |||
578 | ///Creates header file | ||
579 | /** @param classConfig : class config we want to save | ||
580 | * @param headerFile : header file name | ||
581 | * @param listInclude : list of the include files | ||
582 | * @param enableDataStream : true to enable the serialization/deserialization with DataStream, false otherwise | ||
583 | * @param enableTypeStream : true to enable the phoenix_getTypeName function creation | ||
584 | * @param includeTemplate : include to the template implementation file | ||
585 | * @return true on success, false otherwise | ||
586 | */ | ||
587 | 19 | bool saveClassDecl(const std::vector<PClassConfig> & classConfig, const PPath & headerFile, const PVecPath & listInclude, bool enableDataStream, bool enableTypeStream, | |
588 | const PString & includeTemplate) | ||
589 | { | ||
590 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
|
19 | if(headerFile == "") return false; |
591 |
1/1✓ Branch 1 taken 19 times.
|
19 | std::ofstream fs; |
592 |
1/1✓ Branch 2 taken 19 times.
|
19 | fs.open(headerFile.c_str()); |
593 |
2/3✓ Branch 1 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
|
19 | if(!fs.is_open()){ |
594 | ✗ | std::cerr << "saveClassDecl : can't open file '" << headerFile << "'" << std::endl; | |
595 | ✗ | return false; | |
596 | } | ||
597 |
1/1✓ Branch 1 taken 19 times.
|
19 | licenceSave(fs); |
598 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | PString macroDef(makeMultiIncludeDefineMacro(headerFile.getFileName())); |
599 |
3/3✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
|
19 | fs << "#ifndef " << macroDef << std::endl; |
600 |
4/4✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
✓ Branch 10 taken 19 times.
|
19 | fs << "#define " << macroDef << std::endl << std::endl; |
601 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 2 taken 14 times.
|
19 | if(listInclude.size() != 0lu){ |
602 |
2/2✓ Branch 4 taken 11 times.
✓ Branch 5 taken 5 times.
|
16 | for(PVecPath::const_iterator it(listInclude.begin()); it != listInclude.end(); ++it){ |
603 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 5 taken 11 times.
✓ Branch 8 taken 11 times.
|
11 | fs << "#include " << *it << std::endl; |
604 | } | ||
605 |
1/1✓ Branch 1 taken 5 times.
|
5 | fs << std::endl; |
606 | } | ||
607 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
|
19 | if(enableDataStream){ |
608 |
3/3✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
✓ Branch 7 taken 12 times.
|
12 | fs << "#include \"data_all.h\"" << std::endl << std::endl; |
609 | } | ||
610 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 8 times.
|
19 | if(enableTypeStream){ |
611 |
3/3✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
|
11 | fs << "#include \"phoenix_type_stream.h\"" << std::endl << std::endl; |
612 | } | ||
613 | |||
614 |
2/2✓ Branch 4 taken 25 times.
✓ Branch 5 taken 19 times.
|
44 | for(std::vector<PClassConfig>::const_iterator it(classConfig.begin()); it != classConfig.end(); ++it){ |
615 |
3/3✓ Branch 2 taken 25 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 24 times.
|
25 | if(it->getIsEnum()){ |
616 |
1/1✓ Branch 2 taken 1 times.
|
1 | saveEnumDecl(fs, *it, enableDataStream, enableTypeStream); |
617 | }else{ | ||
618 |
1/1✓ Branch 2 taken 24 times.
|
24 | saveClassDecl(fs, *it, enableDataStream, enableTypeStream); |
619 | } | ||
620 | } | ||
621 | |||
622 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 2 taken 15 times.
|
19 | if(includeTemplate != ""){ |
623 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
|
4 | fs << "#include \""<<includeTemplate<<"\"" << std::endl << std::endl; |
624 | } | ||
625 | |||
626 |
5/5✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
✓ Branch 10 taken 19 times.
✓ Branch 13 taken 19 times.
|
19 | fs << std::endl << std::endl << "#endif" << std::endl << std::endl; |
627 |
1/1✓ Branch 1 taken 19 times.
|
19 | fs.close(); |
628 | 19 | return true; | |
629 | 19 | } | |
630 | |||
631 | ///Creates source file | ||
632 | /** @param classConfig : class config we want to save | ||
633 | * @param sourceFile : source file name | ||
634 | * @param headerFile : header file name | ||
635 | * @param enableTypeStream : true to enable the phoenix_getTypeName function creation | ||
636 | * @return true on success, false otherwise | ||
637 | */ | ||
638 | 15 | bool saveClassImpl(const std::vector<PClassConfig> & classConfig, const PPath & sourceFile, const PPath & headerFile, bool enableTypeStream){ | |
639 |
3/6✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
|
15 | if(sourceFile == "" || headerFile == "") return false; |
640 |
1/1✓ Branch 1 taken 15 times.
|
15 | std::ofstream fs; |
641 |
1/1✓ Branch 2 taken 15 times.
|
15 | fs.open(sourceFile.c_str()); |
642 |
2/3✓ Branch 1 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
|
15 | if(!fs.is_open()){ |
643 | ✗ | std::cerr << "saveClassImpl : can't open file '" << sourceFile << "'" << std::endl; | |
644 | ✗ | return true; | |
645 | } | ||
646 |
1/1✓ Branch 1 taken 15 times.
|
15 | licenceSave(fs); |
647 |
7/7✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
✓ Branch 13 taken 15 times.
✓ Branch 16 taken 15 times.
✓ Branch 19 taken 15 times.
|
15 | fs << std::endl << "#include \"" << headerFile.getFileName() << "\"" << std::endl << std::endl; |
648 |
2/2✓ Branch 4 taken 21 times.
✓ Branch 5 taken 15 times.
|
36 | for(std::vector<PClassConfig>::const_iterator it(classConfig.begin()); it != classConfig.end(); ++it){ |
649 |
3/3✓ Branch 2 taken 21 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 20 times.
|
21 | if(it->getIsEnum()){continue;} |
650 |
1/1✓ Branch 2 taken 20 times.
|
20 | saveClassImpl(fs, *it, enableTypeStream); |
651 | } | ||
652 |
1/1✓ Branch 1 taken 15 times.
|
15 | fs.close(); |
653 | 15 | return true; | |
654 | 15 | } | |
655 | |||
656 | |||
657 | ///Creates template implementation file | ||
658 | /** @param[out] fs : template implementation file | ||
659 | * @param classConfig : PClassConfig we vant to save | ||
660 | */ | ||
661 | 4 | void saveClassTemplate(std::ofstream & fs, const PClassConfig & classConfig){ | |
662 |
1/1✓ Branch 1 taken 4 times.
|
4 | const PVecString & listTemplate = classConfig.getListTemplate(); |
663 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
4 | if(listTemplate.size() == 0lu){return;} |
664 | |||
665 |
1/1✓ Branch 1 taken 4 times.
|
4 | PString defTemplate(getClassDefTemplate(listTemplate)); |
666 |
1/1✓ Branch 1 taken 4 times.
|
4 | PString templateDeclaration(getClassDeclTempalteDef(listTemplate)); |
667 | |||
668 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassConstructorImpl(fs, classConfig, defTemplate, templateDeclaration); |
669 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassCopyConstructorImpl(fs, classConfig, defTemplate, templateDeclaration); |
670 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassDestructorImpl(fs, classConfig, defTemplate, templateDeclaration); |
671 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassEqualOperatorImpl(fs, classConfig, defTemplate, templateDeclaration); |
672 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassSettersImpl(fs, classConfig, defTemplate, templateDeclaration); |
673 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassGettersImpl(fs, classConfig, defTemplate, templateDeclaration); |
674 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassCopyFunctionImpl(fs, classConfig, defTemplate, templateDeclaration); |
675 |
1/1✓ Branch 1 taken 4 times.
|
4 | saveClassInitialisationFunctionImpl(fs, classConfig, defTemplate, templateDeclaration); |
676 | 4 | } | |
677 | |||
678 | ///Creates template implementation file | ||
679 | /** @param classConfig : class config we want to save | ||
680 | * @param sourceFile : source file name | ||
681 | * @param headerFile : header file name | ||
682 | * @return true on success, false otherwise | ||
683 | */ | ||
684 | 4 | bool saveClassTemplate(const std::vector<PClassConfig> & classConfig, const PPath & sourceFile, const PPath & headerFile){ | |
685 |
3/6✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
|
4 | if(sourceFile == "" || headerFile == "") return false; |
686 |
1/1✓ Branch 1 taken 4 times.
|
4 | std::ofstream fs; |
687 |
1/1✓ Branch 2 taken 4 times.
|
4 | fs.open(sourceFile.c_str()); |
688 |
2/3✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
|
4 | if(!fs.is_open()){ |
689 | ✗ | std::cerr << "saveClassTemplate : can't open file '" << sourceFile << "'" << std::endl; | |
690 | ✗ | return true; | |
691 | } | ||
692 |
1/1✓ Branch 1 taken 4 times.
|
4 | licenceSave(fs); |
693 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
8 | PString macroDef(makeMultiIncludeDefineMacro(headerFile.getFileName() + "_IMPL")); |
694 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
|
4 | fs << "#ifndef " << macroDef << std::endl; |
695 |
4/4✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
|
4 | fs << "#define " << macroDef << std::endl << std::endl; |
696 |
7/7✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
|
4 | fs << std::endl << "#include \"" << headerFile.getFileName() << "\"" << std::endl << std::endl; |
697 |
2/2✓ Branch 4 taken 4 times.
✓ Branch 5 taken 4 times.
|
8 | for(std::vector<PClassConfig>::const_iterator it(classConfig.begin()); it != classConfig.end(); ++it){ |
698 |
1/1✓ Branch 2 taken 4 times.
|
4 | saveClassTemplate(fs, *it); |
699 | } | ||
700 |
2/2✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
|
4 | fs << "\n\n#endif\n\n" << std::endl; |
701 |
1/1✓ Branch 1 taken 4 times.
|
4 | fs.close(); |
702 | 4 | return true; | |
703 | 4 | } | |
704 | |||
705 | ///Check if the configuration has source or template to determine if the .cpp or _impl.h files have to be generated | ||
706 | /** @param[out] hasSource : true if the configuration needs .cpp file | ||
707 | * @param[out] hasTemplate : true if the configuration needs _impl.h file | ||
708 | * @param classConfig : class config we want to save | ||
709 | */ | ||
710 | 19 | void checkClassConfig(bool & hasSource, bool & hasTemplate, const std::vector<PClassConfig> & classConfig){ | |
711 | 19 | hasSource = false; | |
712 | 19 | hasTemplate = false; | |
713 |
2/2✓ Branch 3 taken 25 times.
✓ Branch 4 taken 19 times.
|
44 | for(std::vector<PClassConfig>::const_iterator it(classConfig.begin()); it != classConfig.end(); ++it){ |
714 |
1/1✓ Branch 2 taken 25 times.
|
25 | bool isTemplate = it->getListTemplate().size() != 0lu; |
715 | 25 | hasSource |= !isTemplate; | |
716 | 25 | hasTemplate |= isTemplate; | |
717 | } | ||
718 | 19 | } | |
719 | |||
720 | ///Creates header file | ||
721 | /** @param classConfig : class config we want to save | ||
722 | * @param baseFileName : base file name for header or source file | ||
723 | * @param listInclude : list of the include files | ||
724 | * @param enableDataStream : true to enable the serialization/deserialization with DataStream, false otherwise | ||
725 | * @param enableTypeStream : true to enable the phoenix_getTypeName function creation | ||
726 | * @return true on success, false otherwise | ||
727 | */ | ||
728 | 19 | bool saveClassImplDecl(const std::vector<PClassConfig> & classConfig, const PPath & baseFileName, const PVecPath & listInclude, bool enableDataStream, bool enableTypeStream){ | |
729 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
|
19 | if(baseFileName == "") return false; |
730 | 19 | bool hasSource(false), hasTemplate(false); | |
731 |
1/1✓ Branch 1 taken 19 times.
|
19 | checkClassConfig(hasSource, hasTemplate, classConfig); |
732 |
2/2✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
|
19 | PPath includeTemplate(""); |
733 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
|
19 | if(hasTemplate){ |
734 |
5/5✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
|
4 | includeTemplate = PString(baseFileName.getFileName() + "_impl.h"); |
735 | } | ||
736 | |||
737 |
5/6✓ Branch 1 taken 19 times.
✓ Branch 4 taken 19 times.
✓ Branch 7 taken 19 times.
✓ Branch 10 taken 19 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 19 times.
|
19 | if(!saveClassDecl(classConfig, PString(baseFileName + ".h"), listInclude, enableDataStream, enableTypeStream, includeTemplate)) return false; |
738 | |||
739 |
2/2✓ Branch 0 taken 15 times.
✓ Branch 1 taken 4 times.
|
19 | if(hasSource){ |
740 |
10/11✓ Branch 1 taken 15 times.
✓ Branch 4 taken 15 times.
✓ Branch 7 taken 15 times.
✓ Branch 10 taken 15 times.
✓ Branch 13 taken 15 times.
✓ Branch 16 taken 15 times.
✓ Branch 19 taken 15 times.
✓ Branch 22 taken 15 times.
✓ Branch 25 taken 15 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 15 times.
|
15 | if(!saveClassImpl(classConfig, PPath(baseFileName + PString(".cpp")), PPath(baseFileName + PString(".h")), enableTypeStream)) return false; |
741 | } | ||
742 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
|
19 | if(hasTemplate){ |
743 |
10/11✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✓ Branch 10 taken 4 times.
✓ Branch 13 taken 4 times.
✓ Branch 16 taken 4 times.
✓ Branch 19 taken 4 times.
✓ Branch 22 taken 4 times.
✓ Branch 25 taken 4 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 4 times.
|
4 | if(!saveClassTemplate(classConfig, PPath(baseFileName + PString("_impl.h")), PPath(baseFileName + PString(".h")))) return false; |
744 | } | ||
745 | 19 | return true; | |
746 | 19 | } | |
747 | |||
748 | |||
749 |