Line | Branch | Exec | Source |
---|---|---|---|
1 | /*************************************** | ||
2 | Auteur : Pierre Aubert | ||
3 | Mail : pierre.aubert@lapp.in2p3.fr | ||
4 | Licence : CeCILL-C | ||
5 | ****************************************/ | ||
6 | |||
7 | #include "pxml_utils.h" | ||
8 | #include "PParseSeq_utils.h" | ||
9 | |||
10 | ///Load a ParseSeq with a XML balise | ||
11 | /** @param[out] seq : ParseSeq to be initialised | ||
12 | * @param xmlSeq : sequence in XML | ||
13 | * @return true on success, false otherwise | ||
14 | * Parse a xml such as : | ||
15 | * \<sequence\> | ||
16 | * \<step\> | ||
17 | * \<str\>0123456789\</str\> | ||
18 | * \</step\> | ||
19 | * \<step optional="true"\> | ||
20 | * \<match\>lu\</match\> | ||
21 | * \<m\>u</m\> | ||
22 | * \</step\> | ||
23 | * \</sequence\> | ||
24 | * It get a number followed by lu or u or nothing | ||
25 | */ | ||
26 | 7 | bool loadParserSeq(PParseSeq & seq, const PXml & xmlSeq){ | |
27 |
3/4✓ Branch 0 (2→3) taken 7 times.
✓ Branch 2 (3→4) taken 7 times.
✗ Branch 4 (4→5) not taken.
✓ Branch 5 (4→11) taken 7 times.
|
7 | if(xmlSeq.getName() != "sequence"){ |
28 | ✗ | std::cerr << "loadParserSeq : expect <sequence> balise, not <"<<xmlSeq.getName()<<"> balise" << std::endl; | |
29 | ✗ | return false; | |
30 | } | ||
31 | 7 | PVecXml listXmlStep; | |
32 |
3/4✓ Branch 0 (12→13) taken 7 times.
✓ Branch 2 (13→14) taken 7 times.
✓ Branch 4 (15→16) taken 7 times.
✗ Branch 5 (15→98) not taken.
|
7 | if(pxml_getVecChildIfExist(listXmlStep, xmlSeq, "step")){ |
33 |
2/2✓ Branch 0 (96→17) taken 17 times.
✓ Branch 1 (96→97) taken 7 times.
|
48 | for(PVecXml::iterator itStep(listXmlStep.begin()); itStep != listXmlStep.end(); ++itStep){ |
34 |
1/1✓ Branch 0 (17→18) taken 17 times.
|
17 | PParseStep step; |
35 |
1/1✓ Branch 0 (18→19) taken 17 times.
|
17 | PXmlAttr attrStep; |
36 |
4/4✓ Branch 0 (19→20) taken 17 times.
✓ Branch 2 (22→23) taken 17 times.
✓ Branch 4 (24→25) taken 5 times.
✓ Branch 5 (24→38) taken 12 times.
|
34 | if(pxml_getAttrIfExist(attrStep, *itStep, "optional")){ |
37 |
2/2✓ Branch 0 (25→26) taken 5 times.
✓ Branch 2 (26→27) taken 5 times.
|
5 | PString val(attrStep.getValue()); |
38 |
3/10✓ Branch 0 (27→28) taken 5 times.
✗ Branch 2 (28→29) not taken.
✓ Branch 3 (28→33) taken 5 times.
✗ Branch 4 (29→30) not taken.
✗ Branch 6 (30→31) not taken.
✗ Branch 7 (30→33) not taken.
✗ Branch 8 (31→32) not taken.
✗ Branch 10 (32→33) not taken.
✗ Branch 11 (32→34) not taken.
✓ Branch 12 (35→36) taken 5 times.
|
5 | step.setIsOptional(val == "true" || val == "True" || val == "TRUE"); |
39 | 5 | } | |
40 |
1/1✓ Branch 0 (40→41) taken 17 times.
|
17 | PVecXml & listCmd(itStep->getVecChild()); |
41 |
2/2✓ Branch 0 (81→42) taken 51 times.
✓ Branch 1 (81→82) taken 17 times.
|
136 | for(PVecXml::iterator itCmd(listCmd.begin()); itCmd != listCmd.end(); ++itCmd){ |
42 |
1/1✓ Branch 0 (42→43) taken 51 times.
|
51 | PParseCmd cmd; |
43 |
2/2✓ Branch 0 (45→46) taken 51 times.
✓ Branch 2 (46→47) taken 51 times.
|
51 | cmd.setStr(pxml_getFullContent(*itCmd)); |
44 |
2/2✓ Branch 0 (50→51) taken 51 times.
✓ Branch 2 (51→52) taken 51 times.
|
51 | PString cmdName(itCmd->getName()); |
45 |
5/6✓ Branch 0 (52→53) taken 51 times.
✓ Branch 2 (53→54) taken 51 times.
✗ Branch 3 (53→56) not taken.
✓ Branch 4 (54→55) taken 51 times.
✓ Branch 6 (55→56) taken 12 times.
✓ Branch 7 (55→57) taken 39 times.
|
51 | bool isString(cmdName == "str" || cmdName == "s"); |
46 |
5/6✓ Branch 0 (58→59) taken 51 times.
✓ Branch 2 (59→60) taken 51 times.
✗ Branch 3 (59→62) not taken.
✓ Branch 4 (60→61) taken 51 times.
✓ Branch 6 (61→62) taken 5 times.
✓ Branch 7 (61→63) taken 46 times.
|
51 | bool isMatch(cmdName == "match" || cmdName == "m"); |
47 |
1/1✓ Branch 0 (64→65) taken 51 times.
|
51 | cmd.setIsMatch(isMatch); |
48 |
4/4✓ Branch 0 (65→66) taken 39 times.
✓ Branch 1 (65→67) taken 12 times.
✓ Branch 2 (66→67) taken 5 times.
✓ Branch 3 (66→69) taken 34 times.
|
51 | if(isString || isMatch){ |
49 |
2/2✓ Branch 0 (67→68) taken 17 times.
✓ Branch 2 (68→69) taken 17 times.
|
17 | step.getVecCmd().push_back(cmd); |
50 | } | ||
51 | 51 | } | |
52 |
2/2✓ Branch 0 (82→83) taken 17 times.
✓ Branch 2 (83→84) taken 17 times.
|
17 | seq.getVecStep().push_back(step); |
53 | 17 | } | |
54 | } | ||
55 | 7 | return true; | |
56 | 7 | } | |
57 | |||
58 | |||
59 | ///Create a full sequence of string to match totaly | ||
60 | /** @param vecStr : vector of string | ||
61 | * @return corresponding sequence | ||
62 | */ | ||
63 | 1 | PParseSeq createSequenceAllMatch(const PVecString & vecStr){ | |
64 | 1 | PParseSeq seq; | |
65 |
2/2✓ Branch 0 (27→4) taken 4 times.
✓ Branch 1 (27→28) taken 1 times.
|
10 | for(PVecString::const_iterator it(vecStr.begin()); it != vecStr.end(); ++it){ |
66 |
1/1✓ Branch 0 (4→5) taken 4 times.
|
4 | PParseStep stepBegin; |
67 |
1/1✓ Branch 0 (5→6) taken 4 times.
|
4 | stepBegin.setIsOptional(false); |
68 |
1/1✓ Branch 0 (6→7) taken 4 times.
|
4 | PParseCmd cmdBegin; |
69 |
1/1✓ Branch 0 (7→8) taken 4 times.
|
4 | cmdBegin.setIsMatch(true); |
70 |
1/1✓ Branch 0 (10→11) taken 4 times.
|
4 | cmdBegin.setStr(*it); |
71 |
2/2✓ Branch 0 (11→12) taken 4 times.
✓ Branch 2 (12→13) taken 4 times.
|
4 | stepBegin.getVecCmd().push_back(cmdBegin); |
72 |
2/2✓ Branch 0 (13→14) taken 4 times.
✓ Branch 2 (14→15) taken 4 times.
|
4 | seq.getVecStep().push_back(stepBegin); |
73 | 4 | } | |
74 | 1 | return seq; | |
75 | ✗ | } | |
76 | |||
77 | |||
78 |