summaryrefslogtreecommitdiffstats
path: root/src/xml/sax
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-11-07 17:26:55 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2020-01-06 18:13:01 +0100
commit82d02b7b95908dec16e41c5af1c63579729c589b (patch)
tree6f78be54709ea918c63e265c61d236be88fbb1f0 /src/xml/sax
parent844ef184e8021237280a45ead04a3ab39cefa657 (diff)
Deprecate SAX classes in Qt XML
Deprecated the SAX classes and disabled or replaced their uses in tests if applicable. Removed the saxbookmarks example, no point in keeping examples for the deprecated code. [ChangeLog][QtXml] SAX classes are now deprecated. Use QXmlStreamReader, QXmlStreamWriter in QtCore instead. Task-number: QTBUG-76177 Change-Id: Ic171d62fa0527b0f36f94cf09a69586092269957 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/xml/sax')
-rw-r--r--src/xml/sax/qxml.cpp38
-rw-r--r--src/xml/sax/qxml.h70
-rw-r--r--src/xml/sax/qxml_p.h9
3 files changed, 101 insertions, 16 deletions
diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp
index 1993073cce..0033d042d4 100644
--- a/src/xml/sax/qxml.cpp
+++ b/src/xml/sax/qxml.cpp
@@ -51,6 +51,7 @@
#include "qstack.h"
#include <qdebug.h>
+#if QT_DEPRECATED_SINCE(5, 15)
#ifdef Q_CC_BOR // borland 6 finds bogus warnings when building this file in uic3
# pragma warn -8080
@@ -284,6 +285,7 @@ class QXmlDefaultHandlerPrivate
/*!
\class QXmlParseException
+ \obsolete
\reentrant
\brief The QXmlParseException class is used to report errors with
the QXmlErrorHandler interface.
@@ -403,6 +405,7 @@ QString QXmlParseException::systemId() const
/*!
\class QXmlLocator
+ \obsolete
\reentrant
\brief The QXmlLocator class provides the XML handler classes with
information about the parsing position within a file.
@@ -445,6 +448,9 @@ QXmlLocator::~QXmlLocator()
number available.
*/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
class QXmlSimpleReaderLocator : public QXmlLocator
{
public:
@@ -497,6 +503,7 @@ public:
/*!
\class QXmlNamespaceSupport
+ \obsolete
\since 4.4
\reentrant
\brief The QXmlNamespaceSupport class is a helper class for XML
@@ -745,6 +752,7 @@ void QXmlNamespaceSupport::reset()
/*!
\class QXmlAttributes
+ \obsolete
\reentrant
\brief The QXmlAttributes class provides XML attributes.
@@ -1028,6 +1036,7 @@ void QXmlAttributes::append(const QString &qName, const QString &uri, const QStr
/*!
\class QXmlInputSource
+ \obsolete
\reentrant
\brief The QXmlInputSource class provides the input data for the
QXmlReader subclasses.
@@ -1446,6 +1455,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning)
/*!
\class QXmlContentHandler
+ \obsolete
\reentrant
\brief The QXmlContentHandler class provides an interface to
report the logical content of XML data.
@@ -1688,6 +1698,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning)
/*!
\class QXmlErrorHandler
+ \obsolete
\reentrant
\brief The QXmlErrorHandler class provides an interface to report
errors in XML data.
@@ -1763,6 +1774,7 @@ events are reported.
/*!
\class QXmlDTDHandler
+ \obsolete
\reentrant
\brief The QXmlDTDHandler class provides an interface to report
DTD content of XML data.
@@ -1830,6 +1842,7 @@ events are reported.
/*!
\class QXmlEntityResolver
+ \obsolete
\reentrant
\brief The QXmlEntityResolver class provides an interface to
resolve external entities contained in XML data.
@@ -1886,6 +1899,7 @@ events are reported.
/*!
\class QXmlLexicalHandler
+ \obsolete
\reentrant
\brief The QXmlLexicalHandler class provides an interface to
report the lexical content of XML data.
@@ -2037,6 +2051,7 @@ events are reported.
/*!
\class QXmlDeclHandler
+ \obsolete
\reentrant
\brief The QXmlDeclHandler class provides an interface to report declaration
content of XML data.
@@ -2124,6 +2139,7 @@ events are reported.
/*!
\class QXmlDefaultHandler
+ \obsolete
\reentrant
\brief The QXmlDefaultHandler class provides a default implementation of all
the XML handler classes.
@@ -2558,6 +2574,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
/*!
\class QXmlReader
+ \obsolete
\reentrant
\brief The QXmlReader class provides an interface for XML readers (i.e.
parsers).
@@ -2597,6 +2614,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
setDeclHandler(). The parse itself is started with a call to
parse().
+ Note that this class is now deprecated, please use QXmlStreamReader or
+ QDomDocument for reading XML files.
+
\sa QXmlSimpleReader
*/
@@ -2783,6 +2803,7 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
/*!
\class QXmlSimpleReader
+ \obsolete
\nonreentrant
\brief The QXmlSimpleReader class provides an implementation of a
simple XML parser.
@@ -2845,6 +2866,9 @@ void QXmlSimpleReaderPrivate::initIncrementalParsing()
QXmlSimpleReader is not reentrant. If you want to use the class
in threaded code, lock the code using QXmlSimpleReader with a
locking mechanism, such as a QMutex.
+
+ Note that this class is now deprecated, please use QXmlStreamReader or
+ QDomDocument for reading XML files.
*/
static inline bool is_S(QChar ch)
@@ -5255,7 +5279,10 @@ bool QXmlSimpleReaderPrivate::parsePEReference()
} else if (entityRes) {
QMap<QString,QXmlSimpleReaderPrivate::ExternParameterEntity>::Iterator it2;
it2 = externParameterEntities.find(ref());
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource *ret = nullptr;
+QT_WARNING_POP
if (it2 != externParameterEntities.end()) {
if (!entityRes->resolveEntity((*it2).publicId, (*it2).systemId, ret)) {
delete ret;
@@ -7610,7 +7637,10 @@ bool QXmlSimpleReaderPrivate::processReference()
// Included if validating
bool skipIt = true;
if (entityRes) {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
QXmlInputSource *ret = nullptr;
+QT_WARNING_POP
if (!entityRes->resolveEntity((*itExtern).publicId, (*itExtern).systemId, ret)) {
delete ret;
reportParseError(entityRes->errorString());
@@ -7850,6 +7880,8 @@ bool QXmlSimpleReaderPrivate::next_eat_ws()
This private function initializes the reader. \a i is the input source to
read the data from.
*/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i)
{
lineNr = 0;
@@ -7870,6 +7902,7 @@ void QXmlSimpleReaderPrivate::init(const QXmlInputSource *i)
standalone = QXmlSimpleReaderPrivate::Unknown;
error.clear();
}
+QT_WARNING_POP
/*
This private function initializes the XML data related variables. Especially,
@@ -7898,6 +7931,8 @@ bool QXmlSimpleReaderPrivate::entityExist(const QString& e) const
}
}
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
void QXmlSimpleReaderPrivate::reportParseError(const QString& error)
{
this->error = error;
@@ -7913,6 +7948,7 @@ void QXmlSimpleReaderPrivate::reportParseError(const QString& error)
}
}
}
+QT_WARNING_POP
/*
This private function is called when a parsing function encounters an
@@ -8006,3 +8042,5 @@ void QXmlSimpleReaderPrivate::refAddC(QChar ch)
refArray[refArrayPos++] = ch;
}
QT_END_NAMESPACE
+
+#endif // QT_DEPRECATED_SINCE(5, 15)
diff --git a/src/xml/sax/qxml.h b/src/xml/sax/qxml.h
index 9be14bd7a9..e19a398ca7 100644
--- a/src/xml/sax/qxml.h
+++ b/src/xml/sax/qxml.h
@@ -40,6 +40,26 @@
#ifndef QXML_H
#define QXML_H
+#if 0
+// This is needed because of QTBUG-80347
+#pragma qt_class(QXmlNamespaceSupport)
+#pragma qt_class(QXmlAttributes)
+#pragma qt_class(QXmlInputSource)
+#pragma qt_class(QXmlParseException)
+#pragma qt_class(QXmlReader)
+#pragma qt_class(QXmlSimpleReader)
+#pragma qt_class(QXmlLocator)
+#pragma qt_class(QXmlContentHandler)
+#pragma qt_class(QXmlErrorHandler)
+#pragma qt_class(QXmlDTDHandler)
+#pragma qt_class(QXmlEntityResolver)
+#pragma qt_class(QXmlLexicalHandler)
+#pragma qt_class(QXmlDeclHandler)
+#pragma qt_class(QXmlDefaultHandler)
+#endif
+
+#include <QtCore/qglobal.h>
+
#include <QtXml/qtxmlglobal.h>
#include <QtCore/qtextstream.h>
#include <QtCore/qfile.h>
@@ -48,8 +68,12 @@
#include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
+#if QT_DEPRECATED_SINCE(5, 15)
+
QT_BEGIN_NAMESPACE
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
class QXmlNamespaceSupport;
class QXmlAttributes;
@@ -76,12 +100,11 @@ class QXmlParseExceptionPrivate;
class QXmlLocatorPrivate;
class QXmlDefaultHandlerPrivate;
-
//
// SAX Namespace Support
//
-class Q_XML_EXPORT QXmlNamespaceSupport
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlNamespaceSupport
{
public:
QXmlNamespaceSupport();
@@ -112,10 +135,15 @@ private:
// SAX Attributes
//
+// Although deprecated warnings are disabled, the intel icc 18 compiler
+// still complains during the instantiation of the templated qSwap() call below
+// (with the parameter QXmlAttributes::AttributeList) when QXmlAttributes is
+// deprecated. This makes the build fail when warnings are treated as errors.
+// To workaround this, deprecated only the constructor.
class Q_XML_EXPORT QXmlAttributes
{
public:
- QXmlAttributes();
+ QT_DEPRECATED_VERSION(5, 15) QXmlAttributes();
QXmlAttributes(const QXmlAttributes &) = default;
QXmlAttributes(QXmlAttributes &&) noexcept = default;
QXmlAttributes &operator=(const QXmlAttributes &) = default;
@@ -158,6 +186,7 @@ private:
QXmlAttributesPrivate *d;
};
+
Q_DECLARE_TYPEINFO(QXmlAttributes::Attribute, Q_MOVABLE_TYPE);
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QXmlAttributes)
@@ -165,7 +194,7 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QXmlAttributes)
// SAX Input Source
//
-class Q_XML_EXPORT QXmlInputSource
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlInputSource
{
public:
QXmlInputSource();
@@ -194,7 +223,7 @@ private:
// SAX Exception Classes
//
-class Q_XML_EXPORT QXmlParseException
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlParseException
{
public:
explicit QXmlParseException(const QString &name = QString(), int c = -1, int l = -1,
@@ -217,7 +246,7 @@ private:
// XML Reader
//
-class Q_XML_EXPORT QXmlReader
+class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlReader
{
public:
virtual ~QXmlReader() {}
@@ -243,7 +272,8 @@ public:
virtual bool parse(const QXmlInputSource* input) = 0;
};
-class Q_XML_EXPORT QXmlSimpleReader : public QXmlReader
+class QT_DEPRECATED_VERSION_X(5, 15, "Use QXmlStreamReader") Q_XML_EXPORT QXmlSimpleReader
+ : public QXmlReader
{
public:
QXmlSimpleReader();
@@ -288,7 +318,7 @@ private:
// SAX Locator
//
-class Q_XML_EXPORT QXmlLocator
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLocator
{
public:
QXmlLocator();
@@ -304,7 +334,7 @@ public:
// SAX handler classes
//
-class Q_XML_EXPORT QXmlContentHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlContentHandler
{
public:
virtual ~QXmlContentHandler() {}
@@ -322,7 +352,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlErrorHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlErrorHandler
{
public:
virtual ~QXmlErrorHandler() {}
@@ -332,7 +362,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlDTDHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDTDHandler
{
public:
virtual ~QXmlDTDHandler() {}
@@ -341,7 +371,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlEntityResolver
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlEntityResolver
{
public:
virtual ~QXmlEntityResolver() {}
@@ -349,7 +379,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlLexicalHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlLexicalHandler
{
public:
virtual ~QXmlLexicalHandler() {}
@@ -363,7 +393,7 @@ public:
virtual QString errorString() const = 0;
};
-class Q_XML_EXPORT QXmlDeclHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDeclHandler
{
public:
virtual ~QXmlDeclHandler() {}
@@ -374,8 +404,12 @@ public:
// ### Conform to SAX by adding elementDecl
};
-
-class Q_XML_EXPORT QXmlDefaultHandler : public QXmlContentHandler, public QXmlErrorHandler, public QXmlDTDHandler, public QXmlEntityResolver, public QXmlLexicalHandler, public QXmlDeclHandler
+class QT_DEPRECATED_VERSION(5, 15) Q_XML_EXPORT QXmlDefaultHandler : public QXmlContentHandler,
+ public QXmlErrorHandler,
+ public QXmlDTDHandler,
+ public QXmlEntityResolver,
+ public QXmlLexicalHandler,
+ public QXmlDeclHandler
{
public:
QXmlDefaultHandler();
@@ -426,6 +460,10 @@ private:
inline int QXmlAttributes::count() const
{ return length(); }
+QT_WARNING_POP
+
QT_END_NAMESPACE
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif // QXML_H
diff --git a/src/xml/sax/qxml_p.h b/src/xml/sax/qxml_p.h
index eb6135db04..1b614dd886 100644
--- a/src/xml/sax/qxml_p.h
+++ b/src/xml/sax/qxml_p.h
@@ -46,6 +46,8 @@
#include <stack>
+#if QT_DEPRECATED_SINCE(5, 15)
+
QT_BEGIN_NAMESPACE
//
@@ -59,6 +61,9 @@ QT_BEGIN_NAMESPACE
// We mean it.
//
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
class QXmlSimpleReaderPrivate
{
public:
@@ -313,6 +318,10 @@ Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::XmlRef, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternParameterEntity, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QXmlSimpleReaderPrivate::ExternEntity, Q_MOVABLE_TYPE);
+QT_WARNING_POP
+
QT_END_NAMESPACE
+#endif // QT_DEPRECATED_SINCE(5, 15)
+
#endif // QXML_P_H