17 PString name(classConfig.
getName()), strConst(
"");
21 fs <<
"///Check the equality between two "+name+
" classes\n";
22 fs <<
"/**\t@param var : variable to be checked\n";
23 fs <<
" * \t@param reference : reference\n";
24 fs <<
" * \t@return true on success, false otherwise\n";
26 fs <<
"bool check"+name+
"Equality";
30 fs <<
"(" + strConst + name +
" & var, " + strConst + name +
" & reference){\n";
31 fs <<
"\tbool b(true);\n";
33 for(PVecClassAttribute::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){
34 PString attrName(it->getName().firstToUpper());
37 if(isSimpleType || it->getIsPointer() || it->getType() ==
"PString"){
38 fs <<
"\tb &= var.get"+attrName+
"() == reference.get"+attrName+
"();\n";
41 fs <<
"\treturn b;\n";
51 PString name(classConfig.
getName());
52 fs <<
"///Check copy of class "+name+
"\n";
53 fs <<
"void check"+name+
"Copy(){\n";
54 fs <<
"\t"+name+
" reference;\n";
55 fs <<
"\t//Let's use the setters\n";
57 for(PVecClassAttribute::const_iterator it(listAttr.begin()); it != listAttr.end(); ++it){
59 if(defaultValue !=
""){
60 fs <<
"\treference.set"+attrName+
"("+defaultValue+
");\n";
63 fs <<
"\t"+name+
" varCopy(reference);\n";
64 fs <<
"\t"+name+
" varEqual;\n";
65 fs <<
"\tvarEqual = reference;\n";
66 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"Equality(varCopy, reference));\n";
67 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"EqualityConst(varCopy, reference));\n";
68 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"Equality(varEqual, reference));\n";
69 fs <<
"\t"<<mode.
assertCall<<
"(check"+name+
"EqualityConst(varEqual, reference));\n";
88 PString name(classConfig.
getName());
89 fs <<
"\t\t" << name <<
"(const " << name << mode.
defTemplate <<
" & other);" << std::endl;
90 fs <<
"\t\t" << name <<
" & operator = (const " << name << mode.
defTemplate <<
" & other);" << std::endl;
100 PString name(classConfig.
getName());
101 fs <<
"///Copy Constructor of class " << name << std::endl;
102 fs <<
"/**\t@param other : " << name <<
" we want ot copy" << std::endl;
103 fs <<
"*/" << std::endl;
105 fs << name << mode.
defTemplate <<
"::" << name <<
"(const " << name << mode.
defTemplate <<
" & other){" << std::endl;
106 fs <<
"\tcopy" << name <<
"(other);" << std::endl;
107 fs <<
"}" << std::endl << std::endl;
108 fs <<
"///Operator = of class " << name << std::endl;
109 fs <<
"/**\t@param other : " << name <<
" we want ot copy" << std::endl;
110 fs <<
" * \t@return copied class " << name << std::endl;
111 fs <<
"*/" << std::endl;
114 fs <<
"\tcopy" << name <<
"(other);" << std::endl;
115 fs <<
"\treturn *this;" << std::endl;
116 fs <<
"}" << std::endl << std::endl;
126 PString name(classConfig.
getName());
127 fs <<
"\t\tvoid copy" << name <<
"(const " << name << mode.
defTemplate <<
" & other);" << std::endl;
137 PString name(classConfig.
getName());
138 fs <<
"///Copy Function of class " << name << std::endl;
139 fs <<
"/**\t@param other : " << name <<
" we want ot copy" << std::endl;
140 fs <<
"*/" << std::endl;
142 fs <<
"void " << name << mode.
defTemplate <<
"::copy" << name <<
"(const " << name << mode.
defTemplate <<
" & other){" << std::endl;
144 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
145 fs <<
"\tp_" << it->getName() <<
" = other.p_" << it->getName() <<
";" << std::endl;
147 fs <<
"}" << std::endl << std::endl;
170 PString name(classConfig.
getName());
172 fs <<
"\t//Cannot create check"+name+
"Copy() because there is no getter enabled" << std::endl;
175 fs <<
"\tcheck"+name+
"Copy();\n";
void class_createCheckClassEquality(std::ofstream &fs, const PClassConfig &classConfig, bool isConst)
Create the class check.
void class_createTestClassCopy(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode)
Create the class check.
std::vector< PClassAttribute > PVecClassAttribute
virtual void publicMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of public methods.
virtual void publicMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of public methods.
CppTraitCopy()
Consctructor of CppTraitCopy.
virtual void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of test function.
virtual ~CppTraitCopy()
Desctructor of CppTraitCopy.
virtual void protectedMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of protected methods.
virtual void protectedMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of protected methods.
virtual void testCallFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Call of the test function.
Class to describe a basic class.
const std::vector< PClassAttribute > & getListAttribute() const
Returns the list of attributes of the class.
const PString & getName() const
Returns the class name.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
bool enableGetter
True to enable getters trait generator.
PString defTemplate
Template definition for the class header.
PString templateDeclaration
Template declaration of the method implementation.
PString assertCall
Assert to be used.
bool enableCopy
True to enable copy trait generator.
PString getTestDefaultValueTypeInCpp(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.