Class for running processes with customizable environment and options.
More...
#include <process_runner.h>
|
| | ProcessRunner (QObject *parent=nullptr) |
| | Constructs a new ProcessRunner object.
|
| void | addEnvVariable (const QString &key, const QString &value) |
| | Adds an environment variable to the process.
|
| void | removeEnvVariable (const QString &key, const QString &value) |
| | Removes an environment variable from the process.
|
| void | setCwd (const QString &path) |
| | Sets the current working directory for the process.
|
| void | setTimeout (int ms) |
| | Sets the timeout for the process in milliseconds.
|
| int | runSync (const QString &cmd, QString &result) |
| | Runs a command synchronously and returns the result.
|
| void | runAsync (const QString &cmd, FinshedCallback finishedCb, LogCallback stdoutCb=nullptr, LogCallback stderrCb=nullptr) |
| | Runs a command asynchronously with callbacks for finished and logging.
|
|
| static int | ExecuteSync (const QString &cmd, QString &result) |
| | Runs a command synchronously and returns the result.
|
| static void | ExecuteAsync (const QString &cmd, QObject *parent, FinshedCallback finishedCb, LogCallback stdoutCb=nullptr, LogCallback stderrCb=nullptr) |
| | Runs a command asynchronously with callbacks for finished and logging.
|
|
|
QString | mCwd |
| | Environment variables for the process.
|
|
int | mTimeout |
| | Current working directory for the process.
|
Class for running processes with customizable environment and options.
◆ ProcessRunner()
| ProcessRunner::ProcessRunner |
( |
QObject * | parent = nullptr | ) |
|
Constructs a new ProcessRunner object.
- Parameters
-
| parent | Pointer to the parent QObject, if any. |
◆ addEnvVariable()
| void ProcessRunner::addEnvVariable |
( |
const QString & | key, |
|
|
const QString & | value ) |
Adds an environment variable to the process.
- Parameters
-
| key | The name of the environment variable. |
| value | The value of the environment variable. |
◆ ExecuteAsync()
| void ProcessRunner::ExecuteAsync |
( |
const QString & | cmd, |
|
|
QObject * | parent, |
|
|
FinshedCallback | finishedCb, |
|
|
LogCallback | stdoutCb = nullptr, |
|
|
LogCallback | stderrCb = nullptr ) |
|
static |
Runs a command asynchronously with callbacks for finished and logging.
- Parameters
-
| cmd | The command to run. |
| parent | Pointer to the parent QObject. |
| finishedCb | Callback function called when the process finishes. |
| stdoutCb | Optional callback function for standard output logging. |
| stderrCb | Optional callback function for standard error logging. |
◆ ExecuteSync()
| int ProcessRunner::ExecuteSync |
( |
const QString & | cmd, |
|
|
QString & | result ) |
|
static |
Runs a command synchronously and returns the result.
- Parameters
-
| cmd | The command to run. |
| result | Reference to a string where the output will be stored. |
- Returns
- int The exit code of the process.
◆ removeEnvVariable()
| void ProcessRunner::removeEnvVariable |
( |
const QString & | key, |
|
|
const QString & | value ) |
Removes an environment variable from the process.
- Parameters
-
| key | The name of the environment variable to remove. |
| value | The value of the environment variable to remove. |
◆ runAsync()
| void ProcessRunner::runAsync |
( |
const QString & | cmd, |
|
|
FinshedCallback | finishedCb, |
|
|
LogCallback | stdoutCb = nullptr, |
|
|
LogCallback | stderrCb = nullptr ) |
Runs a command asynchronously with callbacks for finished and logging.
- Parameters
-
| cmd | The command to run. |
| finishedCb | Callback function called when the process finishes. |
| stdoutCb | Optional callback function for standard output logging. |
| stderrCb | Optional callback function for standard error logging. |
◆ runSync()
| int ProcessRunner::runSync |
( |
const QString & | cmd, |
|
|
QString & | result ) |
Runs a command synchronously and returns the result.
- Parameters
-
| cmd | The command to run. |
| result | Reference to a string where the output will be stored. |
- Returns
- int The exit code of the process.
◆ setCwd()
| void ProcessRunner::setCwd |
( |
const QString & | path | ) |
|
Sets the current working directory for the process.
- Parameters
-
| path | The path to set as the current working directory. |
◆ setTimeout()
| void ProcessRunner::setTimeout |
( |
int | ms | ) |
|
Sets the timeout for the process in milliseconds.
- Parameters
-
| ms | The timeout value in milliseconds. |
The documentation for this class was generated from the following files:
- /__w/maki/maki/app/common/process_runner.h
- /__w/maki/maki/app/common/process_runner.cpp