PhoenixXml
1.2.3
Xml parser for Phoenix
Toggle main menu visibility
Loading...
Searching...
No Matches
PParseSeq_utils.cpp
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
#include "
pxml_utils.h
"
8
#include "
PParseSeq_utils.h
"
9
11
26
bool
loadParserSeq
(PParseSeq & seq,
const
PXml
& xmlSeq){
27
if
(xmlSeq.
getName
() !=
"sequence"
){
28
std::cerr <<
"loadParserSeq : expect <sequence> balise, not <"
<<xmlSeq.
getName
()<<
"> balise"
<< std::endl;
29
return
false
;
30
}
31
PVecXml
listXmlStep;
32
if
(
pxml_getVecChildIfExist
(listXmlStep, xmlSeq,
"step"
)){
33
for
(PVecXml::iterator itStep(listXmlStep.begin()); itStep != listXmlStep.end(); ++itStep){
34
PParseStep step;
35
PXmlAttr
attrStep;
36
if
(
pxml_getAttrIfExist
(attrStep, *itStep,
"optional"
)){
37
PString val(attrStep.
getValue
());
38
step.setIsOptional(val ==
"true"
|| val ==
"True"
|| val ==
"TRUE"
);
39
}
40
PVecXml
& listCmd(itStep->getVecChild());
41
for
(PVecXml::iterator itCmd(listCmd.begin()); itCmd != listCmd.end(); ++itCmd){
42
PParseCmd cmd;
43
cmd.setStr(
pxml_getFullContent
(*itCmd));
44
PString cmdName(itCmd->getName());
45
bool
isString(cmdName ==
"str"
|| cmdName ==
"s"
);
46
bool
isMatch(cmdName ==
"match"
|| cmdName ==
"m"
);
47
cmd.setIsMatch(isMatch);
48
if
(isString || isMatch){
49
step.getVecCmd().push_back(cmd);
50
}
51
}
52
seq.getVecStep().push_back(step);
53
}
54
}
55
return
true
;
56
}
57
58
60
63
PParseSeq
createSequenceAllMatch
(
const
PVecString & vecStr){
64
PParseSeq seq;
65
for
(PVecString::const_iterator it(vecStr.begin()); it != vecStr.end(); ++it){
66
PParseStep stepBegin;
67
stepBegin.setIsOptional(
false
);
68
PParseCmd cmdBegin;
69
cmdBegin.setIsMatch(
true
);
70
cmdBegin.setStr(*it);
71
stepBegin.getVecCmd().push_back(cmdBegin);
72
seq.getVecStep().push_back(stepBegin);
73
}
74
return
seq;
75
}
76
77
loadParserSeq
bool loadParserSeq(PParseSeq &seq, const PXml &xmlSeq)
Load a ParseSeq with a XML balise.
Definition
PParseSeq_utils.cpp:26
createSequenceAllMatch
PParseSeq createSequenceAllMatch(const PVecString &vecStr)
Create a full sequence of string to match totaly.
Definition
PParseSeq_utils.cpp:63
PParseSeq_utils.h
PXmlAttr
Attribute from xml.
Definition
PXml.h:30
PXmlAttr::getValue
const PString & getValue() const
Get the variable p_value.
Definition
PXml.cpp:82
PXml
Class used to parse xml.
Definition
PXml.h:54
PXml::getName
const PString & getName() const
Get the variable p_name.
Definition
PXml.cpp:194
pxml_getVecChildIfExist
bool pxml_getVecChildIfExist(PVecXml &vecMatch, const PXml &xml, const PString &childName)
Get the vector of childs with given name if exist.
Definition
pxml_utils.cpp:197
pxml_getAttrIfExist
bool pxml_getAttrIfExist(PXmlAttr &attr, const PXml &xml, const PString &attrName)
Get the attribute with given name if exist.
Definition
pxml_utils.cpp:251
pxml_getFullContent
PString pxml_getFullContent(const PXml &xml)
Get the content of the PXml (children or value).
Definition
pxml_utils.cpp:395
pxml_utils.h
PVecXml
std::vector< PXml > PVecXml
Vector of PXml.
Definition
pxml_utils.h:14
src
PParseSeq_utils.cpp
Generated by
1.17.0