Cppcheck
csvreport.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 CSV_REPORT_H
20 #define CSV_REPORT_H
21 
22 #include "report.h"
23 
24 #include <QString>
25 #include <QTextStream>
26 
27 class ErrorItem;
28 
29 /// @addtogroup GUI
30 /// @{
31 
32 
33 /**
34  * @brief CSV text file report.
35  * This report exports results as CSV (comma separated values). CSV files are
36  * easy to import to many other programs.
37  * @todo This class should be inherited from TxtReport?
38  */
39 class CsvReport : public Report {
40 public:
41  explicit CsvReport(const QString &filename);
42 
43  /**
44  * @brief Create the report (file).
45  * @return true if succeeded, false if file could not be created.
46  */
47  bool create() override;
48 
49  /**
50  * @brief Write report header.
51  */
52  void writeHeader() override;
53 
54  /**
55  * @brief Write report footer.
56  */
57  void writeFooter() override;
58 
59  /**
60  * @brief Write error to report.
61  * @param error Error data.
62  */
63  void writeError(const ErrorItem &error) override;
64 
65 private:
66 
67  /**
68  * @brief Text stream writer for writing the report in text format.
69  */
70  QTextStream mTxtWriter;
71 };
72 /// @}
73 #endif // CSV_REPORT_H
CSV text file report.
Definition: csvreport.h:39
bool create() override
Create the report (file).
Definition: csvreport.cpp:33
void writeHeader() override
Write report header.
Definition: csvreport.cpp:42
void writeFooter() override
Write report footer.
Definition: csvreport.cpp:52
QTextStream mTxtWriter
Text stream writer for writing the report in text format.
Definition: csvreport.h:70
CsvReport(const QString &filename)
Definition: csvreport.cpp:29
void writeError(const ErrorItem &error) override
Write error to report.
Definition: csvreport.cpp:57
A class containing error data for one error.
Definition: erroritem.h:72
A base class for reports.
Definition: report.h:34
@ error
Programming error.