[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
src/klfbackend/klffilterprocess.h
00001 /***************************************************************************
00002  *   file klffilterprocess.h
00003  *   This file is part of the KLatexFormula Project.
00004  *   Copyright (C) 2011 by Philippe Faist
00005  *   philippe.faist at 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$ */
00023 
00024 
00025 #ifndef KLFFILTERPROCESS_H
00026 #define KLFFILTERPROCESS_H
00027 
00028 
00029 #include <klfdefs.h>
00030 #include <klfblockprocess.h>
00031 #include <klfbackend.h>
00032 
00033 
00034 #define KLFFP_NOERR 0
00035 #define KLFFP_NOSTART 1
00036 #define KLFFP_NOEXIT 2
00037 #define KLFFP_NOSUCCESSEXIT 3
00038 #define KLFFP_NODATA 4
00039 #define KLFFP_DATAREADFAIL 5
00040 #define KLFFP_PAST_LAST_VALUE 6
00041 
00042 
00043 
00044 struct KLFFilterProcessPrivate;
00045 class KLFFilterProcessBlockProcess;
00046 
00047 class KLF_EXPORT KLFFilterProcess
00048 {
00049 public:
00050   KLFFilterProcess(const QString& pTitle = QString(), const KLFBackend::klfSettings *settings = NULL,
00051                    const QString& rundir = QString());
00052   KLFFilterProcess(const QString& pTitle, const KLFBackend::klfSettings *settings,
00053                    const QString& rundir, bool inheritProcessEnvironment);
00054   virtual ~KLFFilterProcess();
00055 
00056 
00057   QString progTitle() const;
00058   void setProgTitle(const QString& title);
00059 
00060   QString programCwd() const;
00061   void setProgramCwd(const QString& cwd);
00062 
00063   QStringList execEnviron() const;
00064   void setExecEnviron(const QStringList& env);
00065   void addExecEnviron(const QStringList& env);
00066 
00067   QStringList argv() const;
00068   void setArgv(const QStringList& argv);
00069   void addArgv(const QStringList& argv);
00070   void addArgv(const QString& argv);
00071 
00072   bool outputStdout() const;
00074   void setOutputStdout(bool on);
00075 
00076   bool outputStderr() const;
00079   void setOutputStderr(bool on);
00080 
00082   void collectStdoutTo(QByteArray * stdoutstore);
00084   void collectStderrTo(QByteArray * stderrstore);
00085 
00087   bool processAppEvents();
00091   void setProcessAppEvents(bool processEvents);
00092 
00093 
00095   virtual int exitStatus() const;
00097   virtual int exitCode() const;
00098 
00100   virtual int resultStatus() const;
00102   virtual QString resultErrorString() const;
00103 
00104 
00105   bool run(const QString& outFileName, QByteArray *outdata)
00106   {
00107     return run(QByteArray(), outFileName, outdata);
00108   }
00109 
00110   bool run(const QByteArray& indata, const QString& outFileName, QByteArray *outdata)
00111   {
00112     QMap<QString,QByteArray*> fout; fout[outFileName] = outdata;
00113     return do_run(indata, fout);
00114   }
00115 
00116   bool run(const QMap<QString, QByteArray*> outdata)
00117   {
00118     return do_run(QByteArray(), outdata);
00119   }
00120 
00121   bool run(const QByteArray& indata = QByteArray())
00122   {
00123     return do_run(indata, QMap<QString, QByteArray*>());
00124   }
00125 
00139   bool run(const QByteArray& indata, const QMap<QString, QByteArray*> outdatalist)
00140   {
00141     return do_run(indata, outdatalist);
00142   }
00143 
00144 protected:
00145 
00146   friend class KLFFilterProcessBlockProcess;
00147   virtual QMap<QString,QString> interpreters() const;
00148 
00157   virtual bool do_run(const QByteArray& indata, const QMap<QString, QByteArray*> outdatalist);
00158 
00164   QByteArray collectedStdout() const;
00170   QByteArray collectedStderr() const;
00171 
00172 private:
00173   KLF_DECLARE_PRIVATE(KLFFilterProcess) ;
00174 };
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 #endif

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net