QChildProcess.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                           Child Process i/o device                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 *        Copyright (C) 2007 by Niall Douglas.   All Rights Reserved.            *
00007 *       NOTE THAT I DO NOT PERMIT ANY OF MY CODE TO BE PROMOTED TO THE GPL      *
00008 *********************************************************************************
00009 * This code is free software; you can redistribute it and/or modify it under    *
00010 * the terms of the GNU Library General Public License v2.1 as published by the  *
00011 * Free Software Foundation EXCEPT that clause 3 does not apply ie; you may not  *
00012 * "upgrade" this code to the GPL without my prior written permission.           *
00013 * Please consult the file "License_Addendum2.txt" accompanying this file.       *
00014 *                                                                               *
00015 * This code is distributed in the hope that it will be useful,                  *
00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                          *
00018 *********************************************************************************
00019 * $Id:                                                                          *
00020 ********************************************************************************/
00021 
00022 
00023 #ifndef QCHILDPROCESS_H
00024 #define QCHILDPROCESS_H
00025 #include "QIODeviceS.h"
00026 #include "FXString.h"
00027 
00028 namespace FX {
00029 
00074 struct QChildProcessPrivate;
00075 class FXAPIR QChildProcess : public QIODeviceS
00076 {
00077     QChildProcessPrivate *p;
00078     QChildProcess(const QChildProcess &);
00079     QChildProcess &operator=(const QChildProcess &);
00080     virtual FXDLLLOCAL void *int_getOSHandle() const;
00081     FXDLLLOCAL void int_killChildI(bool);
00082 public:
00084     enum ReadChannel
00085     {
00086         StdOut=1,       
00087         StdErr=2,       
00088         Combined=3      
00089     };
00090 public:
00091     QChildProcess();
00093     QChildProcess(const FXString &command, const FXString &args=FXString::nullStr(), ReadChannel channel=Combined);
00094     ~QChildProcess();
00095 
00097     const FXString &command() const;
00099     void setCommand(const FXString &command);
00101     FXString arguments() const;
00103     void setArguments(const FXString &args);
00105     FXString workingDir() const;
00107     void setWorkingDir(const FXString &dir);
00109     ReadChannel readChannel() const throw();
00111     void setReadChannel(ReadChannel channel);
00112 
00114     FXlong returnCode() const throw();
00116     void detach();
00118     bool waitForExit(FXuint waitfor=FXINFINITE);
00120     bool terminate();
00121 private:
00123     bool create(FXuint mode=IO_ReadWrite);
00124 public:
00126     bool open(FXuint mode=IO_ReadWrite);
00128     void close();
00130     void flush();
00131 
00133     FXfval size() const;
00134 
00143     FXuval readBlock(char *data, FXuval maxlen);
00151     FXuval writeBlock(const char *data, FXuval maxlen);
00152 
00154     int ungetch(int);
00155 };
00156 
00157 } // namespace
00158 
00159 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:25 2009 for TnFOX by doxygen v1.4.7