diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-11-18 13:33:29 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-11-26 22:42:40 +0100 |
commit | 722df970e82b35e8da9e14a2efaacf733315065c (patch) | |
tree | 07895cedce4271b768591a78a4f96fa4c2f170b4 /src/xml | |
parent | 6f6aa316f1145b3e49abe4d2810d83220c66298a (diff) |
Remove leftovers for supporting SAX-based implenentation of QDomDocument
QXmlDocumentLocator was introduced, so that QDomBuilder can work with
both QXmlStreamReader and QXmlInputSource. It had two subclasses -
QDomDocumentLocator and QSAXDocumentLocator, to allow getting line and
column numbers while parsing, depending on the implementation.
QSAXDocumentLocator was removed when removing SAX-based implementation
(79e0374143ab385cb12a17443e91c8eb9d2f3a4b), and now it doesn't make
sense to keep QXmlDocumentLocator/QDomDocumentLocator, we can get line
and column numbers form QXmlStreamReader directly.
Change-Id: I75f4a776472ee31ddc3685a999f356be9bf47ac5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/xml')
-rw-r--r-- | src/xml/dom/qdom.h | 3 | ||||
-rw-r--r-- | src/xml/dom/qdomhelpers.cpp | 40 | ||||
-rw-r--r-- | src/xml/dom/qdomhelpers_p.h | 37 |
3 files changed, 14 insertions, 66 deletions
diff --git a/src/xml/dom/qdom.h b/src/xml/dom/qdom.h index 779e05805c..cff4883ad3 100644 --- a/src/xml/dom/qdom.h +++ b/src/xml/dom/qdom.h @@ -51,9 +51,6 @@ QT_BEGIN_NAMESPACE class QIODevice; class QTextStream; -class QXmlInputSource; -class QXmlReader; - class QDomDocumentPrivate; class QDomDocumentTypePrivate; class QDomDocumentFragmentPrivate; diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp index 98ba0da845..48dd0776f3 100644 --- a/src/xml/dom/qdomhelpers.cpp +++ b/src/xml/dom/qdomhelpers.cpp @@ -51,36 +51,20 @@ QT_BEGIN_NAMESPACE /************************************************************** * - * QXmlDocumentLocators - * - **************************************************************/ - -int QDomDocumentLocator::column() const -{ - Q_ASSERT(reader); - return static_cast<int>(reader->columnNumber()); -} - -int QDomDocumentLocator::line() const -{ - Q_ASSERT(reader); - return static_cast<int>(reader->lineNumber()); -} - -/************************************************************** - * * QDomBuilder * **************************************************************/ -QDomBuilder::QDomBuilder(QDomDocumentPrivate *d, QXmlDocumentLocator *l, bool namespaceProcessing) +QDomBuilder::QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing) : errorLine(0), errorColumn(0), doc(d), node(d), - locator(l), + reader(r), nsProcessing(namespaceProcessing) { + Q_ASSERT(doc); + Q_ASSERT(reader); } QDomBuilder::~QDomBuilder() {} @@ -109,7 +93,7 @@ bool QDomBuilder::startElement(const QString &nsURI, const QString &qName, if (!n) return false; - n->setLocation(locator->line(), locator->column()); + n->setLocation(int(reader->lineNumber()), int(reader->columnNumber())); node->appendChild(n); node = n; @@ -159,7 +143,7 @@ bool QDomBuilder::characters(const QString &characters, bool cdata) } else { n.reset(doc->createTextNode(characters)); } - n->setLocation(locator->line(), locator->column()); + n->setLocation(int(reader->lineNumber()), int(reader->columnNumber())); node->appendChild(n.data()); n.take(); @@ -171,7 +155,7 @@ bool QDomBuilder::processingInstruction(const QString &target, const QString &da QDomNodePrivate *n; n = doc->createProcessingInstruction(target, data); if (n) { - n->setLocation(locator->line(), locator->column()); + n->setLocation(int(reader->lineNumber()), int(reader->columnNumber())); node->appendChild(n); return true; } else @@ -181,7 +165,7 @@ bool QDomBuilder::processingInstruction(const QString &target, const QString &da bool QDomBuilder::skippedEntity(const QString &name) { QDomNodePrivate *n = doc->createEntityReference(name); - n->setLocation(locator->line(), locator->column()); + n->setLocation(int(reader->lineNumber()), int(reader->columnNumber())); node->appendChild(n); return true; } @@ -189,8 +173,8 @@ bool QDomBuilder::skippedEntity(const QString &name) void QDomBuilder::fatalError(const QString &message) { errorMsg = message; - errorLine = static_cast<int>(locator->line()); - errorColumn = static_cast<int>(locator->column()); + errorLine = static_cast<int>(reader->lineNumber()); + errorColumn = static_cast<int>(reader->columnNumber()); } QDomBuilder::ErrorInfo QDomBuilder::error() const @@ -214,7 +198,7 @@ bool QDomBuilder::comment(const QString &characters) { QDomNodePrivate *n; n = doc->createComment(characters); - n->setLocation(locator->line(), locator->column()); + n->setLocation(int(reader->lineNumber()), int(reader->columnNumber())); node->appendChild(n); return true; } @@ -253,7 +237,7 @@ bool QDomBuilder::notationDecl(const QString &name, const QString &publicId, **************************************************************/ QDomParser::QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing) - : reader(r), locator(r), domBuilder(d, &locator, namespaceProcessing) + : reader(r), domBuilder(d, r, namespaceProcessing) { } diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h index f7264daf4b..22e23e7a21 100644 --- a/src/xml/dom/qdomhelpers_p.h +++ b/src/xml/dom/qdomhelpers_p.h @@ -62,38 +62,6 @@ class QXmlStreamAttributes; /************************************************************** * - * QXmlDocumentLocators - * - **************************************************************/ - -/* TODO: QXmlDocumentLocator can be removed when the SAX-based - * implementation is removed. Right now it is needed for QDomBuilder - * to work with both QXmlStreamReader and QXmlInputSource (SAX) - * based implementations. - */ -class QXmlDocumentLocator -{ -public: - virtual ~QXmlDocumentLocator() = default; - virtual int column() const = 0; - virtual int line() const = 0; -}; - -class QDomDocumentLocator : public QXmlDocumentLocator -{ -public: - QDomDocumentLocator(QXmlStreamReader *r) : reader(r) {} - ~QDomDocumentLocator() override = default; - - int column() const override; - int line() const override; - -private: - QXmlStreamReader *reader; -}; - -/************************************************************** - * * QDomBuilder * **************************************************************/ @@ -101,7 +69,7 @@ private: class QDomBuilder { public: - QDomBuilder(QDomDocumentPrivate *d, QXmlDocumentLocator *l, bool namespaceProcessing); + QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, bool namespaceProcessing); ~QDomBuilder(); bool endDocument(); @@ -131,7 +99,7 @@ public: private: QDomDocumentPrivate *doc; QDomNodePrivate *node; - QXmlDocumentLocator *locator; + QXmlStreamReader *reader; QString entityName; bool nsProcessing; }; @@ -157,7 +125,6 @@ private: bool parseMarkupDecl(); QXmlStreamReader *reader; - QDomDocumentLocator locator; QDomBuilder domBuilder; }; |