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 
00023 #ifndef KLFBLOCKPROCESS_H
00024 #define KLFBLOCKPROCESS_H
00025 
00027 
00030 #include <qprocess.h>
00031 #include <qstring.h>
00032 #ifdef KLFBACKEND_QT4
00033 #include <QByteArray>
00034 #else
00035 #include <qcstring.h>
00036 #include <qmemarray.h>
00037 #endif
00038 
00040 
00056 class KLFBlockProcess : public QProcess
00057 {
00058   Q_OBJECT
00059 public:
00061   KLFBlockProcess(QObject *parent = 0);
00063   ~KLFBlockProcess();
00064 
00067   QByteArray getAllStderr() {
00068 #ifdef KLFBACKEND_QT4
00069     return readAllStandardError();
00070 #else
00071     return readStderr();
00072 #endif
00073   }
00074 
00077   QByteArray getAllStdout() {
00078 #ifdef KLFBACKEND_QT4
00079     return readAllStandardOutput();
00080 #else
00081     return readStdout();
00082 #endif
00083   }
00084 
00085 #ifdef KLFBACKEND_QT4
00086 
00087   bool normalExit() const {
00088     return QProcess::exitStatus() == NormalExit;
00089   }
00091   int exitStatus() const {
00092     return exitCode();
00093   }
00094 #endif
00095 
00096 
00097 public slots:
00107   bool startProcess(QStringList cmd, QByteArray stdindata, QStringList env = QStringList());
00108 #ifndef KLFBACKEND_QT4
00109 
00113   bool startProcess(QStringList cmd, QCString str, QStringList env = QStringList());
00114 #endif
00115 
00118   bool startProcess(QStringList cmd, QStringList env = QStringList());
00119 
00120 #ifdef KLFBACKEND_QT4
00121 
00122   QString readStderrString() {
00123     return QString::fromLocal8Bit(getAllStderr());
00124   }
00126   QString readStdoutString() {
00127     return QString::fromLocal8Bit(getAllStdout());
00128   }
00129 #else
00130 
00131   QString readStdoutString() {
00132     QCString sstdout = "";
00133     QByteArray stdout = readStdout();
00134     if (stdout.size() > 0 && stdout.data() != 0)
00135       sstdout = QCString(stdout.data(), stdout.size());
00136     return QString(sstdout);
00137   }
00139   QString readStderrString() {
00140     QCString sstderr = "";
00141     QByteArray stderr = readStderr();
00142     if (stderr.size() > 0 && stderr.data() != 0)
00143       sstderr = QCString(stderr.data(), stderr.size());
00144     return QString(sstderr);
00145   }
00146 #endif
00147 
00148 
00149 private slots:
00150   void ourProcExited();
00151   void ourProcGotOurStdinData();
00152 
00153 private:
00154   bool _runstatus;
00155 };
00156 
00157 #endif

Generated on Mon May 4 01:27:08 2009 for KLFBackend by  doxygen 1.5.3