1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef XMLPARSER_H
5#define XMLPARSER_H
6
7#include <QtCore/qglobal.h>
8#include <QtCore/qxmlstream.h>
9
10QT_BEGIN_NAMESPACE
11
12class XmlParser
13{
14public:
15 XmlParser(QXmlStreamReader &r, bool whitespaceOnlyData = false)
16 : reader(r), reportWhitespaceOnlyData(whitespaceOnlyData)
17 {
18 }
19 virtual ~XmlParser() = default;
20
21 bool parse();
22
23protected:
24 virtual bool startElement(QStringView namespaceURI, QStringView localName,
25 QStringView qName, const QXmlStreamAttributes &atts);
26 virtual bool endElement(QStringView namespaceURI, QStringView localName,
27 QStringView qName);
28 virtual bool characters(QStringView text);
29 virtual bool endDocument();
30 virtual bool fatalError(qint64 line, qint64 column, const QString &message);
31
32 QXmlStreamReader &reader;
33 bool reportWhitespaceOnlyData;
34};
35
36QT_END_NAMESPACE
37
38#endif // XMLPARSER_H
39

source code of qttools/src/linguist/shared/xmlparser.h