PhoenixLecture  2.0.0
Set of tools to make lectures
select_css_theme.cpp File Reference
#include "PFileParser.h"
#include "select_css_theme.h"
+ Include dependency graph for select_css_theme.cpp:

Go to the source code of this file.

Functions

bool parseThemeSwitch (PString &outputCss, PFileParser &parser, const PVecString &vecTheme, const PString &themeName)
 Parse the theme switch. More...
 
PString select_css_theme (const PVecString &vecTheme, const PString &themeName, const PString &css)
 Select the right css option by respect to the given theme. More...
 

Function Documentation

◆ parseThemeSwitch()

bool parseThemeSwitch ( PString outputCss,
PFileParser parser,
const PVecString vecTheme,
const PString themeName 
)

Parse the theme switch.

Parameters
[out]outputCss: output css selected theme
[out]parser: PFileParser to be used
vecTheme: vector of all possible theme
themeName: theme to be used

Definition at line 16 of file select_css_theme.cpp.

16  {
17  PString themeMatch(parser.isMatch(vecTheme));
18  if(themeMatch == ""){return false;} //Not an existing theme
19  PString strSpace(parser.getStrComposedOf(" \n\t"));
20  if(themeMatch != themeName){
21  if(parser.isMatch("{")){ //It is a theme, but the the one we want
22  parser.getUntilKeyWithoutPatern("}"); //So we skip it
23  return false;
24  }else{ //It is not a theme, so we have to keep this css
25  outputCss = themeMatch + strSpace;
26  return true;
27  }
28  }
29  if(parser.isMatch("{")){ //It is the theme we want
30  outputCss = parser.getUntilKeyWithoutPatern("}"); //So we keep it
31  }else{ //It is not a theme, so we have to keep this css
32  outputCss = themeMatch + strSpace;
33  }
34  return true;
35 }
PString getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.
PString getStrComposedOf(const PString &charset)
Get string composed of the characters in the string charset.
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
Extends the std::string.
Definition: PString.h:16

References PFileParser::getStrComposedOf(), PFileParser::getUntilKeyWithoutPatern(), and PFileParser::isMatch().

Referenced by select_css_theme().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ select_css_theme()

PString select_css_theme ( const PVecString vecTheme,
const PString themeName,
const PString css 
)

Select the right css option by respect to the given theme.

Parameters
vecTheme: vector of all possible theme
themeName: theme to be used
css: raw css with all possible themes
Returns
css with selected theme

Definition at line 43 of file select_css_theme.cpp.

43  {
44  PFileParser parser;
45  parser.setWhiteSpace("");
46  parser.setSeparator("");
47  parser.setFileContent(css);
48  PString outputCss("");
49 
50  while(!parser.isEndOfFile()){
51  PString tmpCss("");
52  if(parseThemeSwitch(tmpCss, parser, vecTheme, themeName)){
53  outputCss += tmpCss;
54  }else{
55  outputCss += parser.getCurrentCh();
56  parser.getNextChar();
57  }
58  }
59  return outputCss;
60 }
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
Definition: PFileParser.h:20
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
Definition: PFileParser.cpp:43
void setWhiteSpace(const PString &whiteSpace)
Initialise la liste des caractères blancs.
Definition: PFileParser.cpp:35
char getCurrentCh() const
Renvoie le caractère courant.
void setFileContent(const PString &fileContent)
Set the file content.
Definition: PFileParser.cpp:50
bool isEndOfFile() const
Dit si on est à la fin du fichier.
Definition: PFileParser.cpp:88
char getNextChar()
Fonction qui renvoie le prochain caractère du fichier courant.
bool parseThemeSwitch(PString &outputCss, PFileParser &parser, const PVecString &vecTheme, const PString &themeName)
Parse the theme switch.

References PFileParser::getCurrentCh(), PFileParser::getNextChar(), PFileParser::isEndOfFile(), parseThemeSwitch(), PFileParser::setFileContent(), PFileParser::setSeparator(), and PFileParser::setWhiteSpace().

Referenced by PGenericParser::saveCss().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: