ifilterstrategy.h 2.96 KB
Newer Older
1 2 3
/*
    Interface description for KDevelop OutputView Filter strategies
    Copyright (C) 2012  Morten Danielsen Volden mvolden2@gmail.com
4
    Copyright (C) 2016  Kevin Funk <kfunk@kde.org>
5 6 7

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation, either version 2 of the License, or
9 10 11 12 13 14 15 16 17 18 19 20
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


21 22
#ifndef KDEVPLATFORM_IFILTERSTRATEGY_H
#define KDEVPLATFORM_IFILTERSTRATEGY_H
23

24 25
#include "outputviewexport.h"

26 27
#include <QMetaType>
#include <QString>
28 29 30

namespace KDevelop
{
31

32
struct FilteredItem;
33 34

/**
35 36 37 38
* Interface class for filtering output. Filtered output is divided into two catagories: Errors
* and Actions. Use this interface if you want to write a filter for the outputview.
*
* @author Morten Danielsen Volden
39
*/
40
class KDEVPLATFORMOUTPUTVIEW_EXPORT IFilterStrategy
41 42 43 44
{
public:
    IFilterStrategy();
    virtual ~IFilterStrategy();
45

46 47 48 49 50 51 52 53 54
    struct Progress
    {
        Progress(const QString& status = QString(), int percent = -1)
            : status(status), percent(percent) {}

        QString status;   /// Status message (example: "Building foo.cpp")
        int percent; /// Percentage from 0-100; -1 indicates no progress could be parsed
    };

55 56 57
    /**
     * Examine if a given line contains output that is defined as an error (E.g. from a script or from a compiler, or other).
     * @param line the line to examine
58
     * @return FilteredItem with associated metadata if an error is found, an item of type InvalidItem otherwise
59
     **/
60
    virtual FilteredItem errorInLine(QString const& line) = 0;
61 62 63 64

    /**
     * Examine if a given line contains output that is defined as an action (E.g. from a script or from a compiler, or other).
     * @param line the line to examine
65
     * @return Filtered of type ActionItem with associated metadata if an action is found, an item of type InvalidItem otherwise
66
     **/
67
    virtual FilteredItem actionInLine(QString const& line) = 0;
68

69 70 71 72 73 74 75
    /**
     * Examine if a given line contains output which reports progress information
     *
     * E.g. `make` reports progress like this:
     * @code
     * [   5%] Doing something
     * [   6%] Doing something
76
     * @endcode
77 78 79 80
     *
     * @return Processed percent & status of the output, default implementation returns default-constructed value
     */
    virtual Progress progressInLine(const QString& line);
81

82
};
83 84 85

} // namespace KDevelop

86
Q_DECLARE_METATYPE(KDevelop::IFilterStrategy*)
Friedrich W. H. Kossebau's avatar
Friedrich W. H. Kossebau committed
87
Q_DECLARE_METATYPE(KDevelop::IFilterStrategy::Progress)
88

89
#endif // KDEVPLATFORM_IFILTERSTRATEGY_H