.TH "KProcIO" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KProcIO \- KProcIO A slightly simpler interface to \fBKProcess\fP.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kprocio.h>\fP
.PP
Inherits \fBKProcess\fP.
.PP
.SS "Signals"

.in +1c
.ti -1c
.RI "void \fBreadReady\fP (\fBKProcIO\fP *pio)"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKProcIO\fP (\fBQTextCodec\fP *codec=0)"
.br
.ti -1c
.RI "\fB~KProcIO\fP ()"
.br
.ti -1c
.RI "void \fBsetComm\fP (\fBCommunication\fP comm)"
.br
.ti -1c
.RI "bool \fBstart\fP (\fBRunMode\fP runmode=NotifyOnExit, bool includeStderr=false)"
.br
.ti -1c
.RI "bool \fBwriteStdin\fP (const \fBQString\fP &line, bool appendnewline=true)"
.br
.ti -1c
.RI "bool \fBwriteStdin\fP (const \fBQCString\fP &line, bool appendnewline)"
.br
.ti -1c
.RI "bool \fBwriteStdin\fP (const \fBQByteArray\fP &data)"
.br
.ti -1c
.RI "KDE_DEPRECATED bool \fBfputs\fP (const \fBQString\fP &line, bool AppendNewLine=true)"
.br
.ti -1c
.RI "void \fBcloseWhenDone\fP ()"
.br
.ti -1c
.RI "int \fBreadln\fP (\fBQString\fP &line, bool autoAck=true, bool *partial=0)"
.br
.ti -1c
.RI "KDE_DEPRECATED int \fBfgets\fP (\fBQString\fP &line, bool autoAck=false)"
.br
.ti -1c
.RI "void \fBresetAll\fP ()"
.br
.ti -1c
.RI "void \fBackRead\fP ()"
.br
.ti -1c
.RI "void \fBenableReadSignals\fP (bool enable)"
.br
.in -1c
.SS "Protected Slots"

.in +1c
.ti -1c
.RI "void \fBreceived\fP (\fBKProcess\fP *proc, char *buffer, int buflen)"
.br
.ti -1c
.RI "void \fBsent\fP (\fBKProcess\fP *)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "void \fBcontrolledEmission\fP ()"
.br
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SS "Protected Attributes"

.in +1c
.ti -1c
.RI "\fBQPtrList\fP< \fBQByteArray\fP > \fBoutbuffer\fP"
.br
.ti -1c
.RI "\fBQCString\fP \fBrecvbuffer\fP"
.br
.ti -1c
.RI "\fBQTextCodec\fP * \fBcodec\fP"
.br
.ti -1c
.RI "int \fBrbi\fP"
.br
.ti -1c
.RI "bool \fBneedreadsignal\fP"
.br
.ti -1c
.RI "bool \fBreadsignalon\fP"
.br
.ti -1c
.RI "bool \fBwriteready\fP"
.br
.in -1c
.SH "Detailed Description"
.PP 
KProcIO A slightly simpler interface to \fBKProcess\fP. 

This class provides a slightly simpler interface to the communication functions provided by \fBKProcess\fP. The simplifications are: 
.PD 0

.IP "\(bu" 2
The buffer for a write is copied to an internal KProcIO buffer and maintained/freed appropriately. There is no need to be concerned with \fBwroteStdin()\fP signals _at_all_. 
.IP "\(bu" 2
\fBreadln()\fP reads a line of data and buffers any leftovers. 
.IP "\(bu" 2
Conversion from/to unicode.
.PP
Basically, KProcIO gives you buffered I/O similar to \fBfgets()\fP/fputs().
.PP
Aside from these, and the fact that \fBstart()\fP takes different parameters, use this class just like \fBKProcess\fP.
.PP
\fBAuthor:\fP
.RS 4
David Sweet 
.RE
.PP

.PP
Definition at line 50 of file kprocio.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KProcIO::KProcIO (\fBQTextCodec\fP * codec = \fC0\fP)"
.PP
Constructor. 
.PP
Definition at line 38 of file kprocio.cpp.
.PP
References QTextCodec::codecForName(), endl(), and QPtrList::setAutoDelete().
.SS "KProcIO::~\fBKProcIO\fP ()"
.PP
Destructor. 
.PP
Definition at line 55 of file kprocio.cpp.
.SH "Member Function Documentation"
.PP 
.SS "void KProcIO::setComm (\fBCommunication\fP comm)"
.PP
Sets the communication mode to be passed to \fBKProcess::start()\fP by \fBstart()\fP. 
.PP
The default communication mode is KProcess::All. You probably want to use this function in conjunction with KProcess::setUsePty(). 
.PP
\fBParameters:\fP
.RS 4
\fIcomm\fP the communication mode 
.RE
.PP

.PP
Definition at line 83 of file kprocio.cpp.
.SS "bool KProcIO::start (\fBRunMode\fP runmode = \fCNotifyOnExit\fP, bool includeStderr = \fCfalse\fP)"
.PP
Starts the process. 
.PP
It will fail in the following cases: 
.PD 0

.IP "\(bu" 2
The process is already running. 
.IP "\(bu" 2
The command line argument list is empty. 
.IP "\(bu" 2
The starting of the process failed (could not fork). 
.IP "\(bu" 2
The executable was not found.
.PP
\fBParameters:\fP
.RS 4
\fIrunmode\fP For a detailed description of the various run modes, have a look at the general description of the \fBKProcess\fP class. 
.br
\fIincludeStderr\fP If true, data from both stdout and stderr is listened to. If false, only stdout is listened to. 
.RE
.PP
\fBReturns:\fP
.RS 4
true on success, false on error. 
.RE
.PP

