Runs non-interactive external commands in FIFO order using a single QProcess.
More...
#include <executor.h>
|
| void | finished (int id, int exitCode, const QString &output, const QString &errout) |
| | finished signal that is emited when process finishes
|
|
void | starting () |
| | starting signal that is emited when process starts
|
| void | error (int id, int exitCode, const QString &output, const QString &errout) |
| | error signal that is emited when process finishes with an error
|
|
| | Executor (QObject *parent=nullptr) |
| | Construct an Executor with an optional parent QObject.
|
| void | execute (int id, const QString &app, const QStringList &args, bool readStdout, bool readStderr=true) |
| | Queue a command without stdin input.
|
| void | execute (int id, const QString &workDir, const QString &app, const QStringList &args, bool readStdout, bool readStderr=true) |
| | Queue a command with an explicit working directory.
|
| void | execute (int id, const QString &app, const QStringList &args, QString input=QString(), bool readStdout=false, bool readStderr=true) |
| | Queue a command with optional stdin input.
|
| void | execute (int id, const QString &workDir, const QString &app, const QStringList &args, QString input=QString(), bool readStdout=false, bool readStderr=true) |
| | Queue a command with working directory and optional stdin input.
|
| void | setEnvironment (const QStringList &env) |
| | Set the environment passed to all child processes.
|
| auto | environment () const -> QStringList |
| | Return the environment passed to child processes.
|
| auto | cancelNext () -> int |
| | Cancel the next queued command without executing it.
|
|
| static auto | executeBlocking (const QString &app, const QStringList &args, const QString &input=QString(), QString *process_out=nullptr, QString *process_err=nullptr) -> int |
| | Run a command synchronously and return its exit code.
|
| static auto | executeBlocking (const QString &app, const QStringList &args, QString *process_out, QString *process_err=nullptr) -> int |
| | Run a command synchronously capturing stdout and stderr.
|
| static auto | executeBlocking (const QStringList &env, const QString &app, const QStringList &args, QString *process_out=nullptr, QString *process_err=nullptr) -> int |
| | Run a command synchronously with a custom environment.
|
Runs non-interactive external commands in FIFO order using a single QProcess.
Queues execution requests and emits per-request completion or error signals; supports optional stdin, configurable stdout/stderr capture, and per-request working directory and environment.
Definition at line 20 of file executor.h.
◆ Executor()
| Executor::Executor |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
Construct an Executor with an optional parent QObject.
- Parameters
-
| parent | Parent QObject, or nullptr for no parent. |
◆ cancelNext()
| auto Executor::cancelNext |
( |
| ) |
-> int |
Cancel the next queued command without executing it.
- Returns
- The id of the cancelled command, or -1 if the queue was empty.
◆ environment()
| auto Executor::environment |
( |
| ) |
const -> QStringList |
Return the environment passed to child processes.
- Returns
- Environment as a list of "KEY=value" strings.
◆ error
| void Executor::error |
( |
int | id, |
|
|
int | exitCode, |
|
|
const QString & | output, |
|
|
const QString & | errout ) |
|
signal |
error signal that is emited when process finishes with an error
- Parameters
-
| id | id of the process |
| exitCode | return code of the process |
| output | stdout produced by the process |
| errout | stderr produced by the process |
◆ execute() [1/4]
| void Executor::execute |
( |
int | id, |
|
|
const QString & | app, |
|
|
const QStringList & | args, |
|
|
bool | readStdout, |
|
|
bool | readStderr = true ) |
Queue a command without stdin input.
- Parameters
-
| id | Caller-assigned process identifier. |
| app | Executable path. |
| args | Command arguments. |
| readStdout | Whether to capture stdout. |
| readStderr | Whether to capture stderr. |
◆ execute() [2/4]
| void Executor::execute |
( |
int | id, |
|
|
const QString & | app, |
|
|
const QStringList & | args, |
|
|
QString | input = QString(), |
|
|
bool | readStdout = false, |
|
|
bool | readStderr = true ) |
Queue a command with optional stdin input.
- Parameters
-
| id | Caller-assigned process identifier. |
| app | Executable path. |
| args | Command arguments. |
| input | Data to write to stdin. |
| readStdout | Whether to capture stdout. |
| readStderr | Whether to capture stderr. |
◆ execute() [3/4]
| void Executor::execute |
( |
int | id, |
|
|
const QString & | workDir, |
|
|
const QString & | app, |
|
|
const QStringList & | args, |
|
|
bool | readStdout, |
|
|
bool | readStderr = true ) |
Queue a command with an explicit working directory.
- Parameters
-
| id | Caller-assigned process identifier. |
| workDir | Working directory for the process. |
| app | Executable path. |
| args | Command arguments. |
| readStdout | Whether to capture stdout. |
| readStderr | Whether to capture stderr. |
◆ execute() [4/4]
| void Executor::execute |
( |
int | id, |
|
|
const QString & | workDir, |
|
|
const QString & | app, |
|
|
const QStringList & | args, |
|
|
QString | input = QString(), |
|
|
bool | readStdout = false, |
|
|
bool | readStderr = true ) |
Queue a command with working directory and optional stdin input.
- Parameters
-
| id | Caller-assigned process identifier. |
| workDir | Working directory for the process. |
| app | Executable path. |
| args | Command arguments. |
| input | Data to write to stdin. |
| readStdout | Whether to capture stdout. |
| readStderr | Whether to capture stderr. |
◆ executeBlocking() [1/3]
| auto Executor::executeBlocking |
( |
const QString & | app, |
|
|
const QStringList & | args, |
|
|
const QString & | input = QString(), |
|
|
QString * | process_out = nullptr, |
|
|
QString * | process_err = nullptr ) -> int |
|
static |
Run a command synchronously and return its exit code.
- Parameters
-
| app | Executable path. |
| args | Command arguments. |
| input | Data to write to stdin. |
| process_out | If non-null, receives stdout output. |
| process_err | If non-null, receives stderr output. |
- Returns
- Process exit code.
◆ executeBlocking() [2/3]
| auto Executor::executeBlocking |
( |
const QString & | app, |
|
|
const QStringList & | args, |
|
|
QString * | process_out, |
|
|
QString * | process_err = nullptr ) -> int |
|
static |
Run a command synchronously capturing stdout and stderr.
- Parameters
-
| app | Executable path. |
| args | Command arguments. |
| process_out | Receives stdout output. |
| process_err | If non-null, receives stderr output. |
- Returns
- Process exit code.
◆ executeBlocking() [3/3]
| auto Executor::executeBlocking |
( |
const QStringList & | env, |
|
|
const QString & | app, |
|
|
const QStringList & | args, |
|
|
QString * | process_out = nullptr, |
|
|
QString * | process_err = nullptr ) -> int |
|
static |
Run a command synchronously with a custom environment.
- Parameters
-
| env | Environment variable list in "KEY=value" format. |
| app | Executable path. |
| args | Command arguments. |
| process_out | If non-null, receives stdout output. |
| process_err | If non-null, receives stderr output. |
- Returns
- Process exit code.
◆ finished
| void Executor::finished |
( |
int | id, |
|
|
int | exitCode, |
|
|
const QString & | output, |
|
|
const QString & | errout ) |
|
signal |
finished signal that is emited when process finishes
- Parameters
-
| id | id of the process |
| exitCode | return code of the process |
| output | stdout produced by the process |
| errout | stderr produced by the process |
◆ setEnvironment()
| void Executor::setEnvironment |
( |
const QStringList & | env | ) |
|
Set the environment passed to all child processes.
- Parameters
-
| env | Environment variable list in "KEY=value" format. |
The documentation for this class was generated from the following file: