File indexing completed on 2024-04-28 05:44:29
0001 /* 0002 This file is part of Massif Visualizer 0003 0004 Copyright 2010 Milian Wolff <mail@milianw.de> 0005 0006 This library is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU Lesser General Public 0008 License as published by the Free Software Foundation; either 0009 version 2.1 of the License, or (at your option) version 3, or any 0010 later version accepted by the membership of KDE e.V. (or its 0011 successor approved by the membership of KDE e.V.), which shall 0012 act as a proxy defined in Section 6 of version 3 of the license. 0013 0014 This library is distributed in the hope that it will be useful, 0015 but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0017 Lesser General Public License for more details. 0018 0019 You should have received a copy of the GNU Lesser General Public 0020 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0021 */ 0022 0023 #ifndef MASSIF_PARSER_H 0024 #define MASSIF_PARSER_H 0025 0026 0027 #include <QObject> 0028 #include <QString> 0029 #include <QStringList> 0030 0031 class QIODevice; 0032 0033 namespace Massif { 0034 0035 class FileData; 0036 0037 /** 0038 * This class parses a Massif output file and stores it's information. 0039 */ 0040 class Parser : public QObject 0041 { 0042 Q_OBJECT 0043 0044 public: 0045 Parser(); 0046 ~Parser() override; 0047 0048 /** 0049 * Parse @p file and return a FileData structure representing the data. 0050 * 0051 * @p customAllocators list of wildcard patterns used to find custom allocators 0052 * @p shouldStop if supplied, this is checked periodically. If the atomic 0053 * evaluates to true, parser stops and returns 0. 0054 * 0055 * @return Data or null if file could not be parsed. 0056 * 0057 * @note The caller has to delete the data afterwards. 0058 */ 0059 FileData* parse(QIODevice* file, 0060 const QStringList& customAllocators = QStringList(), 0061 QAtomicInt* shouldStop = nullptr); 0062 0063 /** 0064 * Returns the number of the line which could not be parsed or -1 if no error occurred. 0065 */ 0066 int errorLine() const; 0067 /** 0068 * Returns the line which could not be parsed. 0069 */ 0070 QByteArray errorLineString() const; 0071 0072 void setProgress(int value); 0073 0074 Q_SIGNALS: 0075 void progress(int value); 0076 0077 private: 0078 int m_errorLine; 0079 QByteArray m_errorLineString; 0080 }; 0081 0082 } 0083 0084 #endif // MASSIF_PARSER_H