Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
xmlparser.cpp
Go to the documentation of this file.
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#include "xmlparser.h"
5
7
9{
10 while (!reader.atEnd()) {
11 reader.readNext();
12 if (reader.hasError()) {
13 fatalError(reader.lineNumber(), reader.columnNumber(), reader.errorString());
14 return false;
15 }
16
17 switch (reader.tokenType()) {
18 case QXmlStreamReader::StartElement:
19 if (!startElement(reader.namespaceUri(), reader.name(), reader.qualifiedName(),
20 reader.attributes())) {
21 return false;
22 }
23 break;
24 case QXmlStreamReader::EndElement:
25 if (!endElement(reader.namespaceUri(), reader.name(), reader.qualifiedName())) {
26 return false;
27 }
28 break;
29 case QXmlStreamReader::Characters:
30 if (reportWhitespaceOnlyData
31 || (!reader.isWhitespace() && !reader.text().toString().trimmed().isEmpty())) {
32 if (!characters(reader.text()))
33 return false;
34 }
35 break;
36 default:
37 break;
38 }
39 }
40 if (reader.isEndDocument() && !endDocument())
41 return false;
42
43 return true;
44}
45
46bool XmlParser::startElement(QStringView namespaceURI, QStringView localName,
47 QStringView qName, const QXmlStreamAttributes &atts)
48{
49 Q_UNUSED(namespaceURI);
50 Q_UNUSED(localName);
51 Q_UNUSED(qName);
52 Q_UNUSED(atts);
53 return true;
54}
55
56bool XmlParser::endElement(QStringView namespaceURI, QStringView localName,
57 QStringView qName)
58{
59 Q_UNUSED(namespaceURI);
60 Q_UNUSED(localName);
61 Q_UNUSED(qName);
62 return true;
63}
64
65bool XmlParser::characters(QStringView text)
66{
67 Q_UNUSED(text);
68 return true;
69}
70
71bool XmlParser::fatalError(qint64 line, qint64 column, const QString &message)
72{
73 Q_UNUSED(line);
74 Q_UNUSED(column);
75 Q_UNUSED(message);
76 return true;
77}
78
80{
81 return true;
82}
83
84QT_END_NAMESPACE
virtual bool characters(QStringView text)
Definition xmlparser.cpp:65
virtual bool endElement(QStringView namespaceURI, QStringView localName, QStringView qName)
Definition xmlparser.cpp:56
bool parse()
Definition xmlparser.cpp:8
virtual bool endDocument()
Definition xmlparser.cpp:79
virtual bool startElement(QStringView namespaceURI, QStringView localName, QStringView qName, const QXmlStreamAttributes &atts)
Definition xmlparser.cpp:46
virtual bool fatalError(qint64 line, qint64 column, const QString &message)
Definition xmlparser.cpp:71
Combined button and popup list for selecting options.