87 PString name(classConfig.
getName());
88 fs <<
"bool fromString(" << name <<
"::" << name <<
" & data, const std::string & value);" << std::endl << std::endl;
98 PString name(classConfig.
getName());
99 fs <<
"///Set " << name <<
"::" << name <<
" enum with a PString" << std::endl;
100 fs <<
"/**\t@param[out] data : " << name <<
"::" << name <<
" to set" << std::endl;
101 fs <<
" * \t@param value : std::string to initialised it" << std::endl;
102 fs <<
" * \t@return true on success, false otherwise" << std::endl;
103 fs <<
"*/" << std::endl;
104 fs <<
"bool fromString(" << name <<
"::" << name <<
" & data, const std::string & value){" << std::endl;
105 fs <<
"\tswitch(value){" << std::endl;
107 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
108 fs <<
"\t\tcase \""<<it->getName()<<
"\": data = " << name <<
"::" << it->getName() <<
"; break;" << std::endl;
110 fs <<
"\t\tdefault: return false;" << std::endl;
111 fs <<
"\t}" << std::endl;
112 fs <<
"\treturn true;" << std::endl;
113 fs <<
"}" << std::endl << std::endl;
123 PString name(classConfig.
getName());
125 fs <<
"///Check the fromString trait of enum " << name <<
"::" << name << std::endl;
126 fs <<
"/**\t@param inputValue : input value to initialise a " << name <<
"::" << name << std::endl;
127 fs <<
" * \t@param reference : reference value of the expected " << name <<
"::" << name << std::endl;
128 fs <<
"*/" << std::endl;
129 fs <<
"void check" << name <<
"FromString(const std::string & inputValue, " << name <<
"::" << name <<
" reference){" << std::endl;
130 fs <<
"\t" << name <<
"::" << name <<
" value;" << std::endl;
131 fs <<
"\t"<<mode.
assertCall<<
"(fromString(value, inputValue));" << std::endl;
132 fs <<
"\t"<<mode.
assertCall<<
"(value == reference);" << std::endl;
133 fs <<
"}" << std::endl << std::endl;
135 fs <<
"///Test the fromString trait of enum " << name <<
"::" << name << std::endl;
136 fs <<
"void test" << name <<
"FromString(){" << std::endl;
138 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
139 fs <<
"\tcheck" << name <<
"FromString(\""<<it->getName()<<
"\", " << name <<
"::" << it->getName() <<
");" << std::endl;
142 fs <<
"\t" << name <<
"::" << name <<
" wrongValue;" << std::endl;
143 fs <<
"\t"<<mode.
assertCall<<
"(!fromString(wrongValue, \"non sense string of configuration\"));" << std::endl;
145 fs <<
"}" << std::endl << std::endl;
155 PString name(classConfig.
getName());
156 fs <<
"\ttest" << name <<
"FromString();" << std::endl;
std::vector< PClassAttribute > PVecClassAttribute
virtual void classExtraFunctionDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of extra functions.
CppTraitFromString()
Consctructor of CppTraitFromString.
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.
virtual void publicMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of public methods.
virtual void headerExtraInclude(std::ofstream &fs, const GeneratorMode &mode) const
Add extra include on the header.
virtual void testFunction(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of test function.
virtual void privateMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of private methods.
virtual ~CppTraitFromString()
Desctructor of CppTraitFromString.
virtual void publicMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of public methods.
virtual void privateMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of private methods.
virtual void protectedMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of protected methods.
virtual void classExtraFunctionImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of extra functions.
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 enableFromString
True to enable fromString trait generator.
PString assertCall
Assert to be used.