1 |
|
#include "xmltools.h" |
2 |
|
|
3 |
|
// Filters constructor |
4 |
< |
XmlTools::XmlTools(QString filesWildcard, XmlFilter filter, bool noBackups) |
4 |
> |
XmlTools::XmlTools(QString filesWildcard, XmlFilter filter, bool noBackups, bool noVerbose) |
5 |
|
{ |
6 |
|
this->filesToProcess=UtilXmlTools::getAllXmlFilesByWildcard(filesWildcard); |
7 |
|
this->filters=filter; |
8 |
|
this->backupsEnabled=!noBackups; |
9 |
+ |
this->verboseEnabled=!noVerbose; |
10 |
|
|
11 |
|
if(this->filesToProcess.isEmpty()){ |
12 |
|
UtilXmlTools::displayErrorMessage("Loading xml files","No XML files were found for the wildcard: "+filesWildcard); |
14 |
|
} |
15 |
|
|
16 |
|
// XPath constructor |
17 |
< |
XmlTools::XmlTools(QString filesWildcard, QString xPathExpression, bool noBackups) |
17 |
> |
XmlTools::XmlTools(QString filesWildcard, QString xPathExpression, bool noBackups, bool noVerbose) |
18 |
|
{ |
19 |
|
this->filesToProcess=UtilXmlTools::getAllXmlFilesByWildcard(filesWildcard); |
20 |
|
this->xPathExpression=xPathExpression; |
21 |
|
this->backupsEnabled=!noBackups; |
22 |
+ |
this->verboseEnabled=!noVerbose; |
23 |
|
} |
24 |
|
|
25 |
|
// Adds new values to an element |
31 |
|
QStringList newValuesList, currValuesList; |
32 |
|
QList<pugi::xml_node> elements; |
33 |
|
|
34 |
< |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled,"add-values"); |
34 |
> |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled,this->verboseEnabled,"add-values"); |
35 |
|
|
36 |
|
newValuesList=Util::qStringListFromSpacedString(newValues); |
37 |
|
|
72 |
|
QStringList valuesToRemoveList, currValuesList; |
73 |
|
bool elementChanged=false; |
74 |
|
|
75 |
< |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, "remove-values"); |
75 |
> |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, this->verboseEnabled, "remove-values"); |
76 |
|
|
77 |
|
// Check how the elements will be fetched via element name or xpath expression |
78 |
|
if(this->xPathExpression==""){ |
119 |
|
QStringList currValuesList; |
120 |
|
bool elementChanged=false; |
121 |
|
|
122 |
< |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, "replace-value"); |
122 |
> |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, this->verboseEnabled, "replace-value"); |
123 |
|
|
124 |
|
// Check how the elements will be fetched via element name or xpath expression |
125 |
|
if(this->xPathExpression==""){ |
159 |
|
|
160 |
|
QList<pugi::xml_node> elements; |
161 |
|
|
162 |
< |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, "replace-all"); |
162 |
> |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, this->verboseEnabled, "replace-all"); |
163 |
|
|
164 |
|
// Check how the elements will be fetched via element name or xpath expression |
165 |
|
if(this->xPathExpression==""){ |
199 |
|
MultiDimVar currXmlValue(0); |
200 |
|
MultiDimVar newXmlValue(0); // value that will update currValue |
201 |
|
|
202 |
< |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, "update-elements"); |
202 |
> |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled,this->verboseEnabled, "update-elements"); |
203 |
|
|
204 |
|
// Check how the elements will be fetched via element name or xpath expression |
205 |
|
if(this->xPathExpression==""){ |
243 |
|
|
244 |
|
// Process all XmlFiles |
245 |
|
for(int i=0; i<this->filesToProcess.size(); i++){ |
246 |
< |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, "invert-elements"); |
246 |
> |
UtilXmlTools::loadXmlFile(this->filesToProcess[i],this->document,this->rootNode,this->backupsEnabled, this->verboseEnabled, "invert-elements"); |
247 |
|
|
248 |
|
QList<pugi::xml_node> elements; |
249 |
|
QStringList invertedElements; //Inverting the element order |