ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/XmlTools2/trunk/xmlpatch.cpp
(Generate patch)

Comparing XmlTools2/trunk/xmlpatch.cpp (file contents):
Revision 920 by s10k, Sun Feb 2 18:50:10 2014 UTC vs.
Revision 923 by s10k, Mon Feb 3 15:42:14 2014 UTC

# Line 1 | Line 1
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;
# Line 65 | Line 66 | void XmlPatch::insertNodesOperation(cons
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()){
# Line 96 | Line 97 | void XmlPatch::insertNodesOperation(cons
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");
# Line 121 | Line 127 | void XmlPatch::removeNodesOperation(XmlF
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()){
# Line 172 | Line 178 | void XmlPatch::removeNodesOperation(XmlF
178          }
179  
180          UtilXmlTools::saveXmlFile(filesToProcess[i],this->document, "@REMOVE_NODES");
181 +
182 +        nodesToDeletion.clear();
183      }
184  
185      UtilXmlTools::displaySuccessMessage(filesToProcess.size(), "@REMOVE_NODES");
# Line 242 | Line 250 | void XmlPatch::executeCustomCommandOpera
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]);

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)