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