[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
klfblockprocess.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfblockprocess.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist@bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfblockprocess.h 603 2011-02-26 23:14:55Z phfaist $ */
23 
24 #ifndef KLFBLOCKPROCESS_H
25 #define KLFBLOCKPROCESS_H
26 
28 
32 #include <klfdefs.h>
33 
34 #include <qprocess.h>
35 #include <qstring.h>
36 #ifdef KLFBACKEND_QT4
37 #include <QByteArray>
38 #else
39 #include <qcstring.h>
40 #include <qmemarray.h>
41 #endif
42 
43 
45 
61 class KLF_EXPORT KLFBlockProcess : public QProcess
62 {
63  Q_OBJECT
64 public:
66  KLFBlockProcess(QObject *parent = 0);
68  ~KLFBlockProcess();
69 
70 #ifdef KLFBACKEND_QT4
71 
74  inline void setProcessAppEvents(bool processAppEvents) { mProcessAppEvents = processAppEvents; }
75 #endif
76 
80 #ifdef KLFBACKEND_QT4
81  return readAllStandardError();
82 #else
83  return readStderr();
84 #endif
85  }
86 
90 #ifdef KLFBACKEND_QT4
91  return readAllStandardOutput();
92 #else
93  return readStdout();
94 #endif
95  }
96 
98  bool processNormalExit() const {
99 #ifdef KLFBACKEND_QT4
100  return QProcess::exitStatus() == NormalExit;
101 #else
102  return normalExit();
103 #endif
104  }
105 
107  int processExitStatus() const {
108 #ifdef KLFBACKEND_QT4
109  return exitCode();
110 #else
111  return exitStatus();
112 #endif
113  }
114 
115 
116 public slots:
126  bool startProcess(QStringList cmd, QByteArray stdindata, QStringList env = QStringList());
127 #ifndef KLFBACKEND_QT4
128 
132  bool startProcess(QStringList cmd, QCString str, QStringList env = QStringList());
133 #endif
134 
137  bool startProcess(QStringList cmd, QStringList env = QStringList());
138 
139 #ifdef KLFBACKEND_QT4
140 
142  return QString::fromLocal8Bit(getAllStderr());
143  }
146  return QString::fromLocal8Bit(getAllStdout());
147  }
148 #else
149 
150  QString readStdoutString() {
151  QCString sstdout = "";
152  QByteArray stdout = readStdout();
153  if (stdout.size() > 0 && stdout.data() != 0)
154  sstdout = QCString(stdout.data(), stdout.size());
155  return QString(sstdout);
156  }
158  QString readStderrString() {
159  QCString sstderr = "";
160  QByteArray stderr = readStderr();
161  if (stderr.size() > 0 && stderr.data() != 0)
162  sstderr = QCString(stderr.data(), stderr.size());
163  return QString(sstderr);
164  }
165 #endif
166 
167 
168 private slots:
169  void ourProcExited();
170  void ourProcGotOurStdinData();
171 
172 private:
173  bool _runstatus;
174 #ifdef KLFBACKEND_QT4
175  bool mProcessAppEvents;
176 #endif
177 };
178 
179 
181 
182 KLF_EXPORT QStringList klf_cur_environ();
183 
184 
185 #endif
Base declarations for klatexformula and some utilities.
fromLocal8Bit(const char *str, int size=-1)
KLF_EXPORT QStringList klf_cur_environ()
The current process environment.
QString readStderrString()
void setProcessAppEvents(bool processAppEvents)
bool processNormalExit() const
int processExitStatus() const
QByteArray getAllStderr()
QString readStdoutString()
A QProcess subclass for code-blocking process execution.
readAllStandardOutput()
readAllStandardError()
QByteArray getAllStdout()

Generated by doxygen 1.8.11