PhoenixPresentation  2.0.0
Set of cmake function to automate presentation generation
PMultiFileParser.h
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 #ifndef __PMULTIFILEPARSER_H__
8 #define __PMULTIFILEPARSER_H__
9 
10 #include <list>
11 #include "PFileParser.h"
12 
13 #define MULTI_PARSER_SEPARATORS_STRING "()[]{}+=*.;,/%#':<>\""
14 
15 
17 
20 typedef std::pair<PString, PString> PMultiCommentConfig;
22 
25 typedef std::list<PMultiCommentConfig > PListMultiCommentConfig;
26 
29  public:
30  PMultiFileParser(const PPath & inputDirectory = PPath(), const PPath & outputDirectory = PPath());
31  virtual ~PMultiFileParser();
32 
33  bool load(const PPath & configFile);
34  void setFileContent(const PString & fileContent);
35  bool fullParsing();
36  void addCommentConfig(const PMultiCommentConfig & commentConfig);
37  void addCommentConfig(const PString & beginStringComment, const PString & endStringComment = "\n");
38 
39  const PString & getLastComment() const;
41 
42  void stopParsing();
43  void errorAt();
44  void pointAtRow();
45  void unexpectedToken();
46  bool checkExpectedToken(const PString & tokenExpected, const PString & tokenBefore = "");
47  bool checkExpectedMatch(const PString & tokenExpected, const PString & tokenBefore = "");
48 
49  void skipComment();
50  void clearComment();
51 
52  bool isMatch(const PString & token);
53  bool isMatchRewind(const PString & token);
54  bool isMatchSeq(const PVecString & patern, bool alwaysPopBack = false);
55  bool isMatch(const PString & patern, const PString & forbiddenCharBefore);
56  PString isMatch(const PVecString & vecToken);
57  PString isMatchToken(const PVecString & vecToken);
58 
59  PString getStrComposedOf(const PString & charset);
60 
63 
64  protected:
65  virtual bool parseFile() = 0;
66  virtual void preLoadFile();
67  virtual void postLoadFile();
68 
72  std::list<PFileParser> p_listFileParser;
74  bool p_run;
83 
84  private:
85  void initialisationPMultiFileParser(const PPath & inputDirectory, const PPath & outputDirectory);
86 
89 };
90 
91 
92 
93 #endif
94 
std::pair< PString, PString > PMultiCommentConfig
Describes a comment config.
std::list< PMultiCommentConfig > PListMultiCommentConfig
Describes a list of comment config.
std::vector< PString > PVecString
Definition: PString.h:96
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
Definition: PFileParser.h:20
Class used to parse file with possibility of inclusion.
void setFileContent(const PString &fileContent)
Set the file content to be parsed.
bool isMatchSeq(const PVecString &patern, bool alwaysPopBack=false)
Match a sequence of token in a vector.
virtual ~PMultiFileParser()
Destructeur of PMultiFileParser.
void getCurrentTokenWithoutComment()
Get the current token and skip the comment.
const PString & getLastComment() const
Get the last comment.
virtual void postLoadFile()
Post load file.
PMultiFileParser(const PPath &inputDirectory=PPath(), const PPath &outputDirectory=PPath())
Default constructeur of PMultiFileParser.
PString isMatchToken(const PVecString &vecToken)
Check the matching between the current caracters and all the string in the vector but treats the stri...
PPath p_inputDirectory
Input directory of the parser.
bool load(const PPath &configFile)
Load the PMultiFileParser with the configFile.
virtual bool parseFile()=0
void clearComment()
Clear comment.
PString getStrComposedOf(const PString &charset)
Get the string composed of charset charcters.
virtual void preLoadFile()
Pre load file.
std::list< PFileParser > p_listFileParser
List of all the parsers for all the loaded files.
bool isMatch(const PString &token)
Check if the given token matches the current read file.
void errorAt()
Write a parsing error.
void initialisationPMultiFileParser(const PPath &inputDirectory, const PPath &outputDirectory)
Initialisation function of the class PMultiFileParser.
void unexpectedToken()
Print unexpected token error.
PString p_lastComment
last comment
void pointAtRow()
Point the problem.
bool checkExpectedToken(const PString &tokenExpected, const PString &tokenBefore="")
Check if the p_currentToken == tokenExpected.
PFileParser * p_parser
Parser helper for the config file.
bool fullParsing()
Perform the full parsing pf data.
bool p_run
Run the parsing if true.
void addCommentConfig(const PMultiCommentConfig &commentConfig)
Adds a comment config for the parser.
bool isMatchRewind(const PString &token)
Check if the given token matches the current read file and goes back even if the token matches.
PListMultiCommentConfig p_listCommentConfig
Defines the differents comments we allow in the parsing.
void stopParsing()
Stop the parsing of all the files.
bool checkExpectedMatch(const PString &tokenExpected, const PString &tokenBefore="")
Check if the tokenExpected match.
PFileParser * getCurrentParser()
Gets the current parser.
PString p_currentToken
CurrentToken parsed.
PPath p_outputDirectory
Output directory of the parser.
void skipComment()
Skip comment.
Path of a directory or a file.
Definition: PPath.h:17
Extends the std::string.
Definition: PString.h:16