8 #define ALLOWED_BALISE_CHAR "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:?!-"
11 #define ALLOWED_ATTRIBUTE_CHAR "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:-"
83 if(attributeName ==
""){
84 std::cerr <<
"pxml_parserXmlAttribute : error at : " << parser.
getLocation() << std::endl;
85 std::cerr <<
"\tcannot parse the attributes name as '"<<parser.
getNextToken()<<
"'" << std::endl;
89 std::cerr <<
"pxml_parserXmlAttribute : error at : " << parser.
getLocation() << std::endl;
90 std::cerr <<
"\texpected '=' after attribute '"<<attributeName<<
"'" << std::endl;
94 std::cerr <<
"pxml_parserXmlAttribute : error at : " << parser.
getLocation() << std::endl;
95 std::cerr <<
"\texpected '\"' after attribute '"<<attributeName<<
"='" << std::endl;
100 tmpAttribute.
setName(attributeName);
101 tmpAttribute.
setValue(attributeValue);
119 PString baliseEnd(
"<" + balisePartialEnd);
124 if(textString !=
""){
127 if(parser.
isMatch(balisePartialEnd)){
142 std::cerr <<
"pxml_parserXmlContent : error at : " << parser.
getLocation() << std::endl;
143 std::cerr <<
"\tunexpected end of file. We are supposed to be in the balise '"<<parent.
getName()<<
"'" << std::endl;
147 if(parser.
isMatch(balisePartialEnd)){
151 if(childBaliseName !=
""){
154 if(childBaliseName ==
"!--"){
156 }
else if(childBaliseName ==
"?xml"){
160 std::cerr <<
"pxml_parserXmlContent : error at : " << parser.
getLocation() << std::endl;
161 std::cerr <<
"\tcannot parse the attributes of balise '"<<childBaliseName<<
"'" << std::endl;
167 std::cerr <<
"pxml_parserXmlContent : error at : " << parser.
getLocation() << std::endl;
168 std::cerr <<
"\tcannot parse balise '"<<childBaliseName<<
"'" << std::endl;
175 std::cerr <<
"pxml_parserXmlContent : in balise '"<<parent.
getName()<<
"' unexpected '</' at : " << parser.
getLocation() << std::endl;
200 for(PVecXml::const_iterator it(vecChild.begin()); it != vecChild.end(); ++it){
201 if(it->getName() == childName){
202 vecMatch.push_back(*it);
216 bool isSearched(
true);
218 PVecXml::const_iterator it(vecChild.begin());
219 while(it != vecChild.end() && isSearched){
220 if(it->getName() == childName){
237 for(PVecXml::iterator it(vecChild.begin()); it != vecChild.end() && out == NULL; ++it){
238 if(it->getName() == childName){
252 bool isSearched(
true);
254 PVecXmlAttr::const_iterator it(vecAttr.begin());
255 while(it != vecAttr.end() && isSearched){
256 if(it->getName() == attrName){
271 bool isSearched(
true);
273 PVecXmlAttr::iterator it(vecAttr.begin());
274 while(it != vecAttr.end() && isSearched){
275 if(it->getName() == nameAttr){
276 it->setValue(valueAttr);
294 for(PVecXml::const_iterator it(vecXml.begin()); it != vecXml.end(); ++it){
295 if(it->getName() != childName){
332 if(name ==
"?xml"){body +=
" ?>\n";}
333 else if(name ==
"!--"){body +=
" -->\n";}
335 body +=
" />"+baseXmlNewLine;
337 body +=
">"+baseXmlNewLine;
340 body +=
"</"+ name +
">" + baseXmlNewLine;
357 for(PVecXml::const_iterator it(vecXml.begin()); it != vecXml.end(); ++it){
383 if(vecXmlAttr.size() == 0lu){
return "";}
385 for(PVecXmlAttr::const_iterator it(vecXmlAttr.begin()); it != vecXmlAttr.end(); ++it){
397 if(vecXml.size() != 0lu){
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
PString getNextToken()
Get the next token.
PString getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.
PString getStrComposedOf(const PString &charset)
Get string composed of the characters in the string charset.
void setWhiteSpace(const PString &whiteSpace)
Initialise la liste des caractères blancs.
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
PLocation getLocation() const
Fonction qui renvoie la PLocation du PFileParser.
void setFileContent(const PString &fileContent)
Set the file content.
bool isEndOfFile() const
Dit si on est à la fin du fichier.
Path of a directory or a file.
bool saveFileContent(const PString &content) const
Save a PString in a file.
PString loadFileContent() const
Get the file content in a PString.
const PString & getName() const
Get the variable p_name.
void setName(const PString &name)
Set the variable p_name, of type 'PString'.
const PString & getValue() const
Get the variable p_value.
void setValue(const PString &value)
Set the variable p_value, of type 'PString'.
bool getIsText() const
Get the variable p_isText.
void setVecAttr(const std ::vector< PXmlAttr > &vecAttr)
Set the variable p_vecAttr, of type 'std ::vector<PXmlAttr>'.
void setValue(const PString &value)
Set the variable p_value, of type 'PString'.
const std ::vector< PXml > & getVecChild() const
Get the variable p_vecChild.
void setIsText(bool isText)
Set the variable p_isText, of type 'bool'.
void setIsCompact(bool isCompact)
Set the variable p_isCompact, of type 'bool'.
const PString & getValue() const
Get the variable p_value.
bool getIsCompact() const
Get the variable p_isCompact.
const std ::vector< PXmlAttr > & getVecAttr() const
Get the variable p_vecAttr.
void setName(const PString &name)
Set the variable p_name, of type 'PString'.
const PString & getName() const
Get the variable p_name.
bool pxml_isAttributeEnd(PXml &parent, PFileParser &parser)
Say if it is the end of the attribute definition of the current balise.
PString pxml_attrStr(const PXmlAttr &xmlAttr, bool isSvg)
Convert attribute in string.
bool pxml_getVecChildIfExist(PVecXml &vecMatch, const PXml &xml, const PString &childName)
Get the vector of childs with given name if exist.
PXml pxml_eraseVecChild(const PXml &xml, const PString &childName)
Erase the childs of the current xml if it has childName as name.
bool pxml_getAttrIfExist(PXmlAttr &attr, const PXml &xml, const PString &attrName)
Get the attribute with given name if exist.
PString pxml_vecAttrStr(const PVecXmlAttr &vecXmlAttr, bool isSvg)
Convert attributes in string.
bool pxml_saveFile(const PPath &fileName, const PXml &xml, bool isSvg)
Save a xml in a file.
bool pxml_parserXmlAttribute(PXml &parent, PFileParser &parser)
Parse the attribute of a xml balise.
#define ALLOWED_BALISE_CHAR
List of allowed char as balise name.
PString pxml_baliseStr(const PXml &xml, bool isSvg)
Convert xml in string.
void pxml_setAttr(PXml &xml, const PString &nameAttr, const PString &valueAttr)
Set a value to an attribute.
PString pxml_getFullContent(const PXml &xml)
Get the content of the PXml (children or value)
PFileParser pxml_setXmlParser(const PString &fileContent, bool isSvg)
Set the PFileParser for xml.
bool pxml_parserFile(PXml &xml, const PPath &fileName, bool isSvg)
Parse a PXml with a file.
bool pxml_getChildIfExist(PXml &match, const PXml &xml, const PString &childName)
Get the child with given name if exist.
PXml * pxml_getChildPtr(PXml &xml, const PString &childName)
Get the child with given name if exist.
#define ALLOWED_ATTRIBUTE_CHAR
List of allowed char as attribute name.
bool pxml_parserXmlContent(PXml &parent, PFileParser &parser, bool isMainBalise)
Parse the content of an xml balise.
PString pxml_vecXmlStr(const PVecXml &vecXml, bool isSvg)
Convert a vecto of xml in string.
bool pxml_parserContent(PXml &xml, const PString &fileContent, bool isSvg)
Parse a PXml with a file content.
std::vector< PXmlAttr > PVecXmlAttr
Vector of PXml.
std::vector< PXml > PVecXml
Vector of PXml.