1 | // Copyright (C) 2021 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | #ifndef QDOMHELPERS_P_H |
4 | #define QDOMHELPERS_P_H |
5 | |
6 | #include <qcoreapplication.h> |
7 | #include <qdom.h> |
8 | #include <private/qglobal_p.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | // |
13 | // W A R N I N G |
14 | // ------------- |
15 | // |
16 | // This file is not part of the Qt API. It exists for the convenience of |
17 | // qxml.cpp and qdom.cpp. This header file may change from version to version without |
18 | // notice, or even be removed. |
19 | // |
20 | // We mean it. |
21 | // |
22 | |
23 | class QDomDocumentPrivate; |
24 | class QDomNodePrivate; |
25 | class QXmlStreamReader; |
26 | class QXmlStreamAttributes; |
27 | |
28 | /************************************************************** |
29 | * |
30 | * QDomBuilder |
31 | * |
32 | **************************************************************/ |
33 | |
34 | class QDomBuilder |
35 | { |
36 | public: |
37 | QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options); |
38 | ~QDomBuilder(); |
39 | |
40 | bool endDocument(); |
41 | bool startElement(const QString &nsURI, const QString &qName, const QXmlStreamAttributes &atts); |
42 | bool endElement(); |
43 | bool characters(const QString &characters, bool cdata = false); |
44 | bool processingInstruction(const QString &target, const QString &data); |
45 | bool skippedEntity(const QString &name); |
46 | bool startEntity(const QString &name); |
47 | bool endEntity(); |
48 | bool startDTD(const QString &name, const QString &publicId, const QString &systemId); |
49 | bool parseDTD(const QString &dtd); |
50 | bool (const QString &characters); |
51 | bool externalEntityDecl(const QString &name, const QString &publicId, const QString &systemId); |
52 | bool notationDecl(const QString &name, const QString &publicId, const QString &systemId); |
53 | bool unparsedEntityDecl(const QString &name, const QString &publicId, const QString &systemId, |
54 | const QString ¬ationName); |
55 | |
56 | void fatalError(const QString &message); |
57 | QDomDocument::ParseResult result() const { return parseResult; } |
58 | |
59 | bool preserveSpacingOnlyNodes() const |
60 | { return parseOptions & QDomDocument::ParseOption::PreserveSpacingOnlyNodes; } |
61 | |
62 | private: |
63 | QString dtdInternalSubset(const QString &dtd); |
64 | |
65 | QDomDocument::ParseResult parseResult; |
66 | QDomDocumentPrivate *doc; |
67 | QDomNodePrivate *node; |
68 | QXmlStreamReader *reader; |
69 | QString entityName; |
70 | QDomDocument::ParseOptions parseOptions; |
71 | }; |
72 | |
73 | /************************************************************** |
74 | * |
75 | * QDomParser |
76 | * |
77 | **************************************************************/ |
78 | |
79 | class QDomParser |
80 | { |
81 | Q_DECLARE_TR_FUNCTIONS(QDomParser) |
82 | public: |
83 | QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options); |
84 | |
85 | bool parse(); |
86 | QDomDocument::ParseResult result() const { return domBuilder.result(); } |
87 | |
88 | private: |
89 | bool parseProlog(); |
90 | bool parseBody(); |
91 | bool parseMarkupDecl(); |
92 | |
93 | QXmlStreamReader *reader; |
94 | QDomBuilder domBuilder; |
95 | }; |
96 | |
97 | QT_END_NAMESPACE |
98 | |
99 | #endif // QDOMHELPERS_P_H |
100 | |