PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
main.cpp
Go to the documentation of this file.
1 
2 /***************************************
3  Auteur : Pierre Aubert
4  Mail : pierre.aubert@lapp.in2p3.fr
5  Licence : CeCILL-C
6 ****************************************/
7 
8 #include <iostream>
9 #include "phoenix_assert.h"
10 #include "phoenix_check.h"
11 #include "pxml_utils.h"
12 #include "PParseSeq_utils.h"
13 
14 
16 
21 bool checkParseSeq(const PPath & fileName, const PString & strToBeParsed, bool expextedResult){
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 }
40 
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 }
53 
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 }
76 
79  PParseCmd cmd;
80  phoenix_assert(!cmd.getIsMatch());
81  phoenix_assert(cmd.getStr() == "");
82  PParseCmd cmd2;
83  cmd2 = cmd;
84 }
85 
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 }
98 
99 int main(int argc, char** argv){
101  checkPParseCmd();
102  testPParseStep();
103  return 0;
104 }
105 
106 
bool loadParserSeq(PParseSeq &seq, const PXml &xmlSeq)
Load a ParseSeq with a XML balise.
PParseSeq createSequenceAllMatch(const PVecString &vecStr)
Create a full sequence of string to match totaly.
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
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
Parsing sequence.
Definition: PParseSeq.h:77
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
Path of a directory or a file.
Definition: PPath.h:17
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395
Extends the std::string.
Definition: PString.h:16
Class used to parse xml.
Definition: PXml.h:54
#define phoenix_assert(isOk)
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
int main(int argc, char **argv)
Definition: main.cpp:290
void testPParseStep()
Check the ParseCmd.
Definition: main.cpp:87
void checkParseSeqFromVec()
Check the ParseSeq.
Definition: main.cpp:42
void checkPParseCmd()
Check the ParseCmd.
Definition: main.cpp:78
bool checkParseSeq(const PPath &fileName, const PString &strToBeParsed, bool expextedResult)
Check the ParseSeq.
Definition: main.cpp:21
void checkTestParseSeq()
Check the ParseSeq.
Definition: main.cpp:55