diff options
Diffstat (limited to 'src/corelib/serialization/qxmlstream.h')
-rw-r--r-- | src/corelib/serialization/qxmlstream.h | 117 |
1 files changed, 79 insertions, 38 deletions
diff --git a/src/corelib/serialization/qxmlstream.h b/src/corelib/serialization/qxmlstream.h index fffb9b689c..8a12c6d611 100644 --- a/src/corelib/serialization/qxmlstream.h +++ b/src/corelib/serialization/qxmlstream.h @@ -6,8 +6,9 @@ #include <QtCore/qiodevice.h> -#ifndef QT_NO_XMLSTREAM +#if QT_CONFIG(xmlstream) +#include <QtCore/qcompare.h> #include <QtCore/qlist.h> #include <QtCore/qscopedpointer.h> #include <QtCore/qstring.h> @@ -58,13 +59,23 @@ public: } inline QStringView value() const { return m_value; } inline bool isDefault() const { return m_isDefault; } - inline bool operator==(const QXmlStreamAttribute &other) const { - return (value() == other.value() - && (namespaceUri().isNull() ? (qualifiedName() == other.qualifiedName()) - : (namespaceUri() == other.namespaceUri() && name() == other.name()))); - } +#if QT_CORE_REMOVED_SINCE(6, 8) + inline bool operator==(const QXmlStreamAttribute &other) const + { return comparesEqual(*this, other); } inline bool operator!=(const QXmlStreamAttribute &other) const - { return !operator==(other); } + { return !operator==(other); } +#endif + +private: + friend bool comparesEqual(const QXmlStreamAttribute &lhs, + const QXmlStreamAttribute &rhs) noexcept + { + return (lhs.value() == rhs.value() + && (lhs.namespaceUri().isNull() ? (lhs.qualifiedName() == rhs.qualifiedName()) + : (lhs.namespaceUri() == rhs.namespaceUri() + && lhs.name() == rhs.name()))); + } + Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamAttribute) }; Q_DECLARE_TYPEINFO(QXmlStreamAttribute, Q_RELOCATABLE_TYPE); @@ -75,25 +86,25 @@ class QXmlStreamAttributes : public QList<QXmlStreamAttribute> { public: inline QXmlStreamAttributes() {} +#if QT_CORE_REMOVED_SINCE(6, 6) Q_CORE_EXPORT QStringView value(const QString &namespaceUri, const QString &name) const; Q_CORE_EXPORT QStringView value(const QString &namespaceUri, QLatin1StringView name) const; Q_CORE_EXPORT QStringView value(QLatin1StringView namespaceUri, QLatin1StringView name) const; Q_CORE_EXPORT QStringView value(const QString &qualifiedName) const; Q_CORE_EXPORT QStringView value(QLatin1StringView qualifiedName) const; +#endif + Q_CORE_EXPORT QStringView value(QAnyStringView namespaceUri, QAnyStringView name) const noexcept; + Q_CORE_EXPORT QStringView value(QAnyStringView qualifiedName) const noexcept; + Q_CORE_EXPORT void append(const QString &namespaceUri, const QString &name, const QString &value); Q_CORE_EXPORT void append(const QString &qualifiedName, const QString &value); - inline bool hasAttribute(const QString &qualifiedName) const + bool hasAttribute(QAnyStringView qualifiedName) const { return !value(qualifiedName).isNull(); } - inline bool hasAttribute(QLatin1StringView qualifiedName) const - { - return !value(qualifiedName).isNull(); - } - - inline bool hasAttribute(const QString &namespaceUri, const QString &name) const + bool hasAttribute(QAnyStringView namespaceUri, QAnyStringView name) const { return !value(namespaceUri, name).isNull(); } @@ -111,11 +122,19 @@ public: inline QStringView prefix() const { return m_prefix; } inline QStringView namespaceUri() const { return m_namespaceUri; } - inline bool operator==(const QXmlStreamNamespaceDeclaration &other) const { - return (prefix() == other.prefix() && namespaceUri() == other.namespaceUri()); - } +#if QT_CORE_REMOVED_SINCE(6, 8) + inline bool operator==(const QXmlStreamNamespaceDeclaration &other) const + { return comparesEqual(*this, other); } inline bool operator!=(const QXmlStreamNamespaceDeclaration &other) const - { return !operator==(other); } + { return !operator==(other); } +#endif +private: + friend bool comparesEqual(const QXmlStreamNamespaceDeclaration &lhs, + const QXmlStreamNamespaceDeclaration &rhs) noexcept + { + return (lhs.prefix() == rhs.prefix() && lhs.namespaceUri() == rhs.namespaceUri()); + } + Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamNamespaceDeclaration) }; Q_DECLARE_TYPEINFO(QXmlStreamNamespaceDeclaration, Q_RELOCATABLE_TYPE); @@ -131,12 +150,20 @@ public: inline QStringView name() const { return m_name; } inline QStringView systemId() const { return m_systemId; } inline QStringView publicId() const { return m_publicId; } - inline bool operator==(const QXmlStreamNotationDeclaration &other) const { - return (name() == other.name() && systemId() == other.systemId() - && publicId() == other.publicId()); - } +#if QT_CORE_REMOVED_SINCE(6, 8) + inline bool operator==(const QXmlStreamNotationDeclaration &other) const + { return comparesEqual(*this, other); } inline bool operator!=(const QXmlStreamNotationDeclaration &other) const - { return !operator==(other); } + { return !operator==(other); } +#endif +private: + friend bool comparesEqual(const QXmlStreamNotationDeclaration &lhs, + const QXmlStreamNotationDeclaration &rhs) noexcept + { + return (lhs.name() == rhs.name() && lhs.systemId() == rhs.systemId() + && lhs.publicId() == rhs.publicId()); + } + Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamNotationDeclaration) }; Q_DECLARE_TYPEINFO(QXmlStreamNotationDeclaration, Q_RELOCATABLE_TYPE); @@ -154,15 +181,24 @@ public: inline QStringView systemId() const { return m_systemId; } inline QStringView publicId() const { return m_publicId; } inline QStringView value() const { return m_value; } - inline bool operator==(const QXmlStreamEntityDeclaration &other) const { - return (name() == other.name() - && notationName() == other.notationName() - && systemId() == other.systemId() - && publicId() == other.publicId() - && value() == other.value()); - } +#if QT_CORE_REMOVED_SINCE(6, 8) + inline bool operator==(const QXmlStreamEntityDeclaration &other) const + { return comparesEqual(*this, other); } inline bool operator!=(const QXmlStreamEntityDeclaration &other) const - { return !operator==(other); } + { return !operator==(other); } +#endif + +private: + friend bool comparesEqual(const QXmlStreamEntityDeclaration &lhs, + const QXmlStreamEntityDeclaration &rhs) noexcept + { + return (lhs.name() == rhs.name() + && lhs.notationName() == rhs.notationName() + && lhs.systemId() == rhs.systemId() + && lhs.publicId() == rhs.publicId() + && lhs.value() == rhs.value()); + } + Q_DECLARE_EQUALITY_COMPARABLE(QXmlStreamEntityDeclaration) }; Q_DECLARE_TYPEINFO(QXmlStreamEntityDeclaration, Q_RELOCATABLE_TYPE); @@ -170,14 +206,17 @@ typedef QList<QXmlStreamEntityDeclaration> QXmlStreamEntityDeclarations; class Q_CORE_EXPORT QXmlStreamEntityResolver { + Q_DISABLE_COPY_MOVE(QXmlStreamEntityResolver) public: + QXmlStreamEntityResolver() = default; virtual ~QXmlStreamEntityResolver(); virtual QString resolveEntity(const QString& publicId, const QString& systemId); virtual QString resolveUndeclaredEntity(const QString &name); }; -#ifndef QT_NO_XMLSTREAMREADER -class Q_CORE_EXPORT QXmlStreamReader { +#if QT_CONFIG(xmlstreamreader) +class Q_CORE_EXPORT QXmlStreamReader +{ QDOC_PROPERTY(bool namespaceProcessing READ namespaceProcessing WRITE setNamespaceProcessing) public: enum TokenType { @@ -246,6 +285,7 @@ public: inline bool isProcessingInstruction() const { return tokenType() == ProcessingInstruction; } bool isStandaloneDocument() const; + bool hasStandaloneDeclaration() const; QStringView documentVersion() const; QStringView documentEncoding() const; @@ -313,9 +353,9 @@ private: QScopedPointer<QXmlStreamReaderPrivate> d_ptr; }; -#endif // QT_NO_XMLSTREAMREADER +#endif // feature xmlstreamreader -#ifndef QT_NO_XMLSTREAMWRITER +#if QT_CONFIG(xmlstreamwriter) class QXmlStreamWriterPrivate; @@ -401,7 +441,7 @@ public: void writeStartElement(QAnyStringView qualifiedName); void writeStartElement(QAnyStringView namespaceUri, QAnyStringView name); -#ifndef QT_NO_XMLSTREAMREADER +#if QT_CONFIG(xmlstreamreader) void writeCurrentToken(const QXmlStreamReader &reader); #endif @@ -412,9 +452,10 @@ private: Q_DECLARE_PRIVATE(QXmlStreamWriter) QScopedPointer<QXmlStreamWriterPrivate> d_ptr; }; -#endif // QT_NO_XMLSTREAMWRITER +#endif // feature xmlstreamwriter QT_END_NAMESPACE -#endif // QT_NO_XMLSTREAM +#endif // feature xmlstream + #endif // QXMLSTREAM_H |