File indexing completed on 2024-05-05 04:39:30
0001 /* 0002 SPDX-FileCopyrightText: 2013 Christoph Thielecke <crissi99@gmx.de> 0003 SPDX-FileCopyrightText: 2016 Anton Anikin <anton.anikin@htower.ru> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef CPPCHECK_PARSER_H 0009 #define CPPCHECK_PARSER_H 0010 0011 #include <interfaces/iproblem.h> 0012 0013 #include <QStack> 0014 #include <QXmlStreamReader> 0015 0016 namespace cppcheck 0017 { 0018 0019 /// A class which parses cppcheck's XML output 0020 class CppcheckParser : protected QXmlStreamReader 0021 { 0022 public: 0023 CppcheckParser(); 0024 ~CppcheckParser(); 0025 0026 using QXmlStreamReader::addData; 0027 0028 QVector<KDevelop::IProblem::Ptr> parse(); 0029 0030 private: 0031 void storeError(QVector<KDevelop::IProblem::Ptr>& problems); 0032 KDevelop::IProblem::Ptr getProblem(int locationIdx = 0) const; 0033 0034 // XML parsing 0035 bool endElement(QVector<KDevelop::IProblem::Ptr>& problems); 0036 bool startElement(); 0037 void clear(); 0038 0039 enum State { 0040 Unknown, 0041 Results, 0042 CppCheck, 0043 Errors, 0044 Error, 0045 Location 0046 }; 0047 0048 QStack<State> m_stateStack; 0049 0050 // error info 0051 QString m_errorSeverity; 0052 QString m_errorMessage; 0053 QString m_errorVerboseMessage; 0054 bool m_errorInconclusive = false; 0055 QStringList m_errorFiles; 0056 QVector<int> m_errorLines; 0057 }; 0058 0059 } 0060 0061 #endif