lib/util/processlinemaker.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include "processlinemaker.h"
00021
#include "processlinemaker.moc"
00022
00023
#include <kprocess.h>
00024
00025 ProcessLineMaker::ProcessLineMaker()
00026 {
00027 }
00028
00029 ProcessLineMaker::ProcessLineMaker(
const KProcess* proc )
00030 {
00031 connect(proc, SIGNAL(receivedStdout(
KProcess*,
char*,
int)),
00032
this, SLOT(
slotReceivedStdout(
KProcess*,
char*,
int)) );
00033
00034 connect(proc, SIGNAL(receivedStderr(
KProcess*,
char*,
int)),
00035
this, SLOT(
slotReceivedStderr(
KProcess*,
char*,
int)) );
00036 }
00037
00038 void ProcessLineMaker::slotReceivedStdout(
const QString& s )
00039 {
00040
00041
if (!
stderrbuf.isEmpty()) {
00042 emit
receivedStderrLine(
stderrbuf);
00043
stderrbuf =
"";
00044 }
00045
00046
stdoutbuf += s;
00047
int pos;
00048
while ( (pos =
stdoutbuf.find(
'\n')) != -1) {
00049
QString line =
stdoutbuf.left(pos);
00050 emit
receivedStdoutLine(line);
00051
stdoutbuf.remove(0, pos+1);
00052 }
00053 }
00054
00055 void ProcessLineMaker::slotReceivedStdout(
KProcess*,
char *buffer,
int buflen )
00056 {
00057
slotReceivedStdout( QString::fromLocal8Bit( buffer, buflen ) );
00058 }
00059
00060 void ProcessLineMaker::slotReceivedStdout(
const char* buffer )
00061 {
00062
slotReceivedStdout( QString::fromLocal8Bit( buffer ) );
00063 }
00064
00065 void ProcessLineMaker::slotReceivedStderr(
const QString& s )
00066 {
00067
00068
if (!
stdoutbuf.isEmpty()) {
00069 emit
receivedStdoutLine(
stdoutbuf);
00070
stdoutbuf =
"";
00071 }
00072
00073
stderrbuf += s;
00074
int pos;
00075
while ( (pos =
stderrbuf.find(
'\n')) != -1) {
00076
QString line =
stderrbuf.left(pos);
00077 emit
receivedStderrLine(line);
00078
stderrbuf.remove(0, pos+1);
00079 }
00080 }
00081
00082 void ProcessLineMaker::slotReceivedStderr(
KProcess*,
char *buffer,
int buflen )
00083 {
00084
slotReceivedStderr( QString::fromLocal8Bit( buffer, buflen ) );
00085 }
00086
00087 void ProcessLineMaker::slotReceivedStderr(
const char* buffer )
00088 {
00089
slotReceivedStderr( QString::fromLocal8Bit( buffer ) );
00090 }
00091
00092 void ProcessLineMaker::clearBuffers( )
00093 {
00094
stderrbuf =
"";
00095
stdoutbuf =
"";
00096 }
This file is part of the documentation for KDevelop Version 3.0.4.