• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • KDevelop Widgets Library
 

KDevelop Widgets Library

  • lib
  • widgets
processlinemaker.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 John Firebaugh <jfirebaugh@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#include "processlinemaker.h"
21#include "processlinemaker.moc"
22
23#include <kprocess.h>
24
25ProcessLineMaker::ProcessLineMaker()
26{
27}
28
29ProcessLineMaker::ProcessLineMaker( const TDEProcess* proc )
30{
31 connect(proc, TQ_SIGNAL(receivedStdout(TDEProcess*,char*,int)),
32 this, TQ_SLOT(slotReceivedStdout(TDEProcess*,char*,int)) );
33
34 connect(proc, TQ_SIGNAL(receivedStderr(TDEProcess*,char*,int)),
35 this, TQ_SLOT(slotReceivedStderr(TDEProcess*,char*,int)) );
36}
37
38void ProcessLineMaker::slotReceivedStdout( const char *buffer )
39{
40 stdoutbuf += buffer;
41 int pos;
42 while ( (pos = stdoutbuf.find('\n')) != -1) {
43 TQCString line = stdoutbuf.left( pos );
44 emit receivedStdoutLine(line);
45 stdoutbuf.remove(0, pos+1);
46 }
47 if( !stdoutbuf.isEmpty() ) {
48 emit receivedPartialStdoutLine( stdoutbuf );
49 stdoutbuf.truncate(0);
50 }
51}
52
53void ProcessLineMaker::slotReceivedStdout( TDEProcess*, char *buffer, int )
54{
55 slotReceivedStdout(buffer); // It is zero-terminated
56}
57
58
59void ProcessLineMaker::slotReceivedStderr( const char *buffer )
60{
61 stderrbuf += buffer;
62 int pos;
63 while ( (pos = stderrbuf.find('\n')) != -1) {
64 TQCString line = stderrbuf.left( pos );
65 emit receivedStderrLine(line);
66 stderrbuf.remove(0, pos+1);
67 }
68 if( !stderrbuf.isEmpty() ) {
69 emit receivedPartialStderrLine( stderrbuf );
70 stderrbuf.truncate(0);
71 }
72}
73
74void ProcessLineMaker::slotReceivedStderr( TDEProcess*, char *buffer, int )
75{
76 slotReceivedStderr(buffer); // It is zero-terminated
77}
78
79void ProcessLineMaker::clearBuffers( )
80{
81 stderrbuf.truncate(0);
82 stdoutbuf.truncate(0);
83}
84
85void ProcessLineMaker::flush()
86{
87 if( !stderrbuf.isEmpty() )
88 emit receivedStderrLine(stderrbuf);
89 if( !stdoutbuf.isEmpty() )
90 emit receivedStdoutLine(stdoutbuf);
91 clearBuffers();
92}
93
processlinemaker.h
Utility objects for process output views.

KDevelop Widgets Library

Skip menu "KDevelop Widgets Library"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members

KDevelop Widgets Library

Skip menu "KDevelop Widgets Library"
  • buildtools
  •   lib
  •     base
  •     parsers
  •       autotools
  •       qmake
  •     widgets
  •   api
  • languages
  •   lib
  •     debugger
  •     designer_integration
  •     interfaces
  • lib
  •   catalog
  •   interfaces
  •     extensions
  •     external
  •     extras
  •   util
  •   widgets
  •     propeditor
  • parts
  •   documentation
  •     interfaces
  • src
  •   profileengine
  •     lib
Generated for KDevelop Widgets Library by doxygen 1.15.0
This website is maintained by Timothy Pearson.