File indexing completed on 2024-04-28 04:37:00
0001 /* 0002 SPDX-FileCopyrightText: 2012 Morten Danielsen Volden <mvolden2@gmail.com> 0003 SPDX-FileCopyrightText: 2016 Kevin Funk <kfunk@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KDEVPLATFORM_IFILTERSTRATEGY_H 0009 #define KDEVPLATFORM_IFILTERSTRATEGY_H 0010 0011 #include "outputviewexport.h" 0012 0013 #include <QMetaType> 0014 #include <QString> 0015 0016 namespace KDevelop 0017 { 0018 0019 struct FilteredItem; 0020 0021 /** 0022 * Interface class for filtering output. Filtered output is divided into two categories: Errors 0023 * and Actions. Use this interface if you want to write a filter for the outputview. 0024 * 0025 * @author Morten Danielsen Volden 0026 */ 0027 class KDEVPLATFORMOUTPUTVIEW_EXPORT IFilterStrategy 0028 { 0029 public: 0030 IFilterStrategy(); 0031 virtual ~IFilterStrategy(); 0032 0033 struct Progress 0034 { 0035 Progress(const QString& status = QString(), int percent = -1) 0036 : status(status), percent(percent) {} 0037 0038 QString status; /// Status message (example: "Building foo.cpp") 0039 int percent; /// Percentage from 0-100; -1 indicates no progress could be parsed 0040 }; 0041 0042 /** 0043 * Examine if a given line contains output that is defined as an error (E.g. from a script or from a compiler, or other). 0044 * @param line the line to examine 0045 * @return FilteredItem with associated metadata if an error is found, an item of type InvalidItem otherwise 0046 **/ 0047 virtual FilteredItem errorInLine(QString const& line) = 0; 0048 0049 /** 0050 * Examine if a given line contains output that is defined as an action (E.g. from a script or from a compiler, or other). 0051 * @param line the line to examine 0052 * @return Filtered of type ActionItem with associated metadata if an action is found, an item of type InvalidItem otherwise 0053 **/ 0054 virtual FilteredItem actionInLine(QString const& line) = 0; 0055 0056 /** 0057 * Examine if a given line contains output which reports progress information 0058 * 0059 * E.g. `make` reports progress like this: 0060 * @code 0061 * [ 5%] Doing something 0062 * [ 6%] Doing something 0063 * @endcode 0064 * 0065 * @return Processed percent & status of the output, default implementation returns default-constructed value 0066 */ 0067 virtual Progress progressInLine(const QString& line); 0068 0069 }; 0070 0071 } // namespace KDevelop 0072 0073 Q_DECLARE_METATYPE(KDevelop::IFilterStrategy*) 0074 Q_DECLARE_METATYPE(KDevelop::IFilterStrategy::Progress) 0075 0076 #endif // KDEVPLATFORM_IFILTERSTRATEGY_H