diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-06-30 10:16:31 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-08-03 20:14:42 +0200 |
commit | 7de21b268a03607455e288994085982101f5fc65 (patch) | |
tree | e6becb9e79abb1ecadbf02dc8e53dc935c95737e /src/xml | |
parent | 8cc389068be398ad20188170c245ca5de305c92e (diff) |
QDom: use QDomDocument::ParseResult for storing the error info
And use the new struct as a result type for error getters instead of
std::tuple. The line and column numbers, therefore, grow to qsizetype
instead of int.
As a drive-by, make the getters inline.
Change-Id: Iad652063af2c9183cb60f27320c2a800ae28ba36
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/xml')
-rw-r--r-- | src/xml/dom/qdom.cpp | 6 | ||||
-rw-r--r-- | src/xml/dom/qdomhelpers.cpp | 18 | ||||
-rw-r--r-- | src/xml/dom/qdomhelpers_p.h | 11 |
3 files changed, 9 insertions, 26 deletions
diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index f4c49c5e8c..74ea7d1e4e 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -5625,10 +5625,8 @@ QDomDocument::ParseResult QDomDocumentPrivate::setContent(QXmlStreamReader *read QDomParser domParser(this, reader, options); - if (!domParser.parse()) { - const auto info = domParser.errorInfo(); - return { std::get<0>(info), std::get<1>(info), std::get<2>(info) }; - } + if (!domParser.parse()) + return domParser.result(); return {}; } diff --git a/src/xml/dom/qdomhelpers.cpp b/src/xml/dom/qdomhelpers.cpp index f3826608e4..2a4d4c5b3a 100644 --- a/src/xml/dom/qdomhelpers.cpp +++ b/src/xml/dom/qdomhelpers.cpp @@ -24,7 +24,7 @@ using namespace Qt::StringLiterals; QDomBuilder::QDomBuilder(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options) - : errorLine(0), errorColumn(0), doc(d), node(d), reader(r), parseOptions(options) + : doc(d), node(d), reader(r), parseOptions(options) { Q_ASSERT(doc); Q_ASSERT(reader); @@ -166,14 +166,9 @@ bool QDomBuilder::skippedEntity(const QString &name) void QDomBuilder::fatalError(const QString &message) { - errorMsg = message; - errorLine = static_cast<int>(reader->lineNumber()); - errorColumn = static_cast<int>(reader->columnNumber()); -} - -QDomBuilder::ErrorInfo QDomBuilder::error() const -{ - return ErrorInfo(errorMsg, errorLine, errorColumn); + parseResult.errorMessage = message; + parseResult.errorLine = reader->lineNumber(); + parseResult.errorColumn = reader->columnNumber(); } bool QDomBuilder::startEntity(const QString &name) @@ -241,11 +236,6 @@ bool QDomParser::parse() return parseProlog() && parseBody(); } -QDomBuilder::ErrorInfo QDomParser::errorInfo() const -{ - return domBuilder.error(); -} - bool QDomParser::parseProlog() { Q_ASSERT(reader); diff --git a/src/xml/dom/qdomhelpers_p.h b/src/xml/dom/qdomhelpers_p.h index 270cec9343..73177981b5 100644 --- a/src/xml/dom/qdomhelpers_p.h +++ b/src/xml/dom/qdomhelpers_p.h @@ -54,17 +54,12 @@ public: const QString ¬ationName); void fatalError(const QString &message); - - using ErrorInfo = std::tuple<QString, int, int>; - ErrorInfo error() const; - - QString errorMsg; - int errorLine; - int errorColumn; + QDomDocument::ParseResult result() const { return parseResult; } private: QString dtdInternalSubset(const QString &dtd); + QDomDocument::ParseResult parseResult; QDomDocumentPrivate *doc; QDomNodePrivate *node; QXmlStreamReader *reader; @@ -85,7 +80,7 @@ public: QDomParser(QDomDocumentPrivate *d, QXmlStreamReader *r, QDomDocument::ParseOptions options); bool parse(); - QDomBuilder::ErrorInfo errorInfo() const; + QDomDocument::ParseResult result() const { return domBuilder.result(); } private: bool parseProlog(); |