PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
main.cpp File Reference
#include <iostream>
#include "phoenix_assert.h"
#include "phoenix_check.h"
#include "pxml_utils.h"
#include "PParseSeq_utils.h"
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

bool checkParseSeq (const PPath &fileName, const PString &strToBeParsed, bool expextedResult)
 Check the ParseSeq. More...
 
void checkParseSeqFromVec ()
 Check the ParseSeq. More...
 
void checkPParseCmd ()
 Check the ParseCmd. More...
 
void checkTestParseSeq ()
 Check the ParseSeq. More...
 
int main (int argc, char **argv)
 
void testPParseStep ()
 Check the ParseCmd. More...
 

Function Documentation

◆ checkParseSeq()

bool checkParseSeq ( const PPath fileName,
const PString strToBeParsed,
bool  expextedResult 
)

Check the ParseSeq.

Parameters
fileName: name of the file to be used
strToBeParsed: string to be parsed
expextedResult: expected result
Returns
true on success, false otherwise

Definition at line 21 of file main.cpp.

21  {
22  bool b(true);
23  PXml root;
24  b &= pxml_parserFile(root, fileName);
25 
26  PXml * xml = pxml_getChildPtr(root, "sequence");
27 
28  PParseSeq seq;
29  b &= loadParserSeq(seq, *xml);
30 
31  b &= pxml_getFullContent(*xml) != "";
32 
33  PFileParser parser;
34  parser.setFileContent(strToBeParsed);
35 
36  b &= (parser.isMatch(seq) != "") == expextedResult;
37 // phoenix_functionOk("checkParseSeq", b);
38  return b;
39 }
bool loadParserSeq(PParseSeq &seq, const PXml &xmlSeq)
Load a ParseSeq with a XML balise.
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
Definition: PFileParser.h:20
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
void setFileContent(const PString &fileContent)
Set the file content.
Definition: PFileParser.cpp:50
Parsing sequence.
Definition: PParseSeq.h:77
Class used to parse xml.
Definition: PXml.h:54
PString pxml_getFullContent(const PXml &xml)
Get the content of the PXml (children or value)
Definition: pxml_utils.cpp:395
bool pxml_parserFile(PXml &xml, const PPath &fileName, bool isSvg)
Parse a PXml with a file.
Definition: pxml_utils.cpp:38
PXml * pxml_getChildPtr(PXml &xml, const PString &childName)
Get the child with given name if exist.
Definition: pxml_utils.cpp:234

References PFileParser::isMatch(), loadParserSeq(), pxml_getChildPtr(), pxml_getFullContent(), pxml_parserFile(), and PFileParser::setFileContent().

Referenced by checkTestParseSeq().

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

◆ checkParseSeqFromVec()

void checkParseSeqFromVec ( )

Check the ParseSeq.

Definition at line 42 of file main.cpp.

42  {
43  std::vector<PString> vecStr;
44  vecStr.push_back("\\begin");
45  vecStr.push_back("{");
46  vecStr.push_back("someName");
47  vecStr.push_back("}");
48 
49  PParseSeq seq = createSequenceAllMatch(vecStr);
50  PParseSeq seq2(seq), seq3;
51  seq3 = seq;
52 }
PParseSeq createSequenceAllMatch(const PVecString &vecStr)
Create a full sequence of string to match totaly.

References createSequenceAllMatch().

Referenced by checkTestParseSeq().

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

◆ checkPParseCmd()

void checkPParseCmd ( )

Check the ParseCmd.

Definition at line 78 of file main.cpp.

78  {
79  PParseCmd cmd;
80  phoenix_assert(!cmd.getIsMatch());
81  phoenix_assert(cmd.getStr() == "");
82  PParseCmd cmd2;
83  cmd2 = cmd;
84 }
Parser command.
Definition: PParseSeq.h:33
bool getIsMatch() const
Get the variable p_isMatch.
Definition: PParseSeq.cpp:65
const PString & getStr() const
Get the variable p_str.
Definition: PParseSeq.cpp:79
#define phoenix_assert(isOk)

