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

Go to the source code of this file.

Functions

PParseSeq createSequenceAllMatch (const PVecString &vecStr)
 Create a full sequence of string to match totaly. More...
 
bool loadParserSeq (PParseSeq &seq, const PXml &xmlSeq)
 Load a ParseSeq with a XML balise. More...
 

Function Documentation

◆ createSequenceAllMatch()

PParseSeq createSequenceAllMatch ( const PVecString vecStr)

Create a full sequence of string to match totaly.

Parameters
vecStr: vector of string
Returns
corresponding sequence

Definition at line 63 of file PParseSeq_utils.cpp.

63  {
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 }
Parser command.
Definition: PParseSeq.h:33
void setIsMatch(bool isMatch)
Set the variable p_isMatch, of type 'bool'.
Definition: PParseSeq.cpp:51
void setStr(const PString &str)
Set the variable p_str, of type 'PString'.
Definition: PParseSeq.cpp:58
Parsing sequence.
Definition: PParseSeq.h:77
const std ::vector< PParseStep > & getVecStep() const
Get the variable p_vecStep.
Definition: PParseSeq.cpp:256
Describes a parsing step.
Definition: PParseSeq.h:55
void setIsOptional(bool isOptional)
Set the variable p_isOptional, of type 'bool'.
Definition: PParseSeq.cpp:150
const std ::vector< PParseCmd > & getVecCmd() const
Get the variable p_vecCmd.
Definition: PParseSeq.cpp:178

References PParseStep::getVecCmd(), PParseSeq::getVecStep(), PParseCmd::setIsMatch(), PParseStep::setIsOptional(), and PParseCmd::setStr().

Referenced by checkParseSeqFromVec().

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

◆ loadParserSeq()

bool loadParserSeq ( PParseSeq seq,
const PXml xmlSeq 
)

Load a ParseSeq with a XML balise.

Parameters
[out]seq: ParseSeq to be initialised
xmlSeq: sequence in XML
Returns
true on success, false otherwise Parse a xml such as : <sequence> <step> <str>0123456789</str> </step> <step optional="true"> <match>lu</match> <m>u</m> </step> </sequence> It get a number followed by lu or u or nothing

Definition at line 26 of file PParseSeq_utils.cpp.

26  {
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 }
Extends the std::string.
Definition: PString.h:16
Attribute from xml.
Definition: PXml.h:30
const PString & getValue() const
Get the variable p_value.
Definition: PXml.cpp:82
const PString & getName() const
Get the variable p_name.
Definition: PXml.cpp:194
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
bool pxml_getAttrIfExist(PXmlAttr &attr, const PXml &xml, const PString &attrName)
Get the attribute with given name if exist.
Definition: pxml_utils.cpp:251
PString pxml_getFullContent(const PXml &xml)
Get the content of the PXml (children or value)
Definition: pxml_utils.cpp:395
std::vector< PXml > PVecXml
Vector of PXml.
Definition: pxml_utils.h:14

References PXml::getName(), PXmlAttr::getValue(), PParseStep::getVecCmd(), PParseSeq::getVecStep(), pxml_getAttrIfExist(), pxml_getFullContent(), pxml_getVecChildIfExist(), PParseCmd::setIsMatch(), PParseStep::setIsOptional(), and PParseCmd::setStr().

Referenced by checkParseSeq().

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