[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project

src/klfbackend/klfblockprocess.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   file klfblockprocess.h
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2007 by Philippe Faist
00005  *   philippe.faist@bluewin.ch
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  *   This program is distributed in the hope that it will be useful,       *
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015  *   GNU General Public License for more details.                          *
00016  *                                                                         *
00017  *   You should have received a copy of the GNU General Public License     *
00018  *   along with this program; if not, write to the                         *
00019  *   Free Software Foundation, Inc.,                                       *
00020  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00021  ***************************************************************************/
00022 /* $Id: klfblockprocess.h 540 2010-10-04 00:19:05Z philippe $ */
00023 
00024 #ifndef KLFBLOCKPROCESS_H
00025 #define KLFBLOCKPROCESS_H
00026 
00028 
00032 #include <klfdefs.h>
00033 
00034 #include <qprocess.h>
00035 #include <qstring.h>
00036 #ifdef KLFBACKEND_QT4
00037 #include <QByteArray>
00038 #else
00039 #include <qcstring.h>
00040 #include <qmemarray.h>
00041 #endif
00042 
00043 
00045 
00061 class KLF_EXPORT KLFBlockProcess : public QProcess
00062 {
00063   Q_OBJECT
00064 public:
00066   KLFBlockProcess(QObject *parent = 0);
00068   ~KLFBlockProcess();
00069 
00070 #ifdef KLFBACKEND_QT4
00071 
00074   inline void setProcessAppEvents(bool processAppEvents) { mProcessAppEvents = processAppEvents; }
00075 #endif
00076 
00079   QByteArray getAllStderr() {
00080 #ifdef KLFBACKEND_QT4
00081     return readAllStandardError();
00082 #else
00083     return readStderr();
00084 #endif
00085   }
00086 
00089   QByteArray getAllStdout() {
00090 #ifdef KLFBACKEND_QT4
00091     return readAllStandardOutput();
00092 #else
00093     return readStdout();
00094 #endif
00095   }
00096 
00098   bool processNormalExit() const {
00099 #ifdef KLFBACKEND_QT4
00100     return QProcess::exitStatus() == NormalExit;
00101 #else
00102     return normalExit();
00103 #endif
00104   }
00105 
00107   int processExitStatus() const {
00108 #ifdef KLFBACKEND_QT4
00109     return exitCode();
00110 #else
00111     return exitStatus();
00112 #endif
00113   }
00114 
00115 
00116 public slots:
00126   bool startProcess(QStringList cmd, QByteArray stdindata, QStringList env = QStringList());
00127 #ifndef KLFBACKEND_QT4
00128 
00132   bool startProcess(QStringList cmd, QCString str, QStringList env = QStringList());
00133 #endif
00134 
00137   bool startProcess(QStringList cmd, QStringList env = QStringList());
00138 
00139 #ifdef KLFBACKEND_QT4
00140 
00141   QString readStderrString() {
00142     return QString::fromLocal8Bit(getAllStderr());
00143   }
00145   QString readStdoutString() {
00146     return QString::fromLocal8Bit(getAllStdout());
00147   }
00148 #else
00149 
00150   QString readStdoutString() {
00151     QCString sstdout = "";
00152     QByteArray stdout = readStdout();
00153     if (stdout.size() > 0 && stdout.data() != 0)
00154       sstdout = QCString(stdout.data(), stdout.size());
00155     return QString(sstdout);
00156   }
00158   QString readStderrString() {
00159     QCString sstderr = "";
00160     QByteArray stderr = readStderr();
00161     if (stderr.size() > 0 && stderr.data() != 0)
00162       sstderr = QCString(stderr.data(), stderr.size());
00163     return QString(sstderr);
00164   }
00165 #endif
00166 
00167 
00168 private slots:
00169   void ourProcExited();
00170   void ourProcGotOurStdinData();
00171 
00172 private:
00173   bool _runstatus;
00174 #ifdef KLFBACKEND_QT4
00175   bool mProcessAppEvents;
00176 #endif
00177 };
00178 
00179 
00181 
00182 KLF_EXPORT QStringList klf_cur_environ();
00183 
00184 
00185 #endif

Generated by doxygen 1.7.3