summaryrefslogtreecommitdiffstats
path: root/src/linguist/shared/xmlparser.h
blob: 891e46527aa22ae8c0410bbd7c4ab395517f8395 (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) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef XMLPARSER_H
#define XMLPARSER_H

#include <QtCore/qglobal.h>
#include <QtCore/qxmlstream.h>

QT_BEGIN_NAMESPACE

class XmlParser
{
public:
    XmlParser(QXmlStreamReader &r, bool whitespaceOnlyData = false)
        : reader(r), reportWhitespaceOnlyData(whitespaceOnlyData)
    {
    }
    virtual ~XmlParser() = default;

    bool parse();

protected:
    virtual bool startElement(QStringView namespaceURI, QStringView localName,
                              QStringView qName, const QXmlStreamAttributes &atts);
    virtual bool endElement(QStringView namespaceURI, QStringView localName,
                            QStringView qName);
    virtual bool characters(QStringView text);
    virtual bool endDocument();
    virtual bool fatalError(qint64 line, qint64 column, const QString &message);

    QXmlStreamReader &reader;
    bool reportWhitespaceOnlyData;
};

QT_END_NAMESPACE

#endif // XMLPARSER_H