• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDE3Support

K3ProcIO Class Reference

A slightly simpler interface to K3Process. More...

#include <k3procio.h>

Inheritance diagram for K3ProcIO:
K3Process QObject

List of all members.

Signals

void readReady (K3ProcIO *pio)

Public Member Functions

void ackRead ()
void closeWhenDone ()
void enableReadSignals (bool enable)
 K3ProcIO (QTextCodec *codec=0)
int readln (QString &line, bool autoAck=true, bool *partial=0)
void resetAll ()
void setComm (Communication comm)
bool start (RunMode runmode=NotifyOnExit, bool includeStderr=false)
bool writeStdin (const QByteArray &data)
bool writeStdin (const QByteArray &line, bool appendnewline)
bool writeStdin (const QString &line, bool appendnewline=true)
 ~K3ProcIO ()

Protected Slots

void received (K3Process *proc, char *buffer, int buflen)
void sent (K3Process *)

Protected Member Functions

void controlledEmission ()

Detailed Description

A slightly simpler interface to K3Process.

Deprecated:
Use KProcess and KPtyProcess instead.

This class provides a slightly simpler interface to the communication functions provided by K3Process. The simplifications are:

  • The buffer for a write is copied to an internal K3ProcIO 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, K3ProcIO 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 K3Process.

Author:
David Sweet

Definition at line 50 of file k3procio.h.


Constructor & Destructor Documentation

K3ProcIO::K3ProcIO ( QTextCodec *  codec = 0  )  [explicit]

Constructor.

Definition at line 49 of file k3procio.cpp.

K3ProcIO::~K3ProcIO (  ) 

Destructor.

Definition at line 60 of file k3procio.cpp.


Member Function Documentation

void K3ProcIO::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.

Definition at line 197 of file k3procio.cpp.

void K3ProcIO::closeWhenDone (  ) 

Closes stdin after all data has been send.

Definition at line 163 of file k3procio.cpp.

void K3ProcIO::controlledEmission (  )  [protected]

Definition at line 205 of file k3procio.cpp.

void K3ProcIO::enableReadSignals ( bool  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

Definition at line 216 of file k3procio.cpp.

int K3ProcIO::readln ( QString &  line,
bool  autoAck = true,
bool *  partial = 0 
)

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 K3ProcIO 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.

Definition at line 225 of file k3procio.cpp.

void K3ProcIO::readReady ( K3ProcIO *  pio  )  [signal]

Emitted when the process is ready for reading.

Parameters:
pio the process that emitted the signal
See also:
enableReadSignals()
void K3ProcIO::received ( K3Process *  proc,
char *  buffer,
int  buflen 
) [protected, slot]

Definition at line 190 of file k3procio.cpp.

void K3ProcIO::resetAll (  ) 

Reset the class.

Doesn't kill the process.

Definition at line 67 of file k3procio.cpp.

void K3ProcIO::sent ( K3Process *   )  [protected, slot]

Definition at line 174 of file k3procio.cpp.

void K3ProcIO::setComm ( Communication  comm  ) 

Sets the communication mode to be passed to K3Process::start() by start().

The default communication mode is K3Process::All. You probably want to use this function in conjunction with K3Process::setUsePty().

Parameters:
comm the communication mode

Definition at line 91 of file k3procio.cpp.

bool K3ProcIO::start ( RunMode  runmode = NotifyOnExit,
bool  includeStderr = false 
)

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 K3Process 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.

Definition at line 96 of file k3procio.cpp.

bool K3ProcIO::writeStdin ( const QByteArray &  data  ) 

Writes data to stdin of the process.

Parameters:
data Data to write.
Returns:
true if successful, false otherwise

Definition at line 147 of file k3procio.cpp.

bool K3ProcIO::writeStdin ( const QByteArray &  line,
bool  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

Definition at line 118 of file k3procio.cpp.

bool K3ProcIO::writeStdin ( const QString &  line,
bool  appendnewline = true 
)

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

Definition at line 113 of file k3procio.cpp.


The documentation for this class was generated from the following files:
  • k3procio.h
  • k3procio.cpp

KDE3Support

Skip menu "KDE3Support"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal