Public Member Functions | |
KLFFilterProcess (const QString &pTitle=QString(), const KLFBackend::klfSettings *settings=NULL, const QString &rundir=QString()) | |
QString | progTitle () const |
void | setProgTitle (const QString &title) |
QString | programCwd () const |
void | setProgramCwd (const QString &cwd) |
QStringList | execEnviron () const |
void | setExecEnviron (const QStringList &env) |
void | addExecEnviron (const QStringList &env) |
QStringList | argv () const |
void | setArgv (const QStringList &argv) |
void | addArgv (const QStringList &argv) |
void | addArgv (const QString &argv) |
bool | outputStdout () const |
void | setOutputStdout (bool on) |
bool | outputStderr () const |
void | setOutputStderr (bool on) |
void | collectStdoutTo (QByteArray *stdoutstore) |
void | collectStderrTo (QByteArray *stderrstore) |
bool | processAppEvents () |
void | setProcessAppEvents (bool processEvents) |
virtual int | exitStatus () const |
virtual int | exitCode () const |
virtual int | resultStatus () const |
virtual QString | resultErrorString () const |
bool | run (const QString &outFileName, QByteArray *outdata) |
bool | run (const QByteArray &indata, const QString &outFileName, QByteArray *outdata) |
bool | run (const QMap< QString, QByteArray * > outdata) |
bool | run (const QByteArray &indata=QByteArray()) |
bool | run (const QByteArray &indata, const QMap< QString, QByteArray * > outdatalist) |
Protected Member Functions | |
virtual QMap< QString, QString > | interpreters () const |
virtual bool | do_run (const QByteArray &indata, const QMap< QString, QByteArray * > outdatalist) |
Actually run the process. More... | |
QByteArray | collectedStdout () const |
The collected stdout data of the process that just ran. More... | |
QByteArray | collectedStderr () const |
The collected stderr data of the process that just ran. More... | |
Definition at line 46 of file klffilterprocess.h.
|
protected |
The collected stderr data of the process that just ran.
Convenience method for subclasses. Stderr data collection must have been enabled (with setOutputStderr() and collectStderrTo()).
Definition at line 413 of file klffilterprocess.cpp.
Referenced by KLFUserScriptFilterProcess::do_run().
|
protected |
The collected stdout data of the process that just ran.
Convenience method for subclasses. Stdout data collection must have been enabled (with setOutputStdout() and collectStdoutTo()).
Definition at line 406 of file klffilterprocess.cpp.
Referenced by KLFUserScriptFilterProcess::do_run().
void KLFFilterProcess::collectStderrTo | ( | QByteArray * | stderrstore | ) |
Set a QByteArray where all stderr data will be stored
Definition at line 249 of file klffilterprocess.cpp.
void KLFFilterProcess::collectStdoutTo | ( | QByteArray * | stdoutstore | ) |
Set a QByteArray where all stdout data will be stored
Definition at line 244 of file klffilterprocess.cpp.
References setOutputStdout().
|
protectedvirtual |
Actually run the process.
Each run() overload above internally just redirects to this function.
Subclasses may reimplement if they want to do some bookkeeping, cleaning up, keeping a log, etc.
Reimplemented in KLFUserScriptFilterProcess.
Definition at line 288 of file klffilterprocess.cpp.
References QString::arg(), QMap::begin(), QMap::end(), QFile::exists(), QProcess::exitCode(), QProcess::exitStatus(), KLFBlockProcess::getAllStderr(), KLFBlockProcess::getAllStdout(), QString::isEmpty(), QByteArray::isEmpty(), QMap::key(), KLF_ASSERT_CONDITION, KLF_ASSERT_NOT_NULL, KLF_DEBUG_BLOCK, KLF_FUNC_NAME, klfDbg, QFile::open(), KLFBlockProcess::processExitStatus(), KLFBlockProcess::processNormalExit(), QIODevice::readAll(), KLFBlockProcess::readStderrString(), KLFBlockProcess::readStdoutString(), KLFBlockProcess::setProcessAppEvents(), QProcess::setWorkingDirectory(), QByteArray::size(), KLFBlockProcess::startProcess(), QObject::tr(), and QMap::value().
Referenced by KLFUserScriptFilterProcess::do_run().
|
virtual |
After run(), this is set to the exit code of the process. See QProcess::exitCode()
Definition at line 269 of file klffilterprocess.cpp.
|
virtual |
After run(), this is set to the exit status of the process. See QProcess::exitStatus()
Definition at line 265 of file klffilterprocess.cpp.
bool KLFFilterProcess::processAppEvents | ( | ) |
Definition at line 255 of file klffilterprocess.cpp.
|
virtual |
An explicit error string in case the resultStatus() indicated an error.
Definition at line 278 of file klffilterprocess.cpp.
Referenced by KLFUserScriptFilterProcess::do_run().
|
virtual |
This is one of the KLFFP_* define's, such as KLFFP_NOSTART, or KLFFP_NOERR if all OK.
Definition at line 274 of file klffilterprocess.cpp.
|
inline |
indata | a QByteArray to write into the program's standard input |
outdatalist | a QMap with keys being files that are created by the program. These files are read and their contents stored in the QByteArray's pointed by the corresponding pointer. |
resError | the klfOutput object is initialized to the corresponding error if an error occurred. |
An empty file name in the list means to collect the standard output.
Definition at line 136 of file klffilterprocess.h.
void KLFFilterProcess::setOutputStderr | ( | bool | on | ) |
Set this to true to also read stderr as part of the output. If false (the default), stderr output is only reported in the error message in case nothing came out on stdout.
Definition at line 239 of file klffilterprocess.cpp.
void KLFFilterProcess::setOutputStdout | ( | bool | on | ) |
Set this to false to ignore output on stdout of the program.
Definition at line 230 of file klffilterprocess.cpp.
Referenced by collectStdoutTo().
void KLFFilterProcess::setProcessAppEvents | ( | bool | processEvents | ) |
specify whether or not to call regularly qApp->processEvents() while executing. This will prevent the GUI to freeze. Enabled is the default. However you can choose to disable this behavior by passing FALSE here, e.g. if you're not in the GUI thread.
Definition at line 260 of file klffilterprocess.cpp.