mirror of https://github.com/qt/qtbase.git
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
(79e0374143
), 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>
This commit is contained in:
parent
6f6aa316f1
commit
722df970e8
|
@ -51,9 +51,6 @@ QT_BEGIN_NAMESPACE
|
|||
class QIODevice;
|
||||
class QTextStream;
|
||||
|
||||
class QXmlInputSource;
|
||||
class QXmlReader;
|
||||
|
||||
class QDomDocumentPrivate;
|
||||
class QDomDocumentTypePrivate;
|
||||
class QDomDocumentFragmentPrivate;
|
||||
|
|
|
@ -49,38 +49,22 @@
|
|||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -60,38 +60,6 @@ class QDomNodePrivate;
|
|||
class QXmlStreamReader;
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue