1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/***************************************************************************
* Copyright (C) 2005 by David Saxton *
* david@bluehaze.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef EXTERNALLANGUAGE_H
#define EXTERNALLANGUAGE_H
#include "language.h"
class KProcess;
/**
Base class for Language support that relies on an external program; so this
class provides functionality for dealing with external processes.
@author Daniel Clarke
@author David Saxton
*/
class ExternalLanguage : public Language
{
Q_OBJECT
TQ_OBJECT
public:
ExternalLanguage( ProcessChain *processChain, KTechlab *parent, const TQString &name );
~ExternalLanguage();
protected slots:
void receivedStdout( KProcess *, char * buffer, int buflen );
void receivedStderr( KProcess *, char * buffer, int buflen );
void processExited( KProcess * );
protected:
/**
* Call this to start the language process. ExternalLanguage will ensure
* that communication et all is properly set up.
* @return true on success, false on error
*/
bool start();
/**
* @returns whether the string outputted to stdout is an error or not
*/
virtual bool isError( const TQString &message ) const = 0;
/**
* @returns whether the string outputted to stderr is fatal (stopped compilation)
*/
virtual bool isStderrOutputFatal( const TQString & message ) const { Q_UNUSED(message); return true; }
/**
* @returns whether the string outputted to stdout is a warning or not
*/
virtual bool isWarning( const TQString &message ) const = 0;
/**
* Called when the process outputs a (non warning/error) message
*/
virtual void outputtedMessage( const TQString &/*message*/ ) {};
/**
* Called when the process outputs a warning
*/
virtual void outputtedWarning( const TQString &/*message*/ ) {};
/**
* Called when the process outputs an error
*/
virtual void outputtedError( const TQString &/*message*/ ) {};
/**
* Called when the process exits (called before any signals are emitted,
* etc). If you reinherit this function, you should return whether
* everything is OK.
*/
virtual bool processExited( bool successfully ) { return successfully; }
/**
* Call this function if your process could not be started - the process
* will be deleted, and a failure signal emitted.
*/
void processInitFailed();
/**
* Disconnects and deletes the language's process.
*/
void deleteLanguageProcess();
/**
* Creates process and makes connections, ready for the derived class to
* add arguments and start the process.
*/
void resetLanguageProcess();
/**
* Prints out the command used for running the process, with any arguments
* that contain spaces put into quotation marks.
*/
void displayProcessCommand();
KProcess * m_languageProcess;
};
#endif
|