org.kde.koala
Class KProcIO
public
class
KProcIO
extends KProcess
KProcIO
This class provides a slightly simpler interface to the communication
functions provided by KProcess. The simplifications are:
The buffer for a write is copied to an internal KProcIO
buffer and maintained/freed appropriately. There is no need
to be concerned with wroteStdin() signals _at_all_.
readln() reads a line of data and buffers any leftovers.
Conversion from/to unicode.
Basically, KProcIO gives you buffered I/O similar to fgets()/fputs().
Aside from these, and the fact that start() takes different
parameters, use this class just like KProcess.
See
KProcIOSignals for signals emitted by KProcIO
Author: David Sweet
UNKNOWN: A slightly simpler interface to KProcess.
Method Summary |
void | ackRead()
Call this after you have finished processing a readReady()
signal. |
String | className() |
void | closeWhenDone()
Closes stdin after all data has been send. |
protected void | controlledEmission() |
void | dispose() Delete the wrapped C++ instance ahead of finalize() |
void | enableReadSignals(boolean enable)
Turns readReady() signals on and off.
|
protected void | finalize() Deletes the wrapped C++ instance |
boolean | isDisposed() Has the wrapped C++ instance been deleted? |
QMetaObject | metaObject() |
int | readln(StringBuffer line, boolean autoAck, boolean[] partial)
Reads a line of text (up to and including '\\n').
|
int | readln(StringBuffer line, boolean autoAck) |
int | readln(StringBuffer line) |
protected void | received(KProcess proc, String buffer, int buflen) |
void | resetAll()
Reset the class. |
protected void | sent(KProcess arg1) |
void | setComm(int comm)
Sets the communication mode to be passed to KProcess.start()
by start(). |
boolean | start(int runmode, boolean includeStderr)
Starts the process. |
boolean | start(int runmode) |
boolean | start() |
boolean | writeStdin(String line, boolean appendnewline)
Writes text to stdin of the process. |
boolean | writeStdin(String line) |
boolean | writeStdin(byte[] data)
Writes data to stdin of the process. |
protected KProcIO(Class dummy)
public KProcIO(QTextCodec codec)
Constructor
UNKNOWN: Constructor
public KProcIO()
public void ackRead()
Call this after you have finished processing a readReady()
signal. This call need not be made in the slot that was signalled
by readReady(). You won't receive any more readReady() signals
until you acknowledge with ackRead(). This prevents your slot
from being reentered while you are still processing the current
data. If this doesn't matter, then call ackRead() right away in
your readReady()-processing slot.
UNKNOWN: Call this after you have finished processing a readReady() signal.
public String className()
public void closeWhenDone()
Closes stdin after all data has been send.
UNKNOWN: Closes stdin after all data has been send.
protected void controlledEmission()
public void dispose()
Delete the wrapped C++ instance ahead of finalize()
public void enableReadSignals(boolean enable)
Turns readReady() signals on and off.
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...)
Parameters: enable true to turn the signals on, false to turn them off
UNKNOWN: Turns readReady() signals on and off.
protected void finalize()
Deletes the wrapped C++ instance
public boolean isDisposed()
Has the wrapped C++ instance been deleted?
public QMetaObject metaObject()
public int readln(StringBuffer line, boolean autoAck, boolean[] partial)
Reads a line of text (up to and including '\\n').
Use readln() in response to a readReady() signal.
You may use it multiple times if more than one line of data is
available.
Be sure to use ackRead() when you have finished processing the
readReady() signal. This informs KProcIO that you are ready for
another readReady() signal.
readln() never blocks.
autoAck==true makes these functions call ackRead() for you.
Parameters: line is used to store the line that was read. autoAck when true, ackRead() is called for you. partial 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.
Returns: the number of characters read, or -1 if no data is available.
UNKNOWN: Reads a line of text (up to and including '\\n').
public int readln(StringBuffer line, boolean autoAck)
public int readln(StringBuffer line)
protected void received(
KProcess proc, String buffer, int buflen)
public void resetAll()
Reset the class. Doesn't kill the process.
UNKNOWN: Reset the class.
public void setComm(int comm)
Sets the communication mode to be passed to KProcess.start()
by start(). The default communication mode is KProcess.All.
You probably want to use this function in conjunction with
KProcess.setUsePty().
Parameters: comm the communication mode
UNKNOWN: Sets the communication mode to be passed to KProcess.start() by start().
public boolean start(int runmode, boolean includeStderr)
Starts the process. It will fail in the following cases:
The process is already running.
The command line argument list is empty.
The starting of the process failed (could not fork).
The executable was not found.
Parameters: runmode For a detailed description of the
various run modes, have a look at the
general description of the KProcess class. includeStderr If true, data from both stdout and stderr is
listened to. If false, only stdout is listened to.
Returns: true on success, false on error.
UNKNOWN: Starts the process.
public boolean start(int runmode)
public boolean start()
public boolean writeStdin(String line, boolean appendnewline)
Writes text to stdin of the process.
Parameters: line Text to write. appendnewline if true, a newline '\\n' is appended.
Returns: true if successful, false otherwise
UNKNOWN: Writes text to stdin of the process.
public boolean writeStdin(String line)
public boolean writeStdin(byte[] data)
Writes data to stdin of the process.
Parameters: data Data to write.
Returns: true if successful, false otherwise
UNKNOWN: Writes data to stdin of the process.