.PP
Definition at line 88 of file kprocio.cpp.
.PP
References QObject::connect(), KProcess::start(), and KProcess::wroteStdin().
.SS "bool KProcIO::writeStdin (const \fBQString\fP & line, bool appendnewline = \fCtrue\fP)"
.PP
Writes text to stdin of the process. 
.PP
\fBParameters:\fP
.RS 4
\fIline\fP Text to write. 
.br
\fIappendnewline\fP if true, a newline '\\n' is appended. 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP

.PP
Definition at line 105 of file kprocio.cpp.
.PP
References QTextCodec::fromUnicode().
.SS "bool KProcIO::writeStdin (const \fBQCString\fP & line, bool appendnewline)"
.PP
Writes text to stdin of the process. 
.PP
\fBParameters:\fP
.RS 4
\fIline\fP Text to write. 
.br
\fIappendnewline\fP if true, a newline '\\n' is appended. 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP

.PP
Definition at line 110 of file kprocio.cpp.
.PP
References QPtrList::append(), QCString::length(), and KProcess::writeStdin().
.SS "bool KProcIO::writeStdin (const \fBQByteArray\fP & data)"
.PP
Writes data to stdin of the process. 
.PP
\fBParameters:\fP
.RS 4
\fIdata\fP Data to write. 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP

.PP
Definition at line 139 of file kprocio.cpp.
.PP
References QPtrList::append(), and KProcess::writeStdin().
.SS "KDE_DEPRECATED bool KProcIO::fputs (const \fBQString\fP & line, bool AppendNewLine = \fCtrue\fP)\fC [inline]\fP"
.PP
This function just calls \fBwriteStdin()\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIline\fP Text to write. 
.br
\fIAppendNewLine\fP if true, a newline '\\n' is appended. 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP
\fBDeprecated\fP
.RS 4
.RE
.PP

.PP
Definition at line 123 of file kprocio.h.
.PP
References KProcess::writeStdin().
.SS "void KProcIO::closeWhenDone ()"
.PP
Closes stdin after all data has been send. 
.PP
Definition at line 154 of file kprocio.cpp.
.PP
References QPtrList::append(), and KProcess::closeStdin().
.SS "int KProcIO::readln (\fBQString\fP & line, bool autoAck = \fCtrue\fP, bool * partial = \fC0\fP)"
.PP
Reads a line of text (up to and including '\\n'). 
.PP
Use \fBreadln()\fP in response to a \fBreadReady()\fP signal. You may use it multiple times if more than one line of data is available. Be sure to use \fBackRead()\fP when you have finished processing the \fBreadReady()\fP signal. This informs KProcIO that you are ready for another \fBreadReady()\fP signal.
.PP
\fBreadln()\fP never blocks.
.PP
autoAck==true makes these functions call \fBackRead()\fP for you.
.PP
\fBParameters:\fP
.RS 4
\fIline\fP is used to store the line that was read. 
.br
\fIautoAck\fP when true, \fBackRead()\fP is called for you. 
.br
\fIpartial\fP when provided the line is returned even if it does not contain a '\\n'. *partial will be set to false if the line contains a '\\n' and false otherwise. 
.RE
.PP
\fBReturns:\fP
.RS 4
the number of characters read, or -1 if no data is available. 
.RE
.PP

.PP
Definition at line 225 of file kprocio.cpp.
.PP
References QCString::find(), QCString::length(), QCString::mid(), and QTextCodec::toUnicode().
.SS "KDE_DEPRECATED int KProcIO::fgets (\fBQString\fP & line, bool autoAck = \fCfalse\fP)\fC [inline]\fP"
.PP
This function calls \fBreadln()\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIline\fP is used to store the line that was read. 
.br
\fIautoAck\fP when true, \fBackRead()\fP is called for you. 
.RE
.PP
\fBReturns:\fP
.RS 4
the number of characters read, or -1 if no data is available. 
.RE
.PP
.PP
\fBDeprecated\fP
.RS 4
use readln. Note that it has an inverted autoAck default, though. 
.RE
.PP

.PP
Definition at line 162 of file kprocio.h.
.SS "void KProcIO::resetAll ()"
.PP
Reset the class. 
.PP
Doesn't kill the process. 
.PP
Definition at line 61 of file kprocio.cpp.
.PP
References QPtrList::clear(), KProcess::clearArguments(), QObject::disconnect(), KProcess::isRunning(), KProcess::kill(), and KProcess::wroteStdin().
.SS "void KProcIO::ackRead ()"
.PP
Call this after you have finished processing a \fBreadReady()\fP signal. 
.PP
This call need not be made in the slot that was signalled by \fBreadReady()\fP. You won't receive any more \fBreadReady()\fP signals until you acknowledge with \fBackRead()\fP. This prevents your slot from being reentered while you are still processing the current data. If this doesn't matter, then call \fBackRead()\fP right away in your \fBreadReady()\fP-processing slot. 
.PP
Definition at line 196 of file kprocio.cpp.
.PP
References QCString::length().
.SS "void KProcIO::enableReadSignals (bool enable)"
.PP
Turns \fBreadReady()\fP signals on and off. 
.PP
You can turn this off at will and not worry about losing any data. (as long as you turn it back on at some point...) 
.PP
\fBParameters:\fP
.RS 4
\fIenable\fP true to turn the signals on, false to turn them off 
.RE
.PP

.PP
Definition at line 217 of file kprocio.cpp.
.PP
References readReady().
.SS "void KProcIO::readReady (\fBKProcIO\fP * pio)\fC [signal]\fP"
.PP
Emitted when the process is ready for reading. 
.PP
\fBParameters:\fP
.RS 4
\fIpio\fP the process that emitted the signal 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBenableReadSignals()\fP 
.RE
.PP

.PP
Referenced by enableReadSignals().

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
