[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Slots | Public Member Functions | List of all members
KLFBlockProcess Class Reference

A QProcess subclass for code-blocking process execution. More...

#include <klfblockprocess.h>

Inheritance diagram for KLFBlockProcess:
Inheritance graph
[legend]
Collaboration diagram for KLFBlockProcess:
Collaboration graph
[legend]

Public Slots

bool startProcess (QStringList cmd, QByteArray stdindata, QStringList env=QStringList())
 
bool startProcess (QStringList cmd, QStringList env=QStringList())
 
QString readStderrString ()
 
QString readStdoutString ()
 

Public Member Functions

 KLFBlockProcess (QObject *parent=0)
 
 ~KLFBlockProcess ()
 
void setProcessAppEvents (bool processAppEvents)
 
QByteArray getAllStderr ()
 
QByteArray getAllStdout ()
 
bool processNormalExit () const
 
int processExitStatus () const
 

Detailed Description

A QProcess subclass for code-blocking process execution.

A Code-blocking (but not GUI-blocking) process executor

Use for example like:

args << "ls" << "/dev";
proc.startProcess(args);
QString alldevices = proc.readStdoutString();

This class provides functionality for passing data to STDIN and getting data from STDOUT and STDERR afterwards.

Author
Philippe Faist <phili.nosp@m.ppe..nosp@m.faist.nosp@m.@blu.nosp@m.ewin..nosp@m.ch>

Definition at line 61 of file klfblockprocess.h.

Constructor & Destructor Documentation

KLFBlockProcess::KLFBlockProcess ( QObject parent = 0)

Normal constructor, like QProcess constructor

Definition at line 33 of file klfblockprocess.cpp.

References QProcess::ExitStatus(), and QProcess::finished().

KLFBlockProcess::~KLFBlockProcess ( )

Normal destructor

Definition at line 45 of file klfblockprocess.cpp.

References startProcess().

Member Function Documentation

QByteArray KLFBlockProcess::getAllStderr ( )
inline

Returns all standard error output as a QByteArray. This function is to standardize the readStderr() and readAllStandardError() functions in QT 3 or QT 4 respectively

Definition at line 79 of file klfblockprocess.h.

References QProcess::readAllStandardError().

QByteArray KLFBlockProcess::getAllStdout ( )
inline

Returns all standard output as a QByteArray. This function is to standardize the readStdout() and readAllStandardOutput() functions in QT 3 or QT 4 respectively

Definition at line 89 of file klfblockprocess.h.

References QProcess::readAllStandardOutput().

int KLFBlockProcess::processExitStatus ( ) const
inline

A function that normalizes Qt3 and Qt4 api: Qt3: exitStatus(), Qt4: exitCode()

Definition at line 107 of file klfblockprocess.h.

References QProcess::exitCode().

Referenced by KLFBackend::getLatexFormula().

bool KLFBlockProcess::processNormalExit ( ) const
inline

A function that normalizes Qt3 and Qt4 api: Qt3: normalExit(), Qt4: exitStatus()==NormalExit

Definition at line 98 of file klfblockprocess.h.

Referenced by KLFBackend::getLatexFormula().

QString KLFBlockProcess::readStderrString ( )
inlineslot

Same as getAllStderr(), except result is returned here as QString.

Definition at line 141 of file klfblockprocess.h.

References QString::fromLocal8Bit().

Referenced by KLFBackend::getLatexFormula().

QString KLFBlockProcess::readStdoutString ( )
inlineslot

Same as getAllStdout(), except result is returned here as QString.

Definition at line 145 of file klfblockprocess.h.

References QByteArray::data(), QString::fromLocal8Bit(), klf_cur_environ(), and QByteArray::size().

Referenced by KLFBackend::getLatexFormula().

void KLFBlockProcess::setProcessAppEvents ( bool  processAppEvents)
inline

Qt4 ONLY: 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.

Definition at line 74 of file klfblockprocess.h.

bool KLFBlockProcess::startProcess ( QStringList  cmd,
QByteArray  stdindata,
QStringList  env = QStringList() 
)
slot

Starts cmd (which is a list of arguments, the first being the program itself) and blocks until process stopped. The QT event loop is updated regularly so that the GUI doesn't freeze.

Read result with QProcess::readStdout() and QProcess::readStderr(), get process exit info with processNormalExit() and processExitStatus().

Returns
TRUE upon success, FALSE upon failure.

Definition at line 71 of file klfblockprocess.cpp.

References QProcess::closeWriteChannel(), QByteArray::constData(), QFile::exists(), KLF_ASSERT_CONDITION, klfDbg, klfSearchPath(), QFile::open(), QProcess::setEnvironment(), QByteArray::size(), QProcess::start(), QProcess::waitForFinished(), and QProcess::waitForStarted().

Referenced by KLFBackend::getLatexFormula(), startProcess(), and ~KLFBlockProcess().

bool KLFBlockProcess::startProcess ( QStringList  cmd,
QStringList  env = QStringList() 
)
slot

Convenient function to be used in the case where program doesn't expect stdin data or if you chose to directly close stdin without writing anything to it.

Definition at line 66 of file klfblockprocess.cpp.

References startProcess().


The documentation for this class was generated from the following files:

Generated by doxygen 1.8.11