changed to explicit std namespace.
This commit is contained in:
parent
572e0f96a5
commit
a4eb96a4a9
@ -28,7 +28,6 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -81,7 +80,7 @@ int PmuppScript::executeScript()
|
|||||||
{
|
{
|
||||||
fParamDataHandler = new PParamDataHandler();
|
fParamDataHandler = new PParamDataHandler();
|
||||||
if (fParamDataHandler == 0) {
|
if (fParamDataHandler == 0) {
|
||||||
cerr << endl << "**ERROR** couldn't invoke data handler ..." << endl << endl;
|
std::cerr << std::endl << "**ERROR** couldn't invoke data handler ..." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,8 +108,12 @@ int PmuppScript::executeScript()
|
|||||||
status = plot(cmd);
|
status = plot(cmd);
|
||||||
} else if (cmd.startsWith("macro")) {
|
} else if (cmd.startsWith("macro")) {
|
||||||
status = macro(cmd);
|
status = macro(cmd);
|
||||||
|
} else if (cmd.startsWith("var")) {
|
||||||
|
std::cout << "debug> will eventually handle variable definition here ..." << std::endl;
|
||||||
|
} else if (cmd.startsWith("col")) {
|
||||||
|
std::cout << "debug> will eventually handle linking of a variable to a collection ..." << std::endl;
|
||||||
} else {
|
} else {
|
||||||
cerr << "**ERROR** found unkown script command '" << cmd.toLatin1().constData() << "'." << endl << endl;
|
std::cerr << "**ERROR** found unkown script command '" << cmd.toLatin1().constData() << "'." << std::endl << std::endl;
|
||||||
status = -2;
|
status = -2;
|
||||||
}
|
}
|
||||||
// check for errors
|
// check for errors
|
||||||
@ -224,7 +227,7 @@ int PmuppScript::select(const QString str)
|
|||||||
QString cmd = str;
|
QString cmd = str;
|
||||||
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl << "**ERROR** wrong 'select' command syntax." << endl << endl;
|
std::cerr << std::endl << "**ERROR** wrong 'select' command syntax." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,18 +235,18 @@ int PmuppScript::select(const QString str)
|
|||||||
int ival = tok[1].toInt(&ok);
|
int ival = tok[1].toInt(&ok);
|
||||||
if (ok) { // collection index given
|
if (ok) { // collection index given
|
||||||
if (ival >= fParamDataHandler->GetNoOfCollections()) {
|
if (ival >= fParamDataHandler->GetNoOfCollections()) {
|
||||||
cerr << endl << "**ERROR** try to select a collection with index " << ival << ", which is >= # collections (" << fParamDataHandler->GetNoOfCollections() << ")." << endl << endl;
|
std::cerr << std::endl << "**ERROR** try to select a collection with index " << ival << ", which is >= # collections (" << fParamDataHandler->GetNoOfCollections() << ")." << std::endl << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
fSelected = ival;
|
fSelected = ival;
|
||||||
} else { // assume that a collection name is given
|
} else { // assume that a collection name is given
|
||||||
ival = fParamDataHandler->GetCollectionIndex(tok[1]);
|
ival = fParamDataHandler->GetCollectionIndex(tok[1]);
|
||||||
if (ival == -1) {
|
if (ival == -1) {
|
||||||
cerr << endl << "**ERROR** couldn't find collection '" << tok[1].toLatin1().constData() << "'." << endl << endl;
|
std::cerr << std::endl << "**ERROR** couldn't find collection '" << tok[1].toLatin1().constData() << "'." << std::endl << std::endl;
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if (ival >= fParamDataHandler->GetNoOfCollections()) {
|
if (ival >= fParamDataHandler->GetNoOfCollections()) {
|
||||||
cerr << endl << "**ERROR** try to select a collection with index " << ival << ", which is >= # collections (" << fParamDataHandler->GetNoOfCollections() << ")." << endl << endl;
|
std::cerr << std::endl << "**ERROR** try to select a collection with index " << ival << ", which is >= # collections (" << fParamDataHandler->GetNoOfCollections() << ")." << std::endl << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
fSelected = ival;
|
fSelected = ival;
|
||||||
@ -263,7 +266,7 @@ int PmuppScript::selectAll()
|
|||||||
if ( noColl > 0) {
|
if ( noColl > 0) {
|
||||||
fSelected = -1; // all collections are selected
|
fSelected = -1; // all collections are selected
|
||||||
} else {
|
} else {
|
||||||
cerr << endl << "**ERROR** no collections present, hence it is not possible to select them." << endl << endl;
|
std::cerr << std::endl << "**ERROR** no collections present, hence it is not possible to select them." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,14 +285,14 @@ int PmuppScript::addX(const QString str)
|
|||||||
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
||||||
|
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl << "**ERROR** in addX: number of tokens missmatch." << endl << endl;
|
std::cerr << std::endl << "**ERROR** in addX: number of tokens missmatch." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
label = tok[1].trimmed();
|
label = tok[1].trimmed();
|
||||||
|
|
||||||
PmuppCollection *coll=0;
|
PmuppCollection *coll=0;
|
||||||
if (fSelected == -2) { // no selection -> error
|
if (fSelected == -2) { // no selection -> error
|
||||||
cerr << endl << "**ERROR** in addX. addX called without previous 'select' command." << endl << endl;
|
std::cerr << std::endl << "**ERROR** in addX. addX called without previous 'select' command." << std::endl << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
} else if (fSelected == -1) { // i.e. select ALL
|
} else if (fSelected == -1) { // i.e. select ALL
|
||||||
// clean up plot info first
|
// clean up plot info first
|
||||||
@ -299,7 +302,7 @@ int PmuppScript::addX(const QString str)
|
|||||||
for (int i=0; i<fParamDataHandler->GetNoOfCollections(); i++) {
|
for (int i=0; i<fParamDataHandler->GetNoOfCollections(); i++) {
|
||||||
coll = fParamDataHandler->GetCollection(i);
|
coll = fParamDataHandler->GetCollection(i);
|
||||||
if (!foundLabel(coll, label)) { // label not found
|
if (!foundLabel(coll, label)) { // label not found
|
||||||
cerr << endl << "**ERROR** couldn't find '" << label.toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << endl << endl;
|
std::cerr << std::endl << "**ERROR** couldn't find '" << label.toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << std::endl << std::endl;
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,11 +319,11 @@ int PmuppScript::addX(const QString str)
|
|||||||
// check that label is found in the selected collection
|
// check that label is found in the selected collection
|
||||||
coll = fParamDataHandler->GetCollection(fSelected);
|
coll = fParamDataHandler->GetCollection(fSelected);
|
||||||
if (coll == 0) {
|
if (coll == 0) {
|
||||||
cerr << endl << "**ERROR** in addX: selected collection couldn't be found ..." << endl << endl;
|
std::cerr << std::endl << "**ERROR** in addX: selected collection couldn't be found ..." << std::endl << std::endl;
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
if (!foundLabel(coll, label)) { // label not found
|
if (!foundLabel(coll, label)) { // label not found
|
||||||
cerr << endl << "**ERROR** couldn't find '" << label.toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << endl << endl;
|
std::cerr << std::endl << "**ERROR** couldn't find '" << label.toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << std::endl << std::endl;
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +348,7 @@ int PmuppScript::addY(const QString str)
|
|||||||
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
||||||
|
|
||||||
if (tok.size() < 2) {
|
if (tok.size() < 2) {
|
||||||
cerr << endl << "**ERROR** in addY: number of tokens < 2." << endl << endl;
|
std::cerr << std::endl << "**ERROR** in addY: number of tokens < 2." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// collect all potential labels
|
// collect all potential labels
|
||||||
@ -354,7 +357,7 @@ int PmuppScript::addY(const QString str)
|
|||||||
|
|
||||||
PmuppCollection *coll=0;
|
PmuppCollection *coll=0;
|
||||||
if (fSelected == -2) { // no selection -> error
|
if (fSelected == -2) { // no selection -> error
|
||||||
cerr << endl << "**ERROR** in addY. addY called without previous 'select' command." << endl << endl;
|
std::cerr << std::endl << "**ERROR** in addY. addY called without previous 'select' command." << std::endl << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
} else if (fSelected == -1) { // i.e. select ALL
|
} else if (fSelected == -1) { // i.e. select ALL
|
||||||
// make sure that label(s) is/are found in ALL collections
|
// make sure that label(s) is/are found in ALL collections
|
||||||
@ -362,7 +365,7 @@ int PmuppScript::addY(const QString str)
|
|||||||
coll = fParamDataHandler->GetCollection(i);
|
coll = fParamDataHandler->GetCollection(i);
|
||||||
for (int j=0; j<label.size(); j++) {
|
for (int j=0; j<label.size(); j++) {
|
||||||
if (!foundLabel(coll, label[j])) { // label not found
|
if (!foundLabel(coll, label[j])) { // label not found
|
||||||
cerr << endl << "**ERROR** couldn't find '" << label[j].toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << endl << endl;
|
std::cerr << std::endl << "**ERROR** couldn't find '" << label[j].toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << std::endl << std::endl;
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -379,13 +382,13 @@ int PmuppScript::addY(const QString str)
|
|||||||
// check that label is found in the selected collection
|
// check that label is found in the selected collection
|
||||||
coll = fParamDataHandler->GetCollection(fSelected);
|
coll = fParamDataHandler->GetCollection(fSelected);
|
||||||
if (coll == 0) {
|
if (coll == 0) {
|
||||||
cerr << endl << "**ERROR** in addY: selected collection couldn't be found ..." << endl << endl;
|
std::cerr << std::endl << "**ERROR** in addY: selected collection couldn't be found ..." << std::endl << std::endl;
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<label.size(); i++) {
|
for (int i=0; i<label.size(); i++) {
|
||||||
if (!foundLabel(coll, label[i])) { // label not found
|
if (!foundLabel(coll, label[i])) { // label not found
|
||||||
cerr << endl << "**ERROR** couldn't find '" << label[i].toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << endl << endl;
|
std::cerr << std::endl << "**ERROR** couldn't find '" << label[i].toLatin1().constData() << "' in collection '" << coll->GetName().toLatin1().constData() << "'" << std::endl << std::endl;
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,21 +413,21 @@ int PmuppScript::plot(const QString str)
|
|||||||
QString cmd = str;
|
QString cmd = str;
|
||||||
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl << "**ERROR** in plot: number of tokens != 2." << endl << endl;
|
std::cerr << std::endl << "**ERROR** in plot: number of tokens != 2." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
QString flnOut = fSavePath + tok[1];
|
QString flnOut = fSavePath + tok[1];
|
||||||
QString macroOut = fSavePath + "__out.C";
|
QString macroOut = fSavePath + "__out.C";
|
||||||
|
|
||||||
if (macro(QString("macro " + macroOut), flnOut) != 0) {
|
if (macro(QString("macro " + macroOut), flnOut) != 0) {
|
||||||
cerr << endl << "**ERROR** temporary macro generation failed." << endl << endl;
|
std::cerr << std::endl << "**ERROR** temporary macro generation failed." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// call root via batch
|
// call root via batch
|
||||||
QProcess *proc = new QProcess(this);
|
QProcess *proc = new QProcess(this);
|
||||||
if (proc == nullptr) {
|
if (proc == nullptr) {
|
||||||
cerr << endl << "**ERROR** couldn't invoke root.exe in batch mode." << endl << endl;
|
std::cerr << std::endl << "**ERROR** couldn't invoke root.exe in batch mode." << std::endl << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +444,7 @@ int PmuppScript::plot(const QString str)
|
|||||||
proc->setWorkingDirectory(fSavePath);
|
proc->setWorkingDirectory(fSavePath);
|
||||||
proc->start(exec_cmd, arg);
|
proc->start(exec_cmd, arg);
|
||||||
if (!proc->waitForStarted()) {
|
if (!proc->waitForStarted()) {
|
||||||
cerr << endl << "**ERROR** Could not execute the output command: " << exec_cmd.toLatin1().constData() << endl << endl;
|
std::cerr << std::endl << "**ERROR** Could not execute the output command: " << exec_cmd.toLatin1().constData() << std::endl << std::endl;
|
||||||
QFile::remove(macroOut);
|
QFile::remove(macroOut);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
@ -467,7 +470,7 @@ int PmuppScript::macro(const QString str, const QString plotFln)
|
|||||||
QString cmd = str;
|
QString cmd = str;
|
||||||
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
QStringList tok = cmd.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl << "**ERROR** macro command with wrong number of arguments (" << tok.size() << ")." << endl << endl;
|
std::cerr << std::endl << "**ERROR** macro command with wrong number of arguments (" << tok.size() << ")." << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
QString macroName = tok[1].trimmed();
|
QString macroName = tok[1].trimmed();
|
||||||
@ -475,7 +478,7 @@ int PmuppScript::macro(const QString str, const QString plotFln)
|
|||||||
QString fln = fSavePath + macroName;
|
QString fln = fSavePath + macroName;
|
||||||
QFile file(fln);
|
QFile file(fln);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
cerr << endl << "**ERROR** Couldn't open macro file for writting." << endl << endl;
|
std::cerr << std::endl << "**ERROR** Couldn't open macro file for writting." << std::endl << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
@ -37,6 +36,7 @@ using namespace std;
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
#include "mupp_version.h"
|
#include "mupp_version.h"
|
||||||
#include "PmuppScript.h"
|
#include "PmuppScript.h"
|
||||||
@ -48,40 +48,40 @@ using namespace std;
|
|||||||
*/
|
*/
|
||||||
void mupp_syntax()
|
void mupp_syntax()
|
||||||
{
|
{
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
cout << "usage: mupp [OPTIONS] [[--path <fit-param-path>] <fit-param-file-names>]" << endl;
|
std::cout << "usage: mupp [OPTIONS] [[--path <fit-param-path>] <fit-param-file-names>]" << std::endl;
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
cout << "OPTIONS:" << endl;
|
std::cout << "OPTIONS:" << std::endl;
|
||||||
cout << " -h, --help: this help" << endl;
|
std::cout << " -h, --help: this help" << std::endl;
|
||||||
cout << " -v, --version: current mupp version" << endl;
|
std::cout << " -v, --version: current mupp version" << std::endl;
|
||||||
cout << " -s <fln>, --script <fln>: <fln> being a mupp script." << endl;
|
std::cout << " -s <fln>, --script <fln>: <fln> being a mupp script." << std::endl;
|
||||||
cout << " --path <fit-param-path>: path where to look for the <fit-param-file-names>" << endl;
|
std::cout << " --path <fit-param-path>: path where to look for the <fit-param-file-names>" << std::endl;
|
||||||
cout << " <fit-param-file-names>: list of file name(s) to be loaded." << endl;
|
std::cout << " <fit-param-file-names>: list of file name(s) to be loaded." << std::endl;
|
||||||
cout << " allowed formats are: db, dat, msr" << endl << endl;
|
std::cout << " allowed formats are: db, dat, msr" << std::endl << std::endl;
|
||||||
cout << "SCRIPT COMMANDS:" << endl;
|
std::cout << "SCRIPT COMMANDS:" << std::endl;
|
||||||
cout << " Lines starting with '#', '%', or '//' are comments and will be ignored." << endl;
|
std::cout << " Lines starting with '#', '%', or '//' are comments and will be ignored." << std::endl;
|
||||||
cout << " The same is true for empty lines. Comments are also allowed at the end" << endl;
|
std::cout << " The same is true for empty lines. Comments are also allowed at the end" << std::endl;
|
||||||
cout << " for a command, i.e. loadPath ./ # the best place ever." << endl;
|
std::cout << " for a command, i.e. loadPath ./ # the best place ever." << std::endl;
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
cout << " loadPath <dir> : set the load path to <dir>. Bash variables like" << endl;
|
std::cout << " loadPath <dir> : set the load path to <dir>. Bash variables like" << std::endl;
|
||||||
cout << " $HOME are accepted." << endl;
|
std::cout << " $HOME are accepted." << std::endl;
|
||||||
cout << " load <coll> : will load a collection <coll>. Currently *.db and *.dat" << endl;
|
std::cout << " load <coll> : will load a collection <coll>. Currently *.db and *.dat" << std::endl;
|
||||||
cout << " are handled." << endl;
|
std::cout << " are handled." << std::endl;
|
||||||
cout << " selectAll : will select all loaded collections. Thie means every plot" << endl;
|
std::cout << " selectAll : will select all loaded collections. Thie means every plot" << std::endl;
|
||||||
cout << " of variable x/y will be carried out to ALL collections." << endl;
|
std::cout << " of variable x/y will be carried out to ALL collections." << std::endl;
|
||||||
cout << " select <nn> : selects collection <nn>, where <nn> is either the number" << endl;
|
std::cout << " select <nn> : selects collection <nn>, where <nn> is either the number" << std::endl;
|
||||||
cout << " of the collections, or its name, e.g. " << endl;
|
std::cout << " of the collections, or its name, e.g. " << std::endl;
|
||||||
cout << " select YBCO-40nm-T5K-FC150mT-Escan.db" << endl;
|
std::cout << " select YBCO-40nm-T5K-FC150mT-Escan.db" << std::endl;
|
||||||
cout << " x <label> : add <label> as a x-variable. Only one is allowed." << endl;
|
std::cout << " x <label> : add <label> as a x-variable. Only one is allowed." << std::endl;
|
||||||
cout << " y <label(s)> : add <label(s)> as y-variable. Multiple labls are possible." << endl;
|
std::cout << " y <label(s)> : add <label(s)> as y-variable. Multiple labls are possible." << std::endl;
|
||||||
cout << " norm : normalize data to maximum." << endl;
|
std::cout << " norm : normalize data to maximum." << std::endl;
|
||||||
cout << " savePath <dir> : set the save path to <dir>. The place where the macros," << endl;
|
std::cout << " savePath <dir> : set the save path to <dir>. The place where the macros," << std::endl;
|
||||||
cout << " and/or the plot output will be saved." << endl;
|
std::cout << " and/or the plot output will be saved." << std::endl;
|
||||||
cout << " plot <fln> : where <fln> is the file name with extension under which" << endl;
|
std::cout << " plot <fln> : where <fln> is the file name with extension under which" << std::endl;
|
||||||
cout << " the plot should be saved." << endl;
|
std::cout << " the plot should be saved." << std::endl;
|
||||||
cout << " macro <fln> : where <fln> is the file name under which the root macro" << endl;
|
std::cout << " macro <fln> : where <fln> is the file name under which the root macro" << std::endl;
|
||||||
cout << " should be saved." << endl;
|
std::cout << " should be saved." << std::endl;
|
||||||
cout << endl;
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -95,10 +95,10 @@ int mupp_script_read(const char *fln, QStringList &list)
|
|||||||
{
|
{
|
||||||
QFile file(fln);
|
QFile file(fln);
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
cerr << "**ERROR** couldn't open '" << fln << "'." << endl;
|
std::cerr << "**ERROR** couldn't open '" << fln << "'." << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +149,26 @@ bool mupp_bash_variable_exists(const QString str)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------
|
||||||
|
void mupp_script_syntax()
|
||||||
|
{
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << " Currently supported script commands:" << std::endl;
|
||||||
|
std::cerr << " load <coll(s)> : where <coll(s)> is a file-name-list of collections (*.db, *.dat)" << std::endl;
|
||||||
|
std::cerr << " loadPath <path> : where <path> is the load path accepting bash variables like $HOME, etc." << std::endl;
|
||||||
|
std::cerr << " x <var-name> : where <var-name> is a data tag of the db/dat-file." << std::endl;
|
||||||
|
std::cerr << " y <var-name> : where <var-name> is a data tag of the db/dat-file." << std::endl;
|
||||||
|
std::cerr << " select <nn> : where <nn> is the row-number or collection name of the collection to be selected." << std::endl;
|
||||||
|
std::cerr << " selectAll : i.e. already set addX, addY will apply to ALL collections present." << std::endl;
|
||||||
|
std::cerr << " savePath <path> : where <path> is the save path accepting bash variables like $HOME, etc." << std::endl;
|
||||||
|
std::cerr << " plot <fln> : where <fln> is the file name with extension under which the plot should be saved." << std::endl;
|
||||||
|
std::cerr << " macro <fln> : where <fln> is the file name under which the root macro should be saved." << std::endl;
|
||||||
|
std::cerr << " var <var_name> = <expr> : defines a variable." << std::endl;
|
||||||
|
std::cerr << " col <nn> : <var_name> : links <var_name> to the collection <nn>, where <nn> is the number of the" << std::endl;
|
||||||
|
std::cerr << " collection as defined by the order of load, starting with 0." << std::endl;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief mupp_script_syntax_check
|
* @brief mupp_script_syntax_check
|
||||||
@ -159,16 +179,19 @@ int mupp_script_syntax_check(QStringList &list)
|
|||||||
{
|
{
|
||||||
QString str;
|
QString str;
|
||||||
QStringList tok;
|
QStringList tok;
|
||||||
|
QVector<QString> var_names;
|
||||||
|
QVector<bool> var_linked;
|
||||||
|
int noOfCollections = 0;
|
||||||
for (int i=0; i<list.size(); i++) {
|
for (int i=0; i<list.size(); i++) {
|
||||||
tok.clear();
|
tok.clear();
|
||||||
str = list.at(i);
|
str = list.at(i);
|
||||||
if (str.startsWith("loadPath")) {
|
if (str.startsWith("loadPath")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() < 2) {
|
if (tok.size() < 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. <path> is missing." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. <path> is missing." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
tok.clear();
|
tok.clear();
|
||||||
@ -179,10 +202,10 @@ int mupp_script_syntax_check(QStringList &list)
|
|||||||
for (int i=0; i<tok.size(); i++) {
|
for (int i=0; i<tok.size(); i++) {
|
||||||
if (tok.at(i).startsWith("$")) {
|
if (tok.at(i).startsWith("$")) {
|
||||||
if (!mupp_bash_variable_exists(tok.at(i))) {
|
if (!mupp_bash_variable_exists(tok.at(i))) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found in command '" << list.at(i).toLatin1().constData() << "' an empty bash variable '" << tok.at(i).toLatin1().constData() << "'." << endl;
|
std::cerr << "**SYNTAX ERROR** found in command '" << list.at(i).toLatin1().constData() << "' an empty bash variable '" << tok.at(i).toLatin1().constData() << "'." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,63 +213,64 @@ int mupp_script_syntax_check(QStringList &list)
|
|||||||
} else if (str.startsWith("load")) {
|
} else if (str.startsWith("load")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() < 2) {
|
if (tok.size() < 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. At least one collection file name is expected." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. At least one collection file name is expected." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
noOfCollections++;
|
||||||
} else if (str.startsWith("x")) {
|
} else if (str.startsWith("x")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one variable name is accepted." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one variable name is accepted." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("y")) {
|
} else if (str.startsWith("y")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() < 2) {
|
if (tok.size() < 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. At least one variable name is needed." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. At least one variable name is needed." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("select ")) {
|
} else if (str.startsWith("select ")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one row-number of collection name is accepted." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one row-number of collection name is accepted." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("selectAll")) {
|
} else if (str.startsWith("selectAll")) {
|
||||||
if (str.compare("selectAll")) {
|
if (str.compare("selectAll")) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. selectAll doesn't accept any options." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. selectAll doesn't accept any options." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("savePath")) {
|
} else if (str.startsWith("savePath")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one save path is accepted." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one save path is accepted." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("plot")) {
|
} else if (str.startsWith("plot")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one file name is accepted." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one file name is accepted." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// check extension
|
// check extension
|
||||||
@ -255,20 +279,20 @@ int mupp_script_syntax_check(QStringList &list)
|
|||||||
QString ext = tok.at(tok.size()-1);
|
QString ext = tok.at(tok.size()-1);
|
||||||
ext = ext.toLower();
|
ext = ext.toLower();
|
||||||
if ((ext != "pdf") && (ext != "jpg") && (ext != "png") && (ext != "svg") && (ext != "gif")) {
|
if ((ext != "pdf") && (ext != "jpg") && (ext != "png") && (ext != "svg") && (ext != "gif")) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found extension " << ext.toLatin1().constData() << " in '" << str.toLatin1().constData() << "' which is not supported." << endl;
|
std::cerr << "**SYNTAX ERROR** found extension " << ext.toLatin1().constData() << " in '" << str.toLatin1().constData() << "' which is not supported." << std::endl;
|
||||||
cerr << " Currently only: pdf, jpg, png, svg, and gif are supported." << endl;
|
std::cerr << " Currently only: pdf, jpg, png, svg, and gif are supported." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("macro")) {
|
} else if (str.startsWith("macro")) {
|
||||||
tok = str.split(' ', QString::SkipEmptyParts);
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
if (tok.size() != 2) {
|
if (tok.size() != 2) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one file name is accepted." << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Only one file name is accepted." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// check extension
|
// check extension
|
||||||
@ -277,33 +301,129 @@ int mupp_script_syntax_check(QStringList &list)
|
|||||||
QString ext = tok.at(tok.size()-1);
|
QString ext = tok.at(tok.size()-1);
|
||||||
ext = ext.toLower();
|
ext = ext.toLower();
|
||||||
if (ext != "c") {
|
if (ext != "c") {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << "**SYNTAX ERROR** found extension " << ext.toLatin1().constData() << " in '" << str.toLatin1().constData() << "' which is not supported." << endl;
|
std::cerr << "**SYNTAX ERROR** found extension " << ext.toLatin1().constData() << " in '" << str.toLatin1().constData() << "' which is not supported." << std::endl;
|
||||||
cerr << " Currently only: C are supported." << endl;
|
std::cerr << " Currently only: C are supported." << std::endl;
|
||||||
cerr << "****************" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("norm")) {
|
} else if (str.startsWith("norm")) {
|
||||||
// nothing-to-be-done
|
// nothing-to-be-done
|
||||||
} else {
|
} else if (str.startsWith("var")) {
|
||||||
cerr << endl;
|
tok.clear();
|
||||||
cerr << "*********" << endl;
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
cerr << "**ERROR** found unrecognized script command: '" << str.toLatin1().constData() << "'." << endl;
|
if (tok.size() < 2) {
|
||||||
cerr << "*********" << endl;
|
std::cerr << std::endl;
|
||||||
cerr << " Currently supported:" << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << " load <coll(s)> : where <coll(s)> is a file-name-list of collections (*.db, *.dat)" << endl;
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'." << std::endl;
|
||||||
cerr << " loadPath <path> : where <path> is the load path accepting bash variables like $HOME, etc." << endl;
|
std::cerr << " Illegal variable definition." << std::endl;
|
||||||
cerr << " x <var-name> : where <var-name> is a data tag of the db/dat-file." << endl;
|
std::cerr << "****************" << std::endl;
|
||||||
cerr << " y <var-name> : where <var-name> is a data tag of the db/dat-file." << endl;
|
return -1;
|
||||||
cerr << " select <nn> : where <nn> is the row-number or collection name of the collection to be selected." << endl;
|
}
|
||||||
cerr << " selectAll : i.e. already set addX, addY will apply to ALL collections present." << endl;
|
// keep var name for later use
|
||||||
cerr << " savePath <path> : where <path> is the save path accepting bash variables like $HOME, etc." << endl;
|
var_names.push_back(tok[1]);
|
||||||
cerr << " plot <fln> : where <fln> is the file name with extension under which the plot should be saved." << endl;
|
var_linked.push_back(false);
|
||||||
cerr << " macro <fln> : where <fln> is the file name under which the root macro should be saved." << endl;
|
// the parsing etc is dealt within the scripting class
|
||||||
cerr << endl;
|
} else if (str.startsWith("col")) {
|
||||||
|
tok.clear();
|
||||||
|
tok = str.split(' ', QString::SkipEmptyParts);
|
||||||
|
if (tok.size() != 4) {
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Syntax for variable collection linking is:" << std::endl;
|
||||||
|
std::cerr << " col <nn> : <var_name>. Where <nn> is the collection index, and <var_name> the variable name to be linked." << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (tok[2] != ":") {
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Syntax for variable collection linking is:" << std::endl;
|
||||||
|
std::cerr << " col <nn> : <var_name>. Where <nn> is the collection index, and <var_name> the variable name to be linked." << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
// will check that the to be linked variable and the target collection exists
|
||||||
|
// first check that the collection exists
|
||||||
|
bool ok;
|
||||||
|
int idx = tok[1].toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR** found '" << str.toLatin1().constData() << "'. Syntax for variable collection linking is:" << std::endl;
|
||||||
|
std::cerr << " col <nn> : <var_name>. Where <nn> is the collection index, and <var_name> the variable name to be linked." << std::endl;
|
||||||
|
std::cerr << " collection index is not a number here!" << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (idx >= noOfCollections) {
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR** in '" << str.toLatin1().constData() << "'." << std::endl;
|
||||||
|
std::cerr << " Requested collection '" << idx << "' is out-of-range." << std::endl;
|
||||||
|
std::cerr << " Only " << noOfCollections << " or present." << std::endl;
|
||||||
|
std::cerr << " Collection indexing starts at 0, not 1." << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
// make sure that the variable to be linked has been defined and is NOT an error variable.
|
||||||
|
if (tok[3].endsWith("Err")) {
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR** in '" << str.toLatin1().constData() << "'." << std::endl;
|
||||||
|
std::cerr << " Only variables can be linked, NOT error variables." << std::endl;
|
||||||
|
std::cerr << " Error variables are linked implicitly." << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
idx = -1;
|
||||||
|
for (unsigned int i=0; i<var_names.size(); i++) {
|
||||||
|
if (tok[3] == var_names[i]) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (idx == -1) {
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR** in '" << str.toLatin1().constData() << "'." << std::endl;
|
||||||
|
std::cerr << " Variable to be linked not defined yet." << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
return -5;
|
||||||
|
}
|
||||||
|
var_linked[idx] = true;
|
||||||
|
} else {
|
||||||
|
std::cerr << "*********" << std::endl;
|
||||||
|
std::cerr << "**ERROR** found unrecognized script command: '" << str.toLatin1().constData() << "'." << std::endl;
|
||||||
|
std::cerr << "*********" << std::endl;
|
||||||
|
mupp_script_syntax();
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (noOfCollections == -1) {
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR** no data loaded." << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
mupp_script_syntax();
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
if (var_names.size() != var_linked.size()) {
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "**SYNTAX ERROR**" << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "** Your never should have reached this point **" << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
return -4;
|
||||||
|
}
|
||||||
|
for (int i=0; i<var_names.size(); i++) {
|
||||||
|
if (!var_names[i].endsWith("Err") && !var_linked[i]) {
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << "** WARNING **" << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
std::cerr << " Found unlinked variable : " << var_names[i].toLatin1().constData() << std::endl;
|
||||||
|
std::cerr << "****************" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -344,32 +464,32 @@ int main(int argc, char *argv[])
|
|||||||
mupp_syntax();
|
mupp_syntax();
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!qstrcmp(argv[1], "-v") || !qstrcmp(argv[1], "--version")) {
|
} else if (!qstrcmp(argv[1], "-v") || !qstrcmp(argv[1], "--version")) {
|
||||||
cout << endl << "mupp git-branch " << GIT_BRANCH << ", git-revision: " << GIT_COMMIT_HASH << ", version: " << MUPP_VERSION << endl << endl;
|
std::cout << std::endl << "mupp git-branch " << GIT_BRANCH << ", git-revision: " << GIT_COMMIT_HASH << ", version: " << MUPP_VERSION << std::endl << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!qstrcmp(argv[1], "-s") || !qstrcmp(argv[1], "--script")) {
|
} else if (!qstrcmp(argv[1], "-s") || !qstrcmp(argv[1], "--script")) {
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
cerr << "**ERROR** the script option cannot be combined with something else." << endl;
|
std::cerr << "**ERROR** the script option cannot be combined with something else." << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
mupp_syntax();
|
mupp_syntax();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// make sure that the script file exists
|
// make sure that the script file exists
|
||||||
if (!QFile::exists(argv[2])) {
|
if (!QFile::exists(argv[2])) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
cerr << "**ERROR** the script file '" << argv[2] << "' doesn't exist." << endl;
|
std::cerr << "**ERROR** the script file '" << argv[2] << "' doesn't exist." << std::endl;
|
||||||
cerr << "*********" << endl << endl;
|
std::cerr << "*********" << std::endl << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read script file
|
// read script file
|
||||||
if (mupp_script_read(argv[2], script) != 0) {
|
if (mupp_script_read(argv[2], script) != 0) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
cerr << "**ERROR** couldn't read script '" << argv[2] << "'" << endl;
|
std::cerr << "**ERROR** couldn't read script '" << argv[2] << "'" << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,10 +503,10 @@ int main(int argc, char *argv[])
|
|||||||
QString path="";
|
QString path="";
|
||||||
if (!qstrcmp(argv[1], "--path")) {
|
if (!qstrcmp(argv[1], "--path")) {
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
cerr << "**ERROR** tag '--path' needs to be followed by a <fit-param-path> and at least one <fit-param-file-name>" << endl;
|
std::cerr << "**ERROR** tag '--path' needs to be followed by a <fit-param-path> and at least one <fit-param-file-name>" << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
mupp_syntax();
|
mupp_syntax();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -421,10 +541,10 @@ int main(int argc, char *argv[])
|
|||||||
} else { // scripting
|
} else { // scripting
|
||||||
PmuppScript *mupp_script = new PmuppScript(script);
|
PmuppScript *mupp_script = new PmuppScript(script);
|
||||||
if (mupp_script == 0) {
|
if (mupp_script == 0) {
|
||||||
cerr << endl;
|
std::cerr << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
cerr << "**ERROR** couldn't invoke script class..." << endl;
|
std::cerr << "**ERROR** couldn't invoke script class..." << std::endl;
|
||||||
cerr << "*********" << endl;
|
std::cerr << "*********" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user