References PParseCmd::getIsMatch(), PParseCmd::getStr(), and phoenix_assert.

Referenced by main().

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

◆ checkTestParseSeq()

void checkTestParseSeq ( )

Check the ParseSeq.

Definition at line 55 of file main.cpp.

55  {
56  PPath fileName1("testFile1.xml");
57  PString content1("<sequence>\t<step>\n\t<s>1234567890</s>\n\t</step>\n\t<step optional=\"true\">\n\t<s>lu</s>\n\t</step>\n</sequence>\n");
58  phoenix_assert(fileName1.saveFileContent(content1));
59  phoenix_assert(checkParseSeq(fileName1, "24140812", true));
60  phoenix_assert(checkParseSeq(fileName1, "2414lu", true));
61 
62  PPath fileName2("testFile2.xml");
63  PString content2("<sequence>\n\t<step>\n\t\t<m>.</m>\n\t</step>\n\t<step>\n\t\t<s>1234567890</s>\n\t</step>\n\t<step optional=\"true\">\n\t\t<s>f</s>\n\t\t\t</step>\n</sequence>\n");
64  phoenix_assert(fileName2.saveFileContent(content2));
65  phoenix_assert(checkParseSeq(fileName2, ".124", true));
66  phoenix_assert(checkParseSeq(fileName2, ".12f", true));
67  phoenix_assert(checkParseSeq(fileName2, "2414lu", false));
68 
69  PPath fileName3("testFile3.xml");
70  PString content3("<sequence>\n\t<step>\n\t\t<m>0x</m>\n\t</step>\n\t<step>\n\t\t<s>1234567890abcdef</s>\n\t</step>\n</sequence>\n");
71  phoenix_assert(fileName3.saveFileContent(content3));
72  phoenix_assert(checkParseSeq(fileName3, "0x124ef", true));
73  phoenix_assert(checkParseSeq(fileName3, "0xa2b5e2f", true));
75 }
Path of a directory or a file.
Definition: PPath.h:17
Extends the std::string.
Definition: PString.h:16
void checkParseSeqFromVec()
Check the ParseSeq.
Definition: main.cpp:42
bool checkParseSeq(const PPath &fileName, const PString &strToBeParsed, bool expextedResult)
Check the ParseSeq.
Definition: main.cpp:21

References checkParseSeq(), checkParseSeqFromVec(), phoenix_assert, and PPath::saveFileContent().

Referenced by main().

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

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 99 of file main.cpp.

99  {
101  checkPParseCmd();
102  testPParseStep();
103  return 0;
104 }
void testPParseStep()
Check the ParseCmd.
Definition: main.cpp:87
void checkPParseCmd()
Check the ParseCmd.
Definition: main.cpp:78
void checkTestParseSeq()
Check the ParseSeq.
Definition: main.cpp:55

References checkPParseCmd(), checkTestParseSeq(), and testPParseStep().

+ Here is the call graph for this function:

◆ testPParseStep()

void testPParseStep ( )

Check the ParseCmd.

Definition at line 87 of file main.cpp.

87  {
88  PParseStep step;
89  std::vector<PParseCmd> vecCmd;
90  step.setVecCmd(vecCmd);
91 
93 
94  PParseSeq seq;
95  std::vector<PParseStep> vecStep;
96  seq.setVecStep(vecStep);
97 }
void setVecStep(const std ::vector< PParseStep > &vecStep)
Set the variable p_vecStep, of type 'std ::vector<PParseStep>'.
Definition: PParseSeq.cpp:249
Describes a parsing step.
Definition: PParseSeq.h:55
void setVecCmd(const std ::vector< PParseCmd > &vecCmd)
Set the variable p_vecCmd, of type 'std ::vector<PParseCmd>'.
Definition: PParseSeq.cpp:157
bool getIsOptional() const
Get the variable p_isOptional.
Definition: PParseSeq.cpp:164

References PParseStep::getIsOptional(), phoenix_assert, PParseStep::setVecCmd(), and PParseSeq::setVecStep().

Referenced by main().

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