1 |
|
#include "xmlpatch.h" |
2 |
|
|
3 |
< |
XmlPatch::XmlPatch(QString patchFilesWildcard, QString forceTargetFilesWildcard, bool noBackups) |
3 |
> |
XmlPatch::XmlPatch(QString patchFilesWildcard, QString forceTargetFilesWildcard, bool noBackups, bool noVerbose) |
4 |
|
{ |
5 |
|
this->patchFilesToProcess=UtilXmlTools::getAllPatchFilesByWildcard(patchFilesWildcard); |
6 |
|
this->forceTargetFilesWildcard=forceTargetFilesWildcard; |
7 |
|
this->backupsEnabled=!noBackups; |
8 |
+ |
this->verboseEnabled=!noVerbose; |
9 |
|
|
10 |
|
if(forceTargetFilesWildcard!=""){ |
11 |
|
std::cout << "User forced patch in the target file(s): " << forceTargetFilesWildcard.toLatin1().constData() << std::endl; |
66 |
|
// Process all XmlFiles |
67 |
|
for(int i=0; i<filesToProcess.size(); i++){ |
68 |
|
|
69 |
< |
UtilXmlTools::loadXmlFile(filesToProcess[i],this->document,this->rootNode,this->backupsEnabled,"@ADD_INSIDE_NODES"); |
69 |
> |
UtilXmlTools::loadXmlFile(filesToProcess[i],this->document,this->rootNode,this->backupsEnabled,this->verboseEnabled,"@ADD_INSIDE_NODES"); |
70 |
|
|
71 |
|
// Check how the element will be fetched via element name or xpath expression |
72 |
|
if(xPathExpression.isEmpty()){ |
97 |
|
} |
98 |
|
|
99 |
|
for(int j=0; j<nodesToInsertion.size(); j++){ |
100 |
< |
nodesToInsertion[j].prepend_copy(newNode.first_child()); // append the new node |
101 |
< |
} |
100 |
> |
for (pugi::xml_node currNodeToInsert = newNode.first_child(); currNodeToInsert; currNodeToInsert = currNodeToInsert.next_sibling()) |
101 |
> |
{ |
102 |
> |
nodesToInsertion[j].append_copy(currNodeToInsert); // append the new node |
103 |
> |
} |
104 |
|
|
105 |
+ |
} |
106 |
|
|
107 |
|
UtilXmlTools::saveXmlFile(filesToProcess[i],this->document, "@ADD_INSIDE_NODES"); |
108 |
+ |
|
109 |
+ |
nodesToInsertion.clear(); |
110 |
|
} |
111 |
|
|
112 |
|
UtilXmlTools::displaySuccessMessage(filesToProcess.size(),"@ADD_INSIDE_NODES"); |
127 |
|
// Process all XmlFiles |
128 |
|
for(int i=0; i<filesToProcess.size(); i++){ |
129 |
|
|
130 |
< |
UtilXmlTools::loadXmlFile(filesToProcess[i],this->document,this->rootNode,this->backupsEnabled,"@REMOVE_NODES"); |
130 |
> |
UtilXmlTools::loadXmlFile(filesToProcess[i],this->document,this->rootNode,this->backupsEnabled,this->verboseEnabled,"@REMOVE_NODES"); |
131 |
|
|
132 |
|
// Check how the element will be fetched via element name or xpath expression |
133 |
|
if(xPathExpression.isEmpty()){ |
178 |
|
} |
179 |
|
|
180 |
|
UtilXmlTools::saveXmlFile(filesToProcess[i],this->document, "@REMOVE_NODES"); |
181 |
+ |
|
182 |
+ |
nodesToDeletion.clear(); |
183 |
|
} |
184 |
|
|
185 |
|
UtilXmlTools::displaySuccessMessage(filesToProcess.size(), "@REMOVE_NODES"); |
250 |
|
for(int i=0; i<filesToProcess.size(); i++){ |
251 |
|
|
252 |
|
if(this->backupsEnabled){ |
253 |
< |
UtilXmlTools::backupFile(filesToProcess[i]); |
253 |
> |
UtilXmlTools::backupFile(filesToProcess[i], this->verboseEnabled); |
254 |
|
} |
255 |
|
|
256 |
|
QFile currXmlFile(filesToProcess[i]); |