aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/silversearcher/silversearcheroutputparser.h
blob: af7f254c9b06a086c9c8ce1a8968e92fa33500f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2017 Przemyslaw Gorszkowski <pgorszkowski@gmail.com>.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include <coreplugin/find/searchresultwindow.h>
#include <utils/filesearch.h>

#include <QList>
#include <QRegularExpression>

namespace SilverSearcher {

class SilverSearcherOutputParser
{
public:
    SilverSearcherOutputParser(const QString &output, const QRegularExpression &regexp = {});

    QList<Utils::FileSearchResult> parse();

private:
    int parseMatches();
    bool parseMatchLength();
    bool parseMatchIndex();
    bool parseLineNumber();
    bool parseFilePath();
    bool parseText();

    QString output;
    QRegularExpression regexp;
    bool hasRegexp = false;
    int outputSize = 0;
    int index = 0;
    Utils::FileSearchResult item;
    QList<Utils::FileSearchResult> items;
};

} // namespace SilverSearcher