| 198 |
|
} |
| 199 |
|
|
| 200 |
|
std::cout << "@COMMAND patch operation output:\n" |
| 201 |
< |
<< "########################################################################" |
| 202 |
< |
<< std::endl; |
| 201 |
> |
<< "########################################################################" |
| 202 |
> |
<< std::endl; |
| 203 |
|
|
| 204 |
|
OptionsParser myParser(Util::QStringToArgsArray(commandString)); |
| 205 |
|
myParser.parse(); |
| 206 |
|
|
| 207 |
|
std::cout |
| 208 |
< |
<< "########################################################################" |
| 209 |
< |
<< std::endl; |
| 208 |
> |
<< "########################################################################" |
| 209 |
> |
<< std::endl; |
| 210 |
|
|
| 211 |
|
UtilXmlTools::displaySuccessMessage(1,"@COMMAND"); |
| 212 |
|
} |
| 220 |
|
|
| 221 |
|
void XmlPatch::executeCustomCommandOperation(const QString &jsString, const QString &filesWildcard){ |
| 222 |
|
|
| 223 |
< |
QStringList filesToProcess; |
| 224 |
< |
#ifdef _USE_OLD_JS_ENGINE |
| 225 |
< |
QScriptEngine engine; |
| 226 |
< |
QScriptValue engineResult; // variable to check for js_errors |
| 227 |
< |
#else |
| 228 |
< |
QJSEngine engine; |
| 229 |
< |
QJSValue engineResult; // variable to check for js_errors |
| 230 |
< |
#endif |
| 231 |
< |
|
| 232 |
< |
QString rexmlString, jsxmlString, currXmlFileString; |
| 233 |
< |
|
| 234 |
< |
|
| 235 |
< |
QFile rexmlfile(":/resources/libs/rexml.js"); |
| 236 |
< |
QFile jsxmlfile(":/resources/libs/jsxml.js"); |
| 237 |
< |
|
| 238 |
< |
// Add echo function so user can debug the code |
| 239 |
< |
QScriptValue echoFunction = engine.newFunction(echo); |
| 240 |
< |
engine.globalObject().setProperty("echo", echoFunction); |
| 241 |
< |
|
| 242 |
< |
filesToProcess=UtilXmlTools::getAllXmlFilesByWildcard(filesWildcard); |
| 223 |
> |
QString rexmlString, jsxmlString; |
| 224 |
> |
QStringList filesToProcess=UtilXmlTools::getAllXmlFilesByWildcard(filesWildcard); |
| 225 |
|
|
| 226 |
|
if(filesToProcess.isEmpty()){ |
| 227 |
|
UtilXmlTools::displayErrorMessage("@CUSTOM_CODE","No XML files were found for the wildcard: "+filesWildcard); |
| 228 |
|
} |
| 229 |
|
|
| 230 |
+ |
QFile rexmlfile(":/resources/libs/rexml.js"); |
| 231 |
+ |
QFile jsxmlfile(":/resources/libs/jsxml.js"); |
| 232 |
+ |
|
| 233 |
|
rexmlfile.open(QFile::ReadOnly | QFile::Text); |
| 234 |
|
jsxmlfile.open(QFile::ReadOnly | QFile::Text); |
| 235 |
|
|
| 236 |
|
rexmlString=QTextStream(&rexmlfile).readAll(); |
| 237 |
|
jsxmlString=QTextStream(&jsxmlfile).readAll(); |
| 238 |
|
|
| 254 |
– |
engine.evaluate(rexmlString); // load js libraries |
| 255 |
– |
engine.evaluate(jsxmlString); |
| 256 |
– |
|
| 239 |
|
// Process all XmlFiles |
| 240 |
+ |
#pragma omp parallel for |
| 241 |
|
for(int i=0; i<filesToProcess.size(); i++){ |
| 242 |
|
|
| 243 |
+ |
QString currXmlFileString; |
| 244 |
+ |
|
| 245 |
+ |
#ifdef _USE_OLD_JS_ENGINE |
| 246 |
+ |
QScriptEngine engine; |
| 247 |
+ |
QScriptValue engineResult; // variable to check for js_errors |
| 248 |
+ |
#else |
| 249 |
+ |
QJSEngine engine; |
| 250 |
+ |
QJSValue engineResult; // variable to check for js_errors |
| 251 |
+ |
#endif |
| 252 |
+ |
|
| 253 |
+ |
// Add echo function so user can debug the code |
| 254 |
+ |
QScriptValue echoFunction = engine.newFunction(echo); |
| 255 |
+ |
engine.globalObject().setProperty("echo", echoFunction); |
| 256 |
+ |
|
| 257 |
+ |
engine.evaluate(rexmlString); // load js libraries |
| 258 |
+ |
engine.evaluate(jsxmlString); |
| 259 |
+ |
|
| 260 |
|
if(this->backupsEnabled){ |
| 261 |
|
UtilXmlTools::backupFile(filesToProcess[i], this->verboseEnabled); |
| 262 |
|
} |