Cppcheck
txtreport.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2023 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TXT_REPORT_H
20 #define TXT_REPORT_H
21 
22 #include "report.h"
23 
24 #include <QString>
25 #include <QObject>
26 #include <QTextStream>
27 
28 class ErrorItem;
29 
30 /// @addtogroup GUI
31 /// @{
32 
33 
34 /**
35  * @brief Text file report.
36  * This report mimics the output of the command line cppcheck.
37  */
38 class TxtReport : public Report {
39  Q_OBJECT
40 
41 public:
42  explicit TxtReport(const QString &filename);
43 
44  /**
45  * @brief Create the report (file).
46  * @return true if succeeded, false if file could not be created.
47  */
48  bool create() override;
49 
50  /**
51  * @brief Write report header.
52  */
53  void writeHeader() override;
54 
55  /**
56  * @brief Write report footer.
57  */
58  void writeFooter() override;
59 
60  /**
61  * @brief Write error to report.
62  * @param error Error data.
63  */
64  void writeError(const ErrorItem &error) override;
65 
66 private:
67 
68  /**
69  * @brief Text stream writer for writing the report in text format.
70  */
71  QTextStream mTxtWriter;
72 };
73 /// @}
74 #endif // TXT_REPORT_H
A class containing error data for one error.
Definition: erroritem.h:72
A base class for reports.
Definition: report.h:34
Text file report.
Definition: txtreport.h:38
void writeHeader() override
Write report header.
Definition: txtreport.cpp:41
void writeFooter() override
Write report footer.
Definition: txtreport.cpp:46
void writeError(const ErrorItem &error) override
Write error to report.
Definition: txtreport.cpp:51
TxtReport(const QString &filename)
Definition: txtreport.cpp:28
bool create() override
Create the report (file).
Definition: txtreport.cpp:32
QTextStream mTxtWriter
Text stream writer for writing the report in text format.
Definition: txtreport.h:71
@ error
Programming error.