18 std::cerr <<
"errorUnexpectedToken : '" << parser.
getFileName() <<
"' line " << parser.
getLine() << std::endl;
19 std::cerr <<
"unexpected token '" << token <<
"'" << std::endl;
27 return parser.
getStrComposedOf(
"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
37 if(currentComment !=
""){currentComment +=
"\n";}
40 if(currentComment !=
""){currentComment +=
"\n";}
54 if(!parser.
isMatch(
"template")){
return false;}
55 if(!parser.
isMatch(
"<")){
return false;}
72 PString attributName(listToken.back());
75 for(PVecString::iterator it(listToken.begin()); it != listToken.end(); ++it){
76 attributType += *it +
" ";
90 if(!parser.
isMatch(
"("))
return true;
138 std::cout <<
"parseEnumConfig : find enum : '"<<enumName<<
"'" << std::endl;
145 std::cerr <<
"\tExpect '{' after enum name '"<<enumName<<
"'" << std::endl;
148 bool searchingData(
true);
158 listClassConfig.push_back(config);
172 std::cout <<
"parsePClassConfig : find className : '"<<className<<
"'" << std::endl;
177 listTemplate.clear();
181 std::cerr <<
"parsePClassConfig : file '" << parser.
getFileName() <<
"' line " << parser.
getLine() << std::endl;
182 std::cerr <<
"\tmissing ')' : can't parse parents of the class '"<<config.
getName()<<
"'" << std::endl;
185 std::cerr <<
"parsePClassConfig : file '" << parser.
getFileName() <<
"' line " << parser.
getLine() << std::endl;
186 std::cerr <<
"\tmissing '}'" << std::endl;
191 std::cerr <<
"\tExpect '{' after class name '"<<className<<
"'" << std::endl;
195 bool searchingData(
true);
205 listClassConfig.push_back(config);
216 if(fileName ==
"")
return false;
220 if(!parser.
open(fileName))
return false;
255 std::vector<PClassConfig> listClassConfig;
257 std::cerr <<
"saveParserClassConfig : can't load file '" << fileName <<
"'" << std::endl;
260 if(!
saveClassImplDecl( listClassConfig, baseFileNameOutput, listInclude, enableDataStream, enableTypeStream)){
261 std::cerr <<
"saveParserClassConfig : can't save files '" << baseFileNameOutput <<
"'[.h or .cpp]" << std::endl;
265 PPath unitTestDir(testParentDir /
PPath(
"TESTS"));
266 if(!
saveClassTest(unitTestDir, libName, listClassConfig, baseFileNameOutput.
getFileName(), enableDataStream, enableTypeStream)){
267 std::cerr <<
"saveParserClassConfig : can't save unit tests in directory'" << unitTestDir <<
"'" << std::endl;
std::vector< PPath > PVecPath
std::vector< PString > PVecString
Describes a class attribute.
void setDefaultValue(const PString &defaultValue)
Sets the defaultValue of the PClassAttribute.
Class to describe a basic class.
void addAttribute(const PClassAttribute &attribute)
Adds an attribute to the class.
void setClassDocumentation(const PString &classDocumentation)
Sets the class documentation.
void setIsEnum(bool isEnum)
Set if the current PClassConfig is an enum.
const PString & getName() const
Returns the class name.
void setName(const PString &name)
Sets the class name.
void addParentClass(const PString &parentClass)
Add a parent class to the PClassConfig.
void setListTemplate(const PVecString &listTemplate)
Sets the list of template of the class.
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
size_t getLine() const
Fonction qui renvoie le numéro de la ligne courante.
bool open(const PPath &fileName)
Fonction qui ouvre le fichier que l'on va parser.
PString getNextToken()
Get the next token.
PString getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.
PString getUntilKeyWithoutPaternRecurse(const PString &patern, const PString &beginPatern, const PString &allowedCharAfterBegin)
Get the string until end sequence and take account recursive patern (embeded strings)
PString getStrComposedOf(const PString &charset)
Get string composed of the characters in the string charset.
void setWhiteSpace(const PString &whiteSpace)
Initialise la liste des caractères blancs.
bool isMatchToken(const PString &patern)
Says if the patern match with the current caracters of the PFileParser but treats the string as a tok...
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
PString getUntilKey(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern comprise.
PPath getFileName() const
Fonction qui renvoie le nom du fichier que l'on a ouvert.
void skipWhiteSpace()
Skip the white space if there is at the current caracter position.
bool isEndOfFile() const
Dit si on est à la fin du fichier.
Path of a directory or a file.
PPath getFileName() const
Get the name of the file, from last char to /.
PString eraseChar(char ch) const
Erase char ch of current string.
std::vector< PString > split(char separator) const
Cut a PString on the given separator char.
PString eraseFirstLastChar(const PString &vecChar) const
Erase first and last char in a string.
PClassAttribute createClassAttribute(const PString &type, const PString &name, const PString &documentation)
Creates a PClassAttribute.
bool updateCurrentComment(PFileParser &parser, PString ¤tComment)
Fonction qui met à jour un commentaire.
bool parseEnumValue(PClassConfig &config, PFileParser &parser, PString ¤tComment)
Parse enum attribute value.
bool parseEnumConfig(std::vector< PClassConfig > &listClassConfig, PFileParser &parser, PString ¤tComment)
Parse an enum definition.
bool saveParserClassConfig(const PPath &baseFileNameOutput, const PPath &fileName, bool enableDataStream, bool enableTypeStream, bool enableUnitTest, const PPath &testParentDir, const PString &libName)
Parser list class config.
bool parseClassConfigAttribut(PClassConfig &config, PFileParser &parser, PString ¤tComment)
Parse a PClassConfig.
bool parsePClassConfig(std::vector< PClassConfig > &listClassConfig, PFileParser &parser, PString ¤tComment, PVecString &listTemplate)
Parse a PClassConfig.
bool parserClassConfig(std::vector< PClassConfig > &listClassConfig, PVecPath &listInclude, const PPath &fileName)
Parser list class config.
bool updateCurrentTemplate(PFileParser &parser, PVecString ¤tTemplate)
Update a template definition.
bool parseParentOfClassConfig(PClassConfig &config, PFileParser &parser)
Parse the parents of the PClassConfig.
PString getClassName(PFileParser &parser)
Get class name from parser.
void errorUnexpectedToken(const PFileParser &parser, const PString &token)
Affiche une erreur de token non attendu.
bool saveClassTest(const PPath &outputTestDir, const PString &libName, const PClassConfig &classConfig, const PPath &baseFileName, bool enableDataStream, bool enableTypeStream)
Save the unit test of the generated PClassConfig.
bool saveClassImplDecl(const std::vector< PClassConfig > &classConfig, const PPath &baseFileName, const PVecPath &listInclude, bool enableDataStream, bool enableTypeStream)
Creates header file.