PhoenixLecture  2.0.0
Set of tools to make lectures
PGenericParser.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 __PGENERICPARSER_H__
8 #define __PGENERICPARSER_H__
9 
10 #include "PMultiFileParser.h"
12 #include "PLatexObj/parser_utils.h"
14 #include "PLatexObj/pbiblio_html.h"
16 
17 #include "ptimtable_load.h"
18 #include "ptimetable_tex.h"
20 
22 #define COPIED_RECOVER_FILE ".copied_file_recover.map"
24 #define PARSER_SKIP_SPACE p_parser->skipChars(" \t\n");
25 
27 typedef std::map<PString, time_t> PMapFile;
28 
31  public:
32  PGenericParser(const PString & installPrefix = "");
33  PGenericParser(const PGenericParser & other);
34  virtual ~PGenericParser();
35  PGenericParser & operator = (const PGenericParser & other);
36 
37  void setDebugMode(bool isDebugMode);
38 
39  const PLatexObj & getSource() const;
40  PLatexObj & getSource();
41 
42  const std::vector<PString> & getVecIncludeDir() const;
43  std::vector<PString> & getVecIncludeDir();
44 
45  const PMapBiblioEntry & getMapBiblioEntry() const;
47 
48  const PString & getBookSideBarWidth() const;
49  const PString & getBookGitlabUrl() const;
50  bool getBookEnableFeedback() const;
51  const PString & getBookMail() const;
52  const PString & getBookMasterProjectUrl() const;
53  const PLatexObj & getBookMainPageLink() const;
54 
55  bool saveCss();
56 
57  protected:
58  void copyPGenericParser(const PGenericParser & other);
59 
60  void clearLatexObj(PLatexObj & obj);
61  void incrementCurrentChar(PLatexObj & textObj);
62  bool playTextLatexObj(PLatexObj & parent, PLatexObj & textObj, bool isRemoveFirstLastSpace = false);
63  void addLatexObj(PLatexObj & parent, const PLatexObj & obj);
64  PString executeLatexCommand(const PString & inputStr);
65 
66  PString getStringBetweenBraces(const PString & previousToken);
69 
70  bool parseMonoParam(PLatexObj & parent, PLatexObj & textObj, const PString & functionName, PLatexType::PLatexType type);
71 
72  bool parseGenericLatexObj(PLatexObj & parent, PLatexObj & textObj);
73  bool parseLabel(PLatexObj & parent, PLatexObj & textObj);
74  bool parserGetEnv(PLatexObj & parent, PLatexObj & textObj);
75  bool parseMainTitle(PLatexObj & parent, PLatexObj & textObj);
76  bool parseMainSubTitle(PLatexObj & parent, PLatexObj & textObj);
77  bool parseMainAuthor(PLatexObj & parent, PLatexObj & textObj);
78  bool parseMainDate(PLatexObj & parent, PLatexObj & textObj);
79 
80  bool parseBookSizeBarWidth(PLatexObj & parent, PLatexObj & textObj);
81  bool parseBookGitlabUrl(PLatexObj & parent, PLatexObj & textObj);
82  bool parseBookEnableFeedback(PLatexObj & parent, PLatexObj & textObj);
83  bool parseBookMail(PLatexObj & parent, PLatexObj & textObj);
84  bool parseBookMasterProject(PLatexObj & parent, PLatexObj & textObj);
85 
86  void loadDirExtraEnvironementFile(const PPath & inputFile);
87  void loadDirExtraEnvironement(const PPath & inputDir);
88 
89  void loadDirExtraFunctionFile(const PPath & inputFile);
90  void loadDirExtraFunction(const PPath & inputDir);
91 
92  void loadDirExtraParserFile(const PPath & inputFile);
93  void loadDirExtraParser(const PPath & inputDir);
94 
95  void loadCss(const PPath & inputDir);
96 
97  void loadMapFile();
98  void saveMapFile();
99  PPath getAbsoluteFileName(const PPath & fileName);
100  PPath copyFile(const PPath & outputDir, const PPath & fileName);
101 
104 
107 
110 
115 
117  std::vector<PString> p_vecIncludeDir;
118 
120  std::vector<PString> p_vecNameExtraEnv;
122  std::vector<PString> p_vecNameFunctionExtraEnv;
124  std::vector<PString> p_vecNameMarkdownExtraEnv;
127 
129  std::vector<PString> p_vecNameExtraFunction;
132 
134  std::vector<PString> p_vecNameExtraParser;
136  std::vector<PString> p_vecNameFunctionExtraParser;
138  std::vector<PString> p_vecNameMarkdownExtraParser;
139 
141  std::vector<PString> p_vecRemoveLatexKeyword;
144 
146  std::map<PString, PString> p_cssContent;
151 
152  //Book specific variables
166  std::vector<PLatexSpeaker> p_vecSpeaker;
167 
168  private:
169  void initialisationPGenericParser(const PString & baseInstallPrefix);
170 };
171 
172 bool wgetFile(const PString& url);
173 std::vector<PString> getBeginSeqEnv(const PString & envName);
174 std::vector<PString> getEndSeqEnv(const PString & envName);
175 
176 #endif
177 
std::vector< PString > getEndSeqEnv(const PString &envName)
Get the sequence of the ending of an environement.
std::vector< PString > getBeginSeqEnv(const PString &envName)
Get the sequence of the begining of an environement.
bool wgetFile(const PString &url)
Do a wget of a file.
std::map< PString, time_t > PMapFile
Map of the copied files.
Generic parser.
PGenericParser & operator=(const PGenericParser &other)
Definition of equal operator of PGenericParser.
void loadDirExtraParser(const PPath &inputDir)
Load the extra parsers.
bool parserGetEnv(PLatexObj &parent, PLatexObj &textObj)
Parse a getenv function.
bool parseBookMail(PLatexObj &parent, PLatexObj &textObj)
Parse the mail in book mode.
PLatexObj p_bookMainPageLink
Main page definition of the full site.
std::vector< PString > p_vecNameExtraParser
Vector of the name of the extra environement.
PMapExtraEnv p_vecExtraEnv
Vector of extra environements.
PLatexObj p_currentSource
Current completed source.
bool parseBookSizeBarWidth(PLatexObj &parent, PLatexObj &textObj)
Parse the width of the book sidebar.
void copyPGenericParser(const PGenericParser &other)
Copy function of PGenericParser.
void incrementCurrentChar(PLatexObj &textObj)
Increment current char position.
const PString & getBookSideBarWidth() const
Get the width of the book sidebar.
const PMapBiblioEntry & getMapBiblioEntry() const
Get the map of all bibliography entries.
void loadDirExtraEnvironementFile(const PPath &inputFile)
Load the extra environements with input file.
bool parseBookGitlabUrl(PLatexObj &parent, PLatexObj &textObj)
Parse the gitlab url in book mode.
const PLatexObj & getSource() const
Get the current source.
std::vector< PLatexSpeaker > p_vecSpeaker
Vector of all Speakers in the project.
std::map< PString, PString > p_cssContent
Css of all the configurations.
PMapExtraEnv p_vecExtraFunction
Vector of extra function.
PPath copyFile(const PPath &outputDir, const PPath &fileName)
Copy a file.
bool saveCss()
Save the css file.
const std::vector< PString > & getVecIncludeDir() const
Get the vector of include directories.
void loadDirExtraFunction(const PPath &inputDir)
Load the extra functions.
std::vector< PString > p_vecNameFunctionExtraParser
Vector of the function name of the extra environement.
void setDebugMode(bool isDebugMode)
Set if the PGenericParser is in debug mode.
bool parseMainDate(PLatexObj &parent, PLatexObj &textObj)
Parse the main date of the site.
PPath getAbsoluteFileName(const PPath &fileName)
Get the absolute path of a file.
const PLatexObj & getBookMainPageLink() const
Get the book main page link.
PLatexObj p_currentText
Current text.
bool parseMainSubTitle(PLatexObj &parent, PLatexObj &textObj)
Parse the main title of the site.
bool playTextLatexObj(PLatexObj &parent, PLatexObj &textObj, bool isRemoveFirstLastSpace=false)
Play the text latex obj.
PString p_bookMasterProjectUrl
Master project url in book mode.
void clearLatexObj(PLatexObj &obj)
Clear a latex obj.
void loadCss(const PPath &inputDir)
Load the css.
const PString & getBookGitlabUrl() const
Get the book gitlab url.
bool parseMainAuthor(PLatexObj &parent, PLatexObj &textObj)
Parse the main author of the site.
PMapBiblioEntry p_mapBiblioEntry
Map of all bibliography entries.
std::vector< PString > p_vecIncludeDir
Vector of the include directories.
bool parseBookEnableFeedback(PLatexObj &parent, PLatexObj &textObj)
Parse the book enable feedback mode.
bool parseMainTitle(PLatexObj &parent, PLatexObj &textObj)
Parse the main title of the site.
PVecLatexEnv p_vecEnv
Vector of all the environements.
PString executeLatexCommand(const PString &inputStr)
Execute the given latex command.
void loadMapFile()
Load the map of copied files.
PString p_bookSideBarWidth
Witdh of the book side bar.
std::vector< PString > p_vecNameExtraFunction
Vector of the name of the extra function.
PGenericParser(const PString &installPrefix="")
Default constructor of PGenericParser.
std::vector< PString > p_vecNameExtraEnv
Vector of the name of the extra environement.
bool p_isEnableBookFeedback
True to enable feedback in book mode.
void addLatexObj(PLatexObj &parent, const PLatexObj &obj)
Add latex obj in parent.
std::vector< PString > p_vecNameMarkdownExtraParser
Vector of the markdown name of the extra environement.
bool parseBookMasterProject(PLatexObj &parent, PLatexObj &textObj)
Parse the master project in book mode.
virtual ~PGenericParser()
Destructor of PGenericParser.
bool parseMonoParam(PLatexObj &parent, PLatexObj &textObj, const PString &functionName, PLatexType::PLatexType type)
Parse all the functions which have mono parameter in braces {...}.
void initialisationPGenericParser(const PString &baseInstallPrefix)
Initialisation function of the class PGenericParser.
PString p_bookGitlabUrl
Gitlab url of the current sources of the project.
bool getBookEnableFeedback() const
Say if the book feedback if enable or not.
const PString & getBookMail() const
Get the book mail list.
const PString & getBookMasterProjectUrl() const
Get the book master project url.
bool parseLabel(PLatexObj &parent, PLatexObj &textObj)
Parse latex label.
void loadDirExtraEnvironement(const PPath &inputDir)
Load the extra environements.
std::vector< PString > p_vecNameFunctionExtraEnv
Vector of the name of the extra environement.
void saveMapFile()
Save the map of copied files.
PVecLatexFunc p_vecFunc
Vector of all the functions.
void loadDirExtraFunctionFile(const PPath &inputFile)
Load the extra functions with input file.
PString getOptionStringBetweenHook()
Get optional string between hooks [...].
PMapFile p_mapCopiedFile
Map of copied files.
void loadDirExtraParserFile(const PPath &inputFile)
Load the extra environements with input file.
PString getOptionStringBetweenBraces()
Get optional string between braces {...}.
std::vector< PString > p_vecNameMarkdownExtraEnv
Vector of the name of the extra environement (for markdown)
PString p_bookMail
Mail to be used to contact authors in book mode.
bool parseGenericLatexObj(PLatexObj &parent, PLatexObj &textObj)
Parse the generic latex function which have to be used in the latex parser and the markdown parser to...
bool p_isDebugMode
True if be parse in debug mode.
PString getStringBetweenBraces(const PString &previousToken)
Get the string between the braces {...}.
std::vector< PString > p_vecRemoveLatexKeyword
Vector of removed latex functions.
PVecParserEnv p_vecExtraParser
Vector of extra parser.
Describe a latex object.
Definition: PLatexObj.h:40
Class used to parse file with possibility of inclusion.
Path of a directory or a file.
Definition: PPath.h:17
Extends the std::string.
Definition: PString.h:16
Vector of the environements.
Definition: PLatexObj.h:391
PLatexType
Type of the PLatexObj.
Definition: PLatexType.h:12
std::map< PString, PBiblioEntry > PMapBiblioEntry
Describes the map for all PBiblioEntry.
std::vector< PLatexFunc > PVecLatexFunc
Vector of functions.
std::vector< PLatexEnv > PVecLatexEnv
Vector of env.
std::map< PString, PEnvironement > PMapExtraEnv
Vector of extra environement.