PhoenixGenerator  2.0.4
Set of tools to generate code
Loading...
Searching...
No Matches
generator_class_cpp.cpp
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#include "phoenix_color.h"
8#include "openFileStream.h"
9#include "header_generator.h"
10#include "cmakelist_generator.h"
11#include "generator_class_cpp.h"
12
14
17bool class_getIsPointer(const PString & varType){
18 if(varType.size() == 0lu){return false;}
19 return varType.find('*') && varType.back() == '*';
20}
21
23
26PString class_getClassDefTemplate(const PVecString & listTemplate){
27 if(listTemplate.size() == 0lu){return "";}
28 PString defTemplate("<"), comma("");
29 for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
30 PVecString vecPart = it->split(' ');
31 if(vecPart.size() != 0lu){
32 defTemplate += comma + vecPart.back();
33 comma = ", ";
34 }
35 }
36 defTemplate += ">";
37 return defTemplate;
38}
39
41
44PString class_getClassDeclTempalteDef(const PVecString & listTemplate){
45 if(listTemplate.size() == 0lu){return "";}
46 PString templateDef("template<");
47 PString comma("");
48 for(PVecString::const_iterator it(listTemplate.begin()); it != listTemplate.end(); ++it){
49 templateDef += comma;
50 templateDef += *it;
51 comma = ", ";
52 }
53 templateDef += ">\n";
54 return templateDef;
55}
56
58
63void class_saveClassConstructorImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){
64 PString name(classConfig.getName());
65 fs << "///Constructor of class " << name << std::endl;
66 fs << templateDeclaration;
67 fs << name << defTemplate << "::" << name << "()";
68 if(classConfig.getListParentClass().size() != 0lu){
69 PVecString::const_iterator it(classConfig.getListParentClass().begin());
70 fs << std::endl << "\t: " << *it << "()";
71 if(classConfig.getListParentClass().size() > 1lu){
72 while(it != classConfig.getListParentClass().end()){
73 fs << ", " << *it << "()";
74 ++it;
75 }
76 }
77 fs << std::endl;
78 }
79 fs << "{" << std::endl;
80 fs << "\tinitialisation" << name << "();" << std::endl;
81 fs << "}" << std::endl << std::endl;
82}
83
84
86
91void class_saveClassDestructorImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){
92 PString name(classConfig.getName());
93 fs << "///Destructor of class " << name << std::endl;
94 fs << templateDeclaration;
95 fs << name << defTemplate << "::~" << name << "(){" << std::endl;
96 fs << "\t" << std::endl;
97 fs << "}" << std::endl << std::endl;
98}
99
101
106void class_saveClassInitialisationFunctionImpl(std::ofstream & fs, const PClassConfig & classConfig, const PString & defTemplate, const PString & templateDeclaration){
107 PString name(classConfig.getName());
108 fs << "///Initialisation Function of class " << name << std::endl;
109 fs << templateDeclaration;
110 fs << "void " << name << defTemplate << "::initialisation" << name << "(){" << std::endl;
111 const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute());
112 for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){
113 if(it->getDefaultValue() != ""){
114 fs << "\tp_" << it->getName() << " = "<<it->getDefaultValue()<<";" << std::endl;
115 }else{
116 PString varType(it->getType());
117 bool isSimpleType = getIsSimpleType(varType);
118 bool isPtr(class_getIsPointer(varType));
119 if(isPtr){
120 fs << "\tp_" << it->getName() << " = NULL;" << std::endl;
121 }else if(isSimpleType){
122 PString defaultValue(getDefaultValueTypeInCpp(varType));
123 if(defaultValue != ""){
124 fs << "\tp_" << it->getName() << " = "<<defaultValue<<";" << std::endl;
125 }
126 }else if(varType == "PString"){
127 fs << "\tp_" << it->getName() << " = \"\";" << std::endl;
128 }
129 }
130 }
131 fs << "}" << std::endl << std::endl;
132}
133
135
138bool generator_checkDefaultValueExist(const std::vector<PClassAttribute> & vecAttr){
139 bool hasDefaultValue = false;
140 for(std::vector<PClassAttribute>::const_iterator it(vecAttr.begin()); it != vecAttr.end() && !hasDefaultValue; ++it){
141 hasDefaultValue |= it->getDefaultValue() != "";
142 }
143 return hasDefaultValue;
144}
145
147
152void generator_enum_cpp_header(const PTraitBackendManager & manager, std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode){
153 if(classConfig.getClassDocumentation() != "") fs << classConfig.getClassDocumentation() << std::endl;
154 PString name(classConfig.getName());
155 fs << "namespace " << name << " {\n";
156 if(classConfig.getClassDocumentation() != ""){fs << "\t"<< classConfig.getClassDocumentation() << std::endl;}
157 fs << "\tenum " << name << " {\n\t\t";
158 const std::vector<PClassAttribute> & vecAttr(classConfig.getListAttribute());
159 bool isDefaultCounterActivated = !generator_checkDefaultValueExist(vecAttr);
160 PString comma("");
161 size_t i(0lu);
162 for(std::vector<PClassAttribute>::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
163 if(it->getDocumentation() != "") fs << "\t\t" << it->getDocumentation() << std::endl;
164 fs << comma << it->getName();
165 if(isDefaultCounterActivated){
166 fs << " = " << i;
167 }else if(it->getDefaultValue() != ""){
168 fs << " = " << it->getDefaultValue();
169 }
170 comma = ",\n\t\t";
171 ++i;
172 }
173 fs << "\n\t};" << std::endl;
174 fs << "}" << std::endl << std::endl;
175 manager.classExtraFunctionDeclaration(fs, classConfig, mode);
176 fs << std::endl << std::endl;
177}
178
179
181
186void generator_class_cpp_header(const PTraitBackendManager & manager, std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode){
187 if(classConfig.getClassDocumentation() != "") fs << classConfig.getClassDocumentation() << std::endl;
188 PString name(classConfig.getName());
189 GeneratorMode classMode(mode);
190 const PVecString & listTemplate = classConfig.getListTemplate();
191 PString defTemplate(class_getClassDefTemplate(listTemplate));
192 PString templateDeclaration(class_getClassDeclTempalteDef(listTemplate));
193 classMode.defTemplate = defTemplate;
194 classMode.templateDeclaration = templateDeclaration;
195
196 fs << classMode.templateDeclaration;
197 fs << "class " << name;
198 if(classConfig.getListParentClass().size() != 0lu){
199 PVecString::const_iterator it(classConfig.getListParentClass().begin());
200 fs << " : public " << *it;
201 if(classConfig.getListParentClass().size() > 1lu){
202 while(it != classConfig.getListParentClass().end()){
203 fs << ", " << *it;
204 ++it;
205 }
206 }
207 }
208 fs << "{" << std::endl;
209 fs << "\tpublic:" << std::endl;
210 fs << "\t\t" << name << "();" << std::endl;
211 fs << "\t\tvirtual ~" << name << "();" << std::endl;
212
213 manager.publicMethodDeclaration(fs, classConfig, classMode);
214 fs << "\tprotected:" << std::endl;
215 manager.protectedMethodDeclaration(fs, classConfig, classMode);
216
217 fs << "\tprivate:" << std::endl;
218 fs << "\t\tvoid initialisation" << name << "();" << std::endl;
219 manager.privateMethodDeclaration(fs, classConfig, classMode);
220 const std::vector<PClassAttribute> & listAttr(classConfig.getListAttribute());
221 for(std::vector<PClassAttribute>::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){
222 if(it->getDocumentation() != "") fs << "\t\t" << it->getDocumentation() << std::endl;
223
224 fs << "\t\t" << it->getType() << " p_" << it->getName() << ";" << std::endl;
225 }
226 fs << "};" << std::endl << std::endl;
227 manager.classExtraFunctionDeclaration(fs, classConfig, classMode);
228 fs << std::endl << std::endl;
229}
230
232
240bool generator_class_cpp_headerFile(const PTraitBackendManager & manager, const PPath & headerFile, const std::vector<PClassConfig> & vecClassConfig, const GeneratorMode & mode,
241 const PVecPath & vecInclude, const PString & includeTemplate)
242{
243 if(headerFile == "") return false;
244 std::ofstream fs;
245 if(!openFileStream(fs, headerFile)){return false;}
246 licenceSave(fs);
247 PString macroDef(makeMultiIncludeDefineMacro(headerFile.getFileName()));
248 fs << "#ifndef " << macroDef << std::endl;
249 fs << "#define " << macroDef << std::endl << std::endl;
250 fs << "#include <string>" << std::endl;
251 if(vecInclude.size() != 0lu){
252 for(PVecPath::const_iterator it(vecInclude.begin()); it != vecInclude.end(); ++it){
253 fs << "#include " << *it << std::endl;
254 }
255 fs << std::endl;
256 }
257 manager.headerExtraInclude(fs, mode);
258 fs << std::endl;
259 for(std::vector<PClassConfig>::const_iterator it(vecClassConfig.begin()); it != vecClassConfig.end(); ++it){
260 if(it->getIsEnum()){
261 generator_enum_cpp_header(manager, fs, *it, mode);
262// saveEnumDecl(fs, *it, mode);
263 }else{
264 generator_class_cpp_header(manager, fs, *it, mode);
265 }
266 }
267
268 if(includeTemplate != ""){
269 fs << "#include \""<<includeTemplate<<"\"" << std::endl << std::endl;
270 }
271
272 fs << std::endl << std::endl << "#endif" << std::endl << std::endl;
273 fs.close();
274 return true;
275}
276
278
283void generator_class_cpp_source(const PTraitBackendManager & manager, std::ofstream & fs, const PClassConfig & classConfig, const GeneratorMode & mode){
284 manager.classExtraFunctionImplementation(fs, classConfig, mode);
285 GeneratorMode classMode(mode);
286 const PVecString & listTemplate = classConfig.getListTemplate();
287 PString defTemplate(class_getClassDefTemplate(listTemplate));
288 PString templateDeclaration(class_getClassDeclTempalteDef(listTemplate));
289 classMode.defTemplate = defTemplate;
290 classMode.templateDeclaration = templateDeclaration;
291 if(!classConfig.getIsEnum()){
292 class_saveClassConstructorImpl(fs, classConfig, defTemplate, templateDeclaration);
293 class_saveClassDestructorImpl(fs, classConfig, defTemplate, templateDeclaration);
294 }
295 manager.publicMethodImplementation(fs, classConfig, classMode);
296 manager.protectedMethodImplementation(fs, classConfig, classMode);
297 manager.privateMethodImplementation(fs, classConfig, classMode);
298 if(!classConfig.getIsEnum()){
299 class_saveClassInitialisationFunctionImpl(fs, classConfig, defTemplate, templateDeclaration);
300 }
301}
302
304
312bool generator_class_cpp_sourceFile(const PTraitBackendManager & manager, const PPath & sourceFile, const PPath & headerFile,
313 const std::vector<PClassConfig> & vecClassConfig, const GeneratorMode & mode, bool isTemplateImpl)
314{
315 if(sourceFile == "" || headerFile == "") return false;
316 std::ofstream fs;
317 if(!openFileStream(fs, sourceFile)){return false;}
318 licenceSave(fs);
319 if(isTemplateImpl){
320 PString macroDef(makeMultiIncludeDefineMacro(headerFile.getFileName() + "_IMPL"));
321 fs << "#ifndef " << macroDef << std::endl;
322 fs << "#define " << macroDef << std::endl << std::endl;
323 }
324 fs << std::endl << "#include \"" << headerFile.getFileName() << "\"" << std::endl << std::endl;
325 for(std::vector<PClassConfig>::const_iterator it(vecClassConfig.begin()); it != vecClassConfig.end(); ++it){
326 generator_class_cpp_source(manager, fs, *it, mode);
327 }
328 if(isTemplateImpl){
329 fs << "#endif" << std::endl << std::endl;
330 }
331 fs.close();
332
333 return true;
334}
335
336
337
339
343void class_checkClassConfig(bool & hasSource, bool & hasTemplate, const std::vector<PClassConfig> & vecClassConfig){
344 hasSource = false;
345 hasTemplate = false;
346 for(std::vector<PClassConfig>::const_iterator it(vecClassConfig.begin()); it != vecClassConfig.end(); ++it){
347 bool isTemplate = it->getListTemplate().size() != 0lu;
348 hasSource |= !isTemplate;
349 hasTemplate |= isTemplate;
350 }
351}
352
354
361bool generator_class_cpp(const PTraitBackendManager & manager, const std::vector<PClassConfig> & vecClassConfig, const PPath & outputSourceDir, const PPath & baseFileName, const GeneratorMode & mode, const PVecPath & vecInclude){
362 if(baseFileName == ""){
363 std::cerr << termRed() << "generator_class_cpp : baseFileName is empty" << termDefault() << std::endl;
364 return false;
365 }
366 bool hasSource(false), hasTemplate(false);
367 class_checkClassConfig(hasSource, hasTemplate, vecClassConfig);
368 PString includeTemplate("");
369 if(hasTemplate){
370 includeTemplate = PString(baseFileName.getFileName() + "_impl.h");
371 }
372 PPath headerFile = outputSourceDir / PPath(baseFileName + ".h");
373 if(!generator_class_cpp_headerFile(manager, headerFile, vecClassConfig, mode, vecInclude, includeTemplate)){
374 std::cerr << termRed() << "generator_class_cpp : cannot generate header file '"<<headerFile<<"'" << termDefault() << std::endl;
375 return false;
376 }
377 if(hasSource){
378 PPath sourceFile = outputSourceDir / PPath(baseFileName + PString(".cpp"));
379 if(!generator_class_cpp_sourceFile(manager, sourceFile, PPath(baseFileName + PString(".h")), vecClassConfig, mode, false)){
380 std::cerr << termRed() << "generator_class_cpp : cannot generate source file '"<<sourceFile<<"'" << termDefault() << std::endl;
381 return false;
382 }
383 }
384 if(hasTemplate){
385 PPath implFile = outputSourceDir / PPath(baseFileName + PString("_impl.h"));
386 if(!generator_class_cpp_sourceFile(manager, implFile, PPath(baseFileName + PString(".h")), vecClassConfig, mode, true)){
387 std::cerr << termRed() << "generator_class_cpp : cannot generate impl file '"<<implFile<<"'" << termDefault() << std::endl;
388 return false;
389 }
390 }
391 return true;
392}
393
394
396
403bool generator_class_testMain(const PTraitBackendManager & manager, const PPath & outputCurrentTestDir, const PClassConfig & classConfig, const PPath & baseFileName, const GeneratorMode & mode){
404 std::ofstream fs;
405 if(!openFileStream(fs, PPath(outputCurrentTestDir + PString("/main.cpp")))){return false;}
406 licenceSave(fs);
407// body += licenceSaveStr() + "\n";
408 if(mode.assertInclude != ""){
409 fs << "#include \"" + mode.assertInclude + "\"\n\n";
410 }
411 fs << "#include \"" + baseFileName + ".h\"\n\n";
412 manager.testFunction(fs, classConfig, mode);
413 fs << "int main(int argc, char ** argv){\n";
414 //Do other test if the enableDataStream is true
415 manager.testCallFunction(fs, classConfig, mode);
416 fs << "\treturn 0;\n";
417 fs << "}\n";
418 fs.close();
419 return true;
420}
421
423
429bool generator_class_testCMakeLists( const PPath & outputCurrentTestDir, const PClassConfig & classConfig, const PString & projectName, const GeneratorMode & mode){
430 PString body(""), testName("test_class_" + classConfig.getName().toLowerUnderscore());
431 body += getCMakeListsHeader();
432 body += "add_executable("+testName+" main.cpp)\n";
433 body += "target_link_libraries("+testName+" ${"+projectName.toUpper()+"_TEST_DEPENDENCIES})\n";
434 body += "\n";
435 body += "add_test(NAME "+testName.firstToUpper()+"\n";
436 body += "\tCOMMAND ${CMAKE_CURRENT_BINARY_DIR}/"+testName+"\n";
437 body += "\tWORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}\n";
438 body += ")\n\n\n";
439 return PPath(outputCurrentTestDir + PString("/CMakeLists.txt")).saveFileContent(body);
440}
441
443
451bool generator_class_test(const PTraitBackendManager & manager, const PPath & outputTestDir, const PClassConfig & classConfig, const PString & projectName, const PPath & baseFileName, const GeneratorMode & mode){
452 PString name(classConfig.getName());
453 PPath outputCurrentTestDir(outputTestDir + PString("/TEST_") + name.toUpper());
454 if(!outputCurrentTestDir.createDirectory()){std::cerr << "generator_class_test : cannot create TEST directory '"<<outputCurrentTestDir<<"'" << std::endl;return false;}
455
456 bool b(true);
457 b &= generator_class_testCMakeLists(outputCurrentTestDir, classConfig, projectName, mode);
458 b &= generator_class_testMain(manager, outputCurrentTestDir, classConfig, baseFileName, mode);
459 return b;
460}
461
463
471bool generator_class_cpp_test(const PTraitBackendManager & manager, const PPath & outputTestDir, const std::vector<PClassConfig> & vecClassConfig, const PString & projectName, const PPath & baseFileName, const GeneratorMode & mode){
472 PString cmakeListBody;
473 cmakeListBody += getCMakeListsHeader();
474 bool b(true);
475 cmakeListBody += "#Generating tests for " + PString::toString(vecClassConfig.size()) + "\n";
476 for(std::vector<PClassConfig>::const_iterator it(vecClassConfig.begin()); it != vecClassConfig.end(); ++it){
477 cmakeListBody += "add_subdirectory(TEST_" + it->getName().toUpper() + ")\n";
478 b &= generator_class_test(manager, outputTestDir, *it, projectName, baseFileName, mode);
479 }
480 cmakeListBody += "\n\n";
481 PPath cmakelist(outputTestDir / PPath("CMakeLists.txt"));
482 b &= cmakelist.saveFileContent(cmakeListBody);
483 return b;
484}
485
487
491bool generator_class_full(const PTraitBackendManager & manager, const ProjectParam & projectParam){
492 bool b(true);
493 b &= projectParam.outputSourceDir.createDirectory();
494 b &= projectParam.outputTestDir.createDirectory();
495 PString cmakeListBody;
496 cmakeListBody += getCMakeListsHeader();
497 const PVecDataConfig & vecDataConfig = projectParam.vecDataConfig;
498 for(const PDataConfig & config : vecDataConfig){
499 PPath baseFileName = config.getFileName().getFileName().eraseExtension();
500 if(!generator_class_cpp(manager, config.getVecClassConfig(), projectParam.outputSourceDir, baseFileName, projectParam.mode, config.getVecInclude())){
501 std::cerr << termRed() << "generator_class_full : cannot generate C++ sources at '"<<projectParam.outputSourceDir<<"'" << termDefault() << std::endl;
502 b = false; //best effort strategy
503 }
504 PPath outputCurrentTestDir = projectParam.outputTestDir / PPath("TEST_" + config.getFileName().getFileName().eraseExtension().toUpper());
505 cmakeListBody += "add_subdirectory(" + outputCurrentTestDir.getFileName() + ")\n";
506 if(!generator_class_cpp_test(manager, outputCurrentTestDir, config.getVecClassConfig(), projectParam.name, baseFileName, projectParam.mode)){
507 std::cerr << termRed() << "generator_class_full : cannot generate C++ tests at '"<<projectParam.outputTestDir<<"'" << termDefault() << std::endl;
508 b = false; //best effort strategy
509 }
510 }
511 cmakeListBody += "\n\n";
512 PPath cmakelist(projectParam.outputTestDir / PPath("CMakeLists.txt"));
513 b &= cmakelist.saveFileContent(cmakeListBody);
514 return b;
515}
516
517
518
519
std::vector< PDataConfig > PVecDataConfig
Definition PDataConfig.h:48
Class to describe a basic class.
const PString & getClassDocumentation() const
Returns the class documentation.
const std::vector< PClassAttribute > & getListAttribute() const
Returns the list of attributes of the class.
const PVecString & getListTemplate() const
Returns the list of the template of the class.
const PString & getName() const
Returns the class name.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
const PVecString & getListParentClass() const
Returns the list of the parents of the class.
Class to describe a basic class.
Definition PDataConfig.h:17
Manager of the Trait backends.
void protectedMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of protected methods.
void classExtraFunctionDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of extra functions.
void testCallFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Call of the test function.
void classExtraFunctionImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of extra functions.
void headerExtraInclude(std::ofstream &fs, const GeneratorMode &mode) const
Add extra include on the header.
void privateMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of private methods.
void protectedMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of protected methods.
void privateMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of private methods.
void publicMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of public methods.
void publicMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of public methods.
void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of test function.
PString getCMakeListsHeader()
Get the CMakeLists.txt header.
bool generator_checkDefaultValueExist(const std::vector< PClassAttribute > &vecAttr)
Check if the vector of PClassAttribute has default value.
PString class_getClassDefTemplate(const PVecString &listTemplate)
Get the template call in the class declaration.
void generator_class_cpp_source(const PTraitBackendManager &manager, std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode)
Create the implementation of the given class.
void class_saveClassDestructorImpl(std::ofstream &fs, const PClassConfig &classConfig, const PString &defTemplate, const PString &templateDeclaration)
Saves destructor of the class.
void generator_class_cpp_header(const PTraitBackendManager &manager, std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode)
Create the declaration of the given class.
bool generator_class_cpp(const PTraitBackendManager &manager, const std::vector< PClassConfig > &vecClassConfig, const PPath &outputSourceDir, const PPath &baseFileName, const GeneratorMode &mode, const PVecPath &vecInclude)
Creates header and source files.
PString class_getClassDeclTempalteDef(const PVecString &listTemplate)
Get the template definition in the class declaration.
bool generator_class_test(const PTraitBackendManager &manager, const PPath &outputTestDir, const PClassConfig &classConfig, const PString &projectName, const PPath &baseFileName, const GeneratorMode &mode)
Save the unit test of the generated PClassConfig.
bool generator_class_cpp_sourceFile(const PTraitBackendManager &manager, const PPath &sourceFile, const PPath &headerFile, const std::vector< PClassConfig > &vecClassConfig, const GeneratorMode &mode, bool isTemplateImpl)
Create the implementation of the given file.
void class_saveClassConstructorImpl(std::ofstream &fs, const PClassConfig &classConfig, const PString &defTemplate, const PString &templateDeclaration)
Saves constructor of the class.
void class_saveClassInitialisationFunctionImpl(std::ofstream &fs, const PClassConfig &classConfig, const PString &defTemplate, const PString &templateDeclaration)
Saves the copy function of a class.
bool generator_class_cpp_test(const PTraitBackendManager &manager, const PPath &outputTestDir, const std::vector< PClassConfig > &vecClassConfig, const PString &projectName, const PPath &baseFileName, const GeneratorMode &mode)
Save the unit test of the generated PClassConfig.
void class_checkClassConfig(bool &hasSource, bool &hasTemplate, const std::vector< PClassConfig > &vecClassConfig)
Check if the configuration has source or template to determine if the .cpp or _impl....
bool class_getIsPointer(const PString &varType)
Check if the given type is a pointer or not.
bool generator_class_full(const PTraitBackendManager &manager, const ProjectParam &projectParam)
Generate the full sources and related unit tests from configuration.
bool generator_class_cpp_headerFile(const PTraitBackendManager &manager, const PPath &headerFile, const std::vector< PClassConfig > &vecClassConfig, const GeneratorMode &mode, const PVecPath &vecInclude, const PString &includeTemplate)
Create the declaration of the given class.
bool generator_class_testMain(const PTraitBackendManager &manager, const PPath &outputCurrentTestDir, const PClassConfig &classConfig, const PPath &baseFileName, const GeneratorMode &mode)
Save the CMakeLists to be used to compile the unit test.
void generator_enum_cpp_header(const PTraitBackendManager &manager, std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode)
Create the declaration of the given class.
bool generator_class_testCMakeLists(const PPath &outputCurrentTestDir, const PClassConfig &classConfig, const PString &projectName, const GeneratorMode &mode)
Save the CMakeLists to be used to compile the unit test.
PString makeMultiIncludeDefineMacro(const PString &fileName)
Create the macro of multi inclusion file name.
void licenceSave(std::ofstream &fs)
Saves the policy.
All the genertor modes.
PString defTemplate
Template definition for the class header.
PString assertInclude
Include of the assert to be used.
PString templateDeclaration
Template declaration of the method implementation.
Set of parameters to generate a project.
GeneratorMode mode
Mode to be used to generate the project.
PPath outputTestDir
Output path of the unit tests.
PVecDataConfig vecDataConfig
Configuration of classes to be generated.
PString name
Name of the project.
PPath outputSourceDir
Output path of the sources.
PString getDefaultValueTypeInCpp(const PString &type)
Get the default value of a type in C++.
bool getIsSimpleType(const PString &varType)
Check if the given type is a simple type.