An encapsulation of QProcess which reports only the final state.
More...
|
static QtlBoundProcess * | newInstance (const QString &program, const QStringList &arguments=QStringList(), int msRunTestTimeout=0, int maxProcessOutputSize=0, QObject *parent=0, const QProcessEnvironment &env=QProcessEnvironment(), bool pipeInput=false) |
| Create a new instance. More...
|
|
|
| QtlBoundProcess (const QString &program, const QStringList &arguments, int msRunTestTimeout, int maxProcessOutputSize, QObject *parent, const QProcessEnvironment &env=QProcessEnvironment(), bool pipeInput=false) |
| Private constructor. More...
|
|
| QtlBoundProcess () Q_DECL_EQ_DELETE |
|
void | sendTerminated (const QString &message) |
| Send the terminated() signal. More...
|
|
An encapsulation of QProcess which reports only the final state.
A QtlBoundProcess instance deletes itself automatically after process termination (after start()) or cancelation (after cancel()). It is both useless and invalid to explicitely delete the object. To enfore object creation on the heap, there is no public constructor. Always use the static method newInstance().
◆ QtlBoundProcess() [1/2]
QtlBoundProcess::QtlBoundProcess |
( |
const QString & |
program, |
|
|
const QStringList & |
arguments, |
|
|
int |
msRunTestTimeout, |
|
|
int |
maxProcessOutputSize, |
|
|
QObject * |
parent, |
|
|
const QProcessEnvironment & |
env = QProcessEnvironment() , |
|
|
bool |
pipeInput = false |
|
) |
| |
|
private |
Private constructor.
- Parameters
-
[in] | program | Executable file path. |
[in] | arguments | Command line arguments. |
[in] | msRunTestTimeout | Timeout of process execution in milliseconds. Ignored if negative or zero. |
[in] | maxProcessOutputSize | Maximum size in bytes of process output. Ignored if negative or zero. |
[in] | parent | Optional parent object. |
[in] | env | Optional process environment. |
[in] | pipeInput | If true, the standard input of the process can be fed using inputDevice(). |
◆ QtlBoundProcess() [2/2]
QtlBoundProcess::QtlBoundProcess |
( |
| ) |
|
|
private |
◆ newInstance()
QtlBoundProcess * QtlBoundProcess::newInstance |
( |
const QString & |
program, |
|
|
const QStringList & |
arguments = QStringList() , |
|
|
int |
msRunTestTimeout = 0 , |
|
|
int |
maxProcessOutputSize = 0 , |
|
|
QObject * |
parent = 0 , |
|
|
const QProcessEnvironment & |
env = QProcessEnvironment() , |
|
|
bool |
pipeInput = false |
|
) |
| |
|
static |
Create a new instance.
Enforce object creation on the heap.
- Parameters
-
[in] | program | Executable file path. |
[in] | arguments | Command line arguments. |
[in] | msRunTestTimeout | Timeout of process execution in milliseconds. Ignored if negative or zero. |
[in] | maxProcessOutputSize | Maximum size in bytes of process output. Ignored if negative or zero. |
[in] | parent | Optional parent object. |
[in] | env | Environment for the process. Current environment by default. |
[in] | pipeInput | If true, the standard input of the process can be fed using inputDevice(). |
- Returns
- The new QtlBoundProcess instance.
◆ start()
void QtlBoundProcess::start |
( |
| ) |
|
◆ cancel()
void QtlBoundProcess::cancel |
( |
| ) |
|
Cancel the start of the process.
If the process is not yet started, it will never be and the terminated() signal is sent with a cancelation message.
◆ inputDevice()
QIODevice* QtlBoundProcess::inputDevice |
( |
| ) |
const |
|
inline |
Get the device representing the input pipe of the process.
The returned QIODevice is writeable only.
- Returns
- The input pipe as a QIODevice or zero if pipeInput was set to false in the constructor.
◆ terminated
This signal is emitted when the process is terminated or failed to start.
- Parameters
-
[in] | result | Process execution results. |
◆ readOutputData
void QtlBoundProcess::readOutputData |
( |
| ) |
|
|
privateslot |
Read as much data as possible from the process standard error and output.
◆ processFinished
void QtlBoundProcess::processFinished |
( |
int |
exitCode, |
|
|
QProcess::ExitStatus |
exitStatus |
|
) |
| |
|
privateslot |
Invoked when the process is finished.
- Parameters
-
[in] | exitCode | Process exit code. |
[in] | exitStatus | QProcess exit status. |
◆ processError
void QtlBoundProcess::processError |
( |
QProcess::ProcessError |
error | ) |
|
|
privateslot |
Invoked when an error occurs on the process.
- Parameters
-
[in] | error | QProcess error code. |
◆ processTimeout
void QtlBoundProcess::processTimeout |
( |
| ) |
|
|
privateslot |
Invoked when the process execution is too long.
◆ sendTerminated()
void QtlBoundProcess::sendTerminated |
( |
const QString & |
message | ) |
|
|
private |
Send the terminated() signal.
- Parameters
-
[in] | message | Error message if process did not complete normally. Empty if process completed normally. |
◆ _msRunTestTimeout
const int QtlBoundProcess::_msRunTestTimeout |
|
private |
Timeout of process execution in milliseconds. Ignored if negative or zero.
◆ _maxProcessOutputSize
const int QtlBoundProcess::_maxProcessOutputSize |
|
private |
Maximum size in bytes of process output. Ignored if negative or zero.
◆ _result
Process execution results.
◆ _pipeInput
bool QtlBoundProcess::_pipeInput |
|
private |
Process input is an accessible pipe.
◆ _started
bool QtlBoundProcess::_started |
|
private |
◆ _terminated
bool QtlBoundProcess::_terminated |
|
private |
◆ _process
QProcess* QtlBoundProcess::_process |
|
private |
◆ _timer
QTimer* QtlBoundProcess::_timer |
|
private |
Process execution timeout.
The documentation for this class was generated from the following files: