1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef IOUTPUTPARSER_H |
6 | #define IOUTPUTPARSER_H |
7 | |
8 | #include "task.h" |
9 | #include "common/widget/outputpane.h" |
10 | |
11 | #include <QObject> |
12 | |
13 | class Task; |
14 | class IOutputParser : public QObject |
15 | { |
16 | Q_OBJECT |
17 | public: |
18 | IOutputParser() = default; |
19 | ~IOutputParser() override; |
20 | |
21 | virtual void appendOutputParser(IOutputParser *parser); |
22 | |
23 | IOutputParser *takeOutputParserChain(); |
24 | |
25 | IOutputParser *childParser() const; |
26 | void setChildParser(IOutputParser *parser); |
27 | |
28 | virtual void stdOutput(const QString &line, OutputPane::OutputFormat format); |
29 | virtual void stdError(const QString &line); |
30 | |
31 | virtual bool hasFatalErrors() const; |
32 | virtual void setWorkingDirectory(const QString &workingDirectory); |
33 | |
34 | void flush(); // flush out pending tasks |
35 | |
36 | static QString rightTrimmed(const QString &in); |
37 | |
38 | signals: |
39 | void addOutput(const QString &string, OutputPane::OutputFormat format); |
40 | void addTask(const Task &task, int linkedOutputLines = 0, int skipLines = 0); |
41 | |
42 | public slots: |
43 | virtual void outputAdded(const QString &string, OutputPane::OutputFormat format); |
44 | virtual void taskAdded(const Task &task, int linkedOutputLines = 0, int skipLines = 0); |
45 | |
46 | private: |
47 | virtual void doFlush(); |
48 | |
49 | IOutputParser *outParser = nullptr; |
50 | }; |
51 | |
52 | #endif // IOUTPUTPARSER_H |
53 | |