/usr/include/klfbackend/klfblockprocess.h is in libklatexformula4-dev 4.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | /***************************************************************************
* file klfblockprocess.h
* This file is part of the KLatexFormula Project.
* Copyright (C) 2011 by Philippe Faist
* philippe.faist@bluewin.ch
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/* $Id: klfblockprocess.h 969 2016-12-29 07:44:24Z phfaist $ */
#ifndef KLFBLOCKPROCESS_H
#define KLFBLOCKPROCESS_H
//! Defines the KLFBlockProcess class
/** \file
* Defines the KLFBlockProcess class */
#include <klfdefs.h>
#include <QProcess>
#include <QString>
#include <QByteArray>
//! A QProcess subclass for code-blocking process execution
/** A Code-blocking (but not GUI-blocking) process executor
*
* Use for example like:
* \code
* KLFBlockProcess proc;
* QStringList args;
* args << "ls" << "/dev";
* proc.startProcess(args);
* QString alldevices = proc.readStdoutString();
* \endcode
*
* This class provides functionality for passing data to STDIN and
* getting data from STDOUT and STDERR afterwards.
*
* \author Philippe Faist <philippe.faist@bluewin.ch>
*/
class KLF_EXPORT KLFBlockProcess : public QProcess
{
Q_OBJECT
public:
/** Normal constructor, like QProcess constructor */
KLFBlockProcess(QObject *parent = 0);
/** Normal destructor */
~KLFBlockProcess();
/** 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. */
inline void setProcessAppEvents(bool processAppEvents) { mProcessAppEvents = processAppEvents; }
/** 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 */
QByteArray getAllStderr() {
return readAllStandardError();
}
/** Returns all standard output as a QByteArray. This function is to standardize the
* readStdout() and readAllStandardOutput() functions in QT 3 or QT 4 respectively */
QByteArray getAllStdout() {
return readAllStandardOutput();
}
/** Same as QProcess::exitStatus()==NormalExit */
bool processNormalExit() const {
return QProcess::exitStatus() == NormalExit;
}
/** Same as QProcess::exitCode() */
int processExitStatus() const {
return exitCode();
}
// detect python, shell, etc. interpreters using some standard paths
static QString detectInterpreterPath(const QString& interp,
const QStringList & addpaths = QStringList());
/** \brief The interpter path to use for the given extension.
*
* This function will be queried by \ref startProcess() when we have to execute a
* script.
*
* Subclasses may reimplement to e.g. query user settings etc. Subclasses may of course
* also make use of \ref detectInterpreterPath().
*
* The default implementation treats some common script extensions ("py", "rb", "sh")
* and tries to find the interpreter using \ref detectInterpreterPath().
*/
virtual QString getInterpreterPath(const QString& ext);
public slots:
/** 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.
*/
bool startProcess(QStringList cmd, QByteArray stdindata, QStringList env = QStringList());
/** 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. */
bool startProcess(QStringList cmd, QStringList env = QStringList());
/** Same as getAllStderr(), except result is returned here as QString. */
QString readStderrString() {
return QString::fromLocal8Bit(getAllStderr());
}
/** Same as getAllStdout(), except result is returned here as QString. */
QString readStdoutString() {
return QString::fromLocal8Bit(getAllStdout());
}
private slots:
void ourProcExited();
void ourProcGotOurStdinData();
private:
int _runstatus;
bool mProcessAppEvents;
};
#endif
|