Port the QXmlStream API from QStringRef to QStringView
This gives some source incompatibilities, most of them can be handled by using auto instead of QStringRef explicitly. [ChangeLog][Important API changes] QXmlStream now uses QStringView insteead of QStringRef in it's API. Using auto forvariables returning a QStringRef in Qt 5 should lead to code that can be used against both Qt versions. Fixes: QTBUG-84317 Change-Id: I6df3a9507276f5d16d044a6bdbe0e4810cf99440 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
This commit is contained in:
parent
a2cec17407
commit
a8028a02df
@ -195,7 +195,7 @@ static QVariant mapFromXml(QXmlStreamReader &xml, Converter::Options options)
|
||||
|
||||
static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options)
|
||||
{
|
||||
QStringRef name = xml.name();
|
||||
QStringView name = xml.name();
|
||||
if (name == QLatin1String("list"))
|
||||
return listFromXml(xml, options);
|
||||
if (name == QLatin1String("map"))
|
||||
@ -207,7 +207,7 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
|
||||
}
|
||||
|
||||
QXmlStreamAttributes attrs = xml.attributes();
|
||||
QStringRef type = attrs.value(QLatin1String("type"));
|
||||
QStringView type = attrs.value(QLatin1String("type"));
|
||||
|
||||
forever {
|
||||
xml.readNext();
|
||||
@ -222,7 +222,7 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
QStringRef text = xml.text();
|
||||
QStringView text = xml.text();
|
||||
if (!xml.isCDATA())
|
||||
text = text.trimmed();
|
||||
|
||||
@ -247,7 +247,7 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
|
||||
}
|
||||
} else if (type == QLatin1String("bytes")) {
|
||||
QByteArray data = text.toLatin1();
|
||||
QStringRef encoding = attrs.value("encoding");
|
||||
QStringView encoding = attrs.value("encoding");
|
||||
if (encoding == QLatin1String("base64url")) {
|
||||
result = QByteArray::fromBase64(data, QByteArray::Base64UrlEncoding);
|
||||
} else if (encoding == QLatin1String("hex")) {
|
||||
|
@ -265,20 +265,20 @@ private:
|
||||
xml.readNext();
|
||||
|
||||
if (xml.tokenType() == QXmlStreamReader::StartElement) {
|
||||
QStringRef className = xml.attributes().value("class");
|
||||
inFlightName |= xml.name() == "h1";
|
||||
inFlightStatus |= className == "FlightDetailHeaderStatus";
|
||||
inFlightMap |= className == "flightMap";
|
||||
if (xml.name() == "td" && !className.isEmpty()) {
|
||||
if (className.contains("fieldTitle")) {
|
||||
auto className = xml.attributes().value("class");
|
||||
inFlightName |= xml.name() == u"h1";
|
||||
inFlightStatus |= className == u"FlightDetailHeaderStatus";
|
||||
inFlightMap |= className == u"flightMap";
|
||||
if (xml.name() == u"td" && !className.isEmpty()) {
|
||||
if (className.contains(u"fieldTitle")) {
|
||||
inFieldName = true;
|
||||
fieldNames += QString();
|
||||
fieldValues += QString();
|
||||
}
|
||||
if (className.contains("fieldValue"))
|
||||
if (className.contains(u"fieldValue"))
|
||||
inFieldValue = true;
|
||||
}
|
||||
if (xml.name() == "img" && inFlightMap) {
|
||||
if (xml.name() == u"img" && inFlightMap) {
|
||||
const QByteArray encoded
|
||||
= ("http://mobile.flightview.com/" % xml.attributes().value("src")).toLatin1();
|
||||
QUrl url = QUrl::fromPercentEncoding(encoded);
|
||||
@ -287,11 +287,11 @@ private:
|
||||
}
|
||||
|
||||
if (xml.tokenType() == QXmlStreamReader::EndElement) {
|
||||
inFlightName &= xml.name() != "h1";
|
||||
inFlightStatus &= xml.name() != "div";
|
||||
inFlightMap &= xml.name() != "div";
|
||||
inFieldName &= xml.name() != "td";
|
||||
inFieldValue &= xml.name() != "td";
|
||||
inFlightName &= xml.name() != u"h1";
|
||||
inFlightStatus &= xml.name() != u"div";
|
||||
inFlightMap &= xml.name() != u"div";
|
||||
inFieldName &= xml.name() != u"td";
|
||||
inFieldValue &= xml.name() != u"td";
|
||||
}
|
||||
|
||||
if (xml.tokenType() == QXmlStreamReader::Characters) {
|
||||
|
@ -217,8 +217,8 @@ void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply)
|
||||
while (!xml.atEnd()) {
|
||||
xml.readNext();
|
||||
if (xml.tokenType() == QXmlStreamReader::StartElement)
|
||||
if (xml.name() == "suggestion") {
|
||||
QStringRef str = xml.attributes().value("data");
|
||||
if (xml.name() == u"suggestion") {
|
||||
auto str = xml.attributes().value("data");
|
||||
choices << str.toString();
|
||||
}
|
||||
}
|
||||
|
@ -103,21 +103,21 @@ GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode, QOb
|
||||
while (!reader.atEnd()) {
|
||||
reader.readNext();
|
||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||
if (reader.name() == "submarine") {
|
||||
if (reader.name() == u"submarine") {
|
||||
SubmarineDescription desc;
|
||||
desc.name = reader.attributes().value("name").toString();
|
||||
desc.points = reader.attributes().value("points").toInt();
|
||||
desc.type = reader.attributes().value("type").toInt();
|
||||
submarinesData.append(desc);
|
||||
} else if (reader.name() == "level") {
|
||||
} else if (reader.name() == u"level") {
|
||||
currentLevel.id = reader.attributes().value("id").toInt();
|
||||
currentLevel.name = reader.attributes().value("name").toString();
|
||||
} else if (reader.name() == "subinstance") {
|
||||
} else if (reader.name() == u"subinstance") {
|
||||
currentLevel.submarines.append(qMakePair(reader.attributes().value("type").toInt(),
|
||||
reader.attributes().value("nb").toInt()));
|
||||
}
|
||||
} else if (reader.tokenType() == QXmlStreamReader::EndElement) {
|
||||
if (reader.name() == "level") {
|
||||
if (reader.name() == u"level") {
|
||||
levelsData.insert(currentLevel.id, currentLevel);
|
||||
currentLevel.submarines.clear();
|
||||
}
|
||||
|
@ -214,11 +214,11 @@ void RSSListing::parseXml()
|
||||
while (!xml.atEnd()) {
|
||||
xml.readNext();
|
||||
if (xml.isStartElement()) {
|
||||
if (xml.name() == "item")
|
||||
if (xml.name() == u"item")
|
||||
linkString = xml.attributes().value("rss:about").toString();
|
||||
currentTag = xml.name().toString();
|
||||
} else if (xml.isEndElement()) {
|
||||
if (xml.name() == "item") {
|
||||
if (xml.name() == u"item") {
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem;
|
||||
item->setText(0, titleString);
|
||||
|
@ -517,14 +517,14 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data)
|
||||
if (xml.name() != QLatin1String("mime-type")) {
|
||||
continue;
|
||||
}
|
||||
const QStringRef name = xml.attributes().value(QLatin1String("type"));
|
||||
const auto name = xml.attributes().value(QLatin1String("type"));
|
||||
if (name.isEmpty())
|
||||
continue;
|
||||
if (name.compare(data.name, Qt::CaseInsensitive))
|
||||
qWarning() << "Got name" << name << "in file" << file << "expected" << data.name;
|
||||
|
||||
while (xml.readNextStartElement()) {
|
||||
const QStringRef tag = xml.name();
|
||||
const auto tag = xml.name();
|
||||
if (tag == QLatin1String("comment")) {
|
||||
QString lang = xml.attributes().value(QLatin1String("xml:lang")).toString();
|
||||
const QString text = xml.readElementText();
|
||||
|
@ -107,7 +107,7 @@ static const char matchMaskAttributeC[] = "mask";
|
||||
Overwrite to process the sequence of parsed data
|
||||
*/
|
||||
|
||||
QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState currentState, const QStringRef &startElement)
|
||||
QMimeTypeParserBase::ParseState QMimeTypeParserBase::nextState(ParseState currentState, QStringView startElement)
|
||||
{
|
||||
switch (currentState) {
|
||||
case ParseBeginning:
|
||||
@ -174,7 +174,7 @@ struct CreateMagicMatchRuleResult {
|
||||
QString errorMessage; // must be first
|
||||
QMimeMagicRule rule;
|
||||
|
||||
CreateMagicMatchRuleResult(const QStringRef &type, const QStringRef &value, const QStringRef &offsets, const QStringRef &mask)
|
||||
CreateMagicMatchRuleResult(QStringView type, QStringView value, QStringView offsets, QStringView mask)
|
||||
: errorMessage(), rule(type.toString(), value.toUtf8(), offsets.toString(), mask.toLatin1(), &errorMessage)
|
||||
{
|
||||
|
||||
@ -183,10 +183,10 @@ struct CreateMagicMatchRuleResult {
|
||||
|
||||
static CreateMagicMatchRuleResult createMagicMatchRule(const QXmlStreamAttributes &atts)
|
||||
{
|
||||
const QStringRef type = atts.value(QLatin1String(matchTypeAttributeC));
|
||||
const QStringRef value = atts.value(QLatin1String(matchValueAttributeC));
|
||||
const QStringRef offsets = atts.value(QLatin1String(matchOffsetAttributeC));
|
||||
const QStringRef mask = atts.value(QLatin1String(matchMaskAttributeC));
|
||||
const auto type = atts.value(QLatin1String(matchTypeAttributeC));
|
||||
const auto value = atts.value(QLatin1String(matchValueAttributeC));
|
||||
const auto offsets = atts.value(QLatin1String(matchOffsetAttributeC));
|
||||
const auto mask = atts.value(QLatin1String(matchMaskAttributeC));
|
||||
return CreateMagicMatchRuleResult(type, value, offsets, mask);
|
||||
}
|
||||
#endif
|
||||
@ -265,7 +265,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
break;
|
||||
case ParseMagic: {
|
||||
priority = 50;
|
||||
const QStringRef priorityS = atts.value(QLatin1String(priorityAttributeC));
|
||||
const auto priorityS = atts.value(QLatin1String(priorityAttributeC));
|
||||
if (!priorityS.isEmpty()) {
|
||||
if (!parseNumber(priorityS, &priority, errorMessage))
|
||||
return false;
|
||||
@ -301,7 +301,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
// continue switch QXmlStreamReader::Token...
|
||||
case QXmlStreamReader::EndElement: // Finished element
|
||||
{
|
||||
const QStringRef elementName = reader.name();
|
||||
const auto elementName = reader.name();
|
||||
if (elementName == QLatin1String(mimeTypeTagC)) {
|
||||
if (!process(QMimeType(data), errorMessage))
|
||||
return false;
|
||||
|
@ -98,7 +98,7 @@ private:
|
||||
ParseError
|
||||
};
|
||||
|
||||
static ParseState nextState(ParseState currentState, const QStringRef &startElement);
|
||||
static ParseState nextState(ParseState currentState, QStringView startElement);
|
||||
};
|
||||
|
||||
|
||||
|
@ -384,13 +384,9 @@ QXmlStreamEntityResolver *QXmlStreamReader::entityResolver() const
|
||||
token at the time it is reported. In addition, QXmlStreamReader
|
||||
avoids the many small string allocations that it normally takes to
|
||||
map an XML document to a convenient and Qt-ish API. It does this by
|
||||
reporting all string data as QStringRef rather than real QString
|
||||
objects. QStringRef is a thin wrapper around QString substrings that
|
||||
provides a subset of the QString API without the memory allocation
|
||||
and reference-counting overhead. Calling
|
||||
\l{QStringRef::toString()}{toString()} on any of those objects
|
||||
returns an equivalent real QString object.
|
||||
|
||||
reporting all string data as QStringView rather than real QString
|
||||
objects. Calling \l{QStringView::toString()}{toString()} on any of
|
||||
those objects returns an equivalent real QString object.
|
||||
*/
|
||||
|
||||
|
||||
@ -1928,7 +1924,7 @@ qint64 QXmlStreamReader::characterOffset() const
|
||||
/*! Returns the text of \l Characters, \l Comment, \l DTD, or
|
||||
EntityReference.
|
||||
*/
|
||||
QStringRef QXmlStreamReader::text() const
|
||||
QStringView QXmlStreamReader::text() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
return d->text;
|
||||
@ -1971,12 +1967,12 @@ QXmlStreamEntityDeclarations QXmlStreamReader::entityDeclarations() const
|
||||
name. Otherwise an empty string is returned.
|
||||
|
||||
*/
|
||||
QStringRef QXmlStreamReader::dtdName() const
|
||||
QStringView QXmlStreamReader::dtdName() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
if (d->type == QXmlStreamReader::DTD)
|
||||
return d->dtdName;
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1986,12 +1982,12 @@ QStringRef QXmlStreamReader::dtdName() const
|
||||
public identifier. Otherwise an empty string is returned.
|
||||
|
||||
*/
|
||||
QStringRef QXmlStreamReader::dtdPublicId() const
|
||||
QStringView QXmlStreamReader::dtdPublicId() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
if (d->type == QXmlStreamReader::DTD)
|
||||
return d->dtdPublicId;
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2001,12 +1997,12 @@ QStringRef QXmlStreamReader::dtdPublicId() const
|
||||
system identifier. Otherwise an empty string is returned.
|
||||
|
||||
*/
|
||||
QStringRef QXmlStreamReader::dtdSystemId() const
|
||||
QStringView QXmlStreamReader::dtdSystemId() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
if (d->type == QXmlStreamReader::DTD)
|
||||
return d->dtdSystemId;
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2187,7 +2183,7 @@ QXmlStreamReader::Error QXmlStreamReader::error() const
|
||||
/*!
|
||||
Returns the target of a ProcessingInstruction.
|
||||
*/
|
||||
QStringRef QXmlStreamReader::processingInstructionTarget() const
|
||||
QStringView QXmlStreamReader::processingInstructionTarget() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
return d->processingInstructionTarget;
|
||||
@ -2196,7 +2192,7 @@ QStringRef QXmlStreamReader::processingInstructionTarget() const
|
||||
/*!
|
||||
Returns the data of a ProcessingInstruction.
|
||||
*/
|
||||
QStringRef QXmlStreamReader::processingInstructionData() const
|
||||
QStringView QXmlStreamReader::processingInstructionData() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
return d->processingInstructionData;
|
||||
@ -2209,7 +2205,7 @@ QStringRef QXmlStreamReader::processingInstructionData() const
|
||||
|
||||
\sa namespaceUri(), qualifiedName()
|
||||
*/
|
||||
QStringRef QXmlStreamReader::name() const
|
||||
QStringView QXmlStreamReader::name() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
return d->name;
|
||||
@ -2220,7 +2216,7 @@ QStringRef QXmlStreamReader::name() const
|
||||
|
||||
\sa name(), qualifiedName()
|
||||
*/
|
||||
QStringRef QXmlStreamReader::namespaceUri() const
|
||||
QStringView QXmlStreamReader::namespaceUri() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
return d->namespaceUri;
|
||||
@ -2238,7 +2234,7 @@ QStringRef QXmlStreamReader::namespaceUri() const
|
||||
|
||||
\sa name(), prefix(), namespaceUri()
|
||||
*/
|
||||
QStringRef QXmlStreamReader::qualifiedName() const
|
||||
QStringView QXmlStreamReader::qualifiedName() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
return d->qualifiedName;
|
||||
@ -2253,7 +2249,7 @@ QStringRef QXmlStreamReader::qualifiedName() const
|
||||
|
||||
\sa name(), qualifiedName()
|
||||
*/
|
||||
QStringRef QXmlStreamReader::prefix() const
|
||||
QStringView QXmlStreamReader::prefix() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
return d->prefix;
|
||||
@ -2317,15 +2313,15 @@ QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QSt
|
||||
m_value = QXmlStreamStringRef(QStringRef(&value));
|
||||
}
|
||||
|
||||
/*! \fn QStringRef QXmlStreamAttribute::namespaceUri() const
|
||||
/*! \fn QStringView QXmlStreamAttribute::namespaceUri() const
|
||||
|
||||
Returns the attribute's resolved namespaceUri, or an empty string
|
||||
reference if the attribute does not have a defined namespace.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamAttribute::name() const
|
||||
/*! \fn QStringView QXmlStreamAttribute::name() const
|
||||
Returns the attribute's local name.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamAttribute::qualifiedName() const
|
||||
/*! \fn QStringView QXmlStreamAttribute::qualifiedName() const
|
||||
Returns the attribute's qualified name.
|
||||
|
||||
A qualified name is the raw name of an attribute in the XML
|
||||
@ -2337,7 +2333,7 @@ QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QSt
|
||||
the attribute's local name().
|
||||
*/
|
||||
/*!
|
||||
\fn QStringRef QXmlStreamAttribute::prefix() const
|
||||
\fn QStringView QXmlStreamAttribute::prefix() const
|
||||
\since 4.4
|
||||
Returns the attribute's namespace prefix.
|
||||
|
||||
@ -2345,7 +2341,7 @@ QXmlStreamAttribute::QXmlStreamAttribute(const QString &qualifiedName, const QSt
|
||||
|
||||
*/
|
||||
|
||||
/*! \fn QStringRef QXmlStreamAttribute::value() const
|
||||
/*! \fn QStringView QXmlStreamAttribute::value() const
|
||||
Returns the attribute's value.
|
||||
*/
|
||||
|
||||
@ -2421,15 +2417,15 @@ QXmlStreamNotationDeclaration::QXmlStreamNotationDeclaration()
|
||||
{
|
||||
}
|
||||
|
||||
/*! \fn QStringRef QXmlStreamNotationDeclaration::name() const
|
||||
/*! \fn QStringView QXmlStreamNotationDeclaration::name() const
|
||||
|
||||
Returns the notation name.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamNotationDeclaration::systemId() const
|
||||
/*! \fn QStringView QXmlStreamNotationDeclaration::systemId() const
|
||||
|
||||
Returns the system identifier.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamNotationDeclaration::publicId() const
|
||||
/*! \fn QStringView QXmlStreamNotationDeclaration::publicId() const
|
||||
|
||||
Returns the public identifier.
|
||||
*/
|
||||
@ -2492,11 +2488,11 @@ QXmlStreamNamespaceDeclaration::QXmlStreamNamespaceDeclaration(const QString &pr
|
||||
m_namespaceUri = namespaceUri;
|
||||
}
|
||||
|
||||
/*! \fn QStringRef QXmlStreamNamespaceDeclaration::prefix() const
|
||||
/*! \fn QStringView QXmlStreamNamespaceDeclaration::prefix() const
|
||||
|
||||
Returns the prefix.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamNamespaceDeclaration::namespaceUri() const
|
||||
/*! \fn QStringView QXmlStreamNamespaceDeclaration::namespaceUri() const
|
||||
|
||||
Returns the namespaceUri.
|
||||
*/
|
||||
@ -2545,23 +2541,23 @@ QXmlStreamEntityDeclaration::QXmlStreamEntityDeclaration()
|
||||
This function is very fast and never fails.
|
||||
*/
|
||||
|
||||
/*! \fn QStringRef QXmlStreamEntityDeclaration::name() const
|
||||
/*! \fn QStringView QXmlStreamEntityDeclaration::name() const
|
||||
|
||||
Returns the entity name.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamEntityDeclaration::notationName() const
|
||||
/*! \fn QStringView QXmlStreamEntityDeclaration::notationName() const
|
||||
|
||||
Returns the notation name.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamEntityDeclaration::systemId() const
|
||||
/*! \fn QStringView QXmlStreamEntityDeclaration::systemId() const
|
||||
|
||||
Returns the system identifier.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamEntityDeclaration::publicId() const
|
||||
/*! \fn QStringView QXmlStreamEntityDeclaration::publicId() const
|
||||
|
||||
Returns the public identifier.
|
||||
*/
|
||||
/*! \fn QStringRef QXmlStreamEntityDeclaration::value() const
|
||||
/*! \fn QStringView QXmlStreamEntityDeclaration::value() const
|
||||
|
||||
Returns the entity's value.
|
||||
*/
|
||||
@ -2581,13 +2577,13 @@ Returns the entity's value.
|
||||
described with \a namespaceUri, or an empty string reference if the
|
||||
attribute is not defined. The \a namespaceUri can be empty.
|
||||
*/
|
||||
QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QString &name) const
|
||||
QStringView QXmlStreamAttributes::value(const QString &namespaceUri, const QString &name) const
|
||||
{
|
||||
for (const QXmlStreamAttribute &attribute : *this) {
|
||||
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
||||
return attribute.value();
|
||||
}
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!\overload
|
||||
@ -2595,13 +2591,13 @@ QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QStrin
|
||||
described with \a namespaceUri, or an empty string reference if the
|
||||
attribute is not defined. The \a namespaceUri can be empty.
|
||||
*/
|
||||
QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const
|
||||
QStringView QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const
|
||||
{
|
||||
for (const QXmlStreamAttribute &attribute : *this) {
|
||||
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
||||
return attribute.value();
|
||||
}
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!\overload
|
||||
@ -2609,13 +2605,13 @@ QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1Strin
|
||||
described with \a namespaceUri, or an empty string reference if the
|
||||
attribute is not defined. The \a namespaceUri can be empty.
|
||||
*/
|
||||
QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const
|
||||
QStringView QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const
|
||||
{
|
||||
for (const QXmlStreamAttribute &attribute : *this) {
|
||||
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
||||
return attribute.value();
|
||||
}
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!\overload
|
||||
@ -2630,13 +2626,13 @@ QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String
|
||||
use qualified names, but a resolved namespaceUri and the attribute's
|
||||
local name.
|
||||
*/
|
||||
QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const
|
||||
QStringView QXmlStreamAttributes::value(const QString &qualifiedName) const
|
||||
{
|
||||
for (const QXmlStreamAttribute &attribute : *this) {
|
||||
if (attribute.qualifiedName() == qualifiedName)
|
||||
return attribute.value();
|
||||
}
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!\overload
|
||||
@ -2651,13 +2647,13 @@ QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const
|
||||
use qualified names, but a resolved namespaceUri and the attribute's
|
||||
local name.
|
||||
*/
|
||||
QStringRef QXmlStreamAttributes::value(QLatin1String qualifiedName) const
|
||||
QStringView QXmlStreamAttributes::value(QLatin1String qualifiedName) const
|
||||
{
|
||||
for (const QXmlStreamAttribute &attribute : *this) {
|
||||
if (attribute.qualifiedName() == qualifiedName)
|
||||
return attribute.value();
|
||||
}
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!Appends a new attribute with \a name in the namespace
|
||||
@ -2754,12 +2750,12 @@ bool QXmlStreamReader::isStandaloneDocument() const
|
||||
version string as specified in the XML declaration.
|
||||
Otherwise an empty string is returned.
|
||||
*/
|
||||
QStringRef QXmlStreamReader::documentVersion() const
|
||||
QStringView QXmlStreamReader::documentVersion() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
if (d->type == QXmlStreamReader::StartDocument)
|
||||
return d->documentVersion;
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2769,12 +2765,12 @@ QStringRef QXmlStreamReader::documentVersion() const
|
||||
encoding string as specified in the XML declaration.
|
||||
Otherwise an empty string is returned.
|
||||
*/
|
||||
QStringRef QXmlStreamReader::documentEncoding() const
|
||||
QStringView QXmlStreamReader::documentEncoding() const
|
||||
{
|
||||
Q_D(const QXmlStreamReader);
|
||||
if (d->type == QXmlStreamReader::StartDocument)
|
||||
return d->documentEncoding;
|
||||
return QStringRef();
|
||||
return QStringView();
|
||||
}
|
||||
|
||||
#endif // QT_NO_XMLSTREAMREADER
|
||||
|
@ -70,9 +70,11 @@ public:
|
||||
|
||||
inline void clear() { m_string.clear(); m_position = m_size = 0; }
|
||||
inline operator QStringRef() const { return QStringRef(&m_string, m_position, m_size); }
|
||||
inline operator QStringView() const { return QStringView(m_string.constData() + m_position, m_size); }
|
||||
inline const QString *string() const { return &m_string; }
|
||||
inline int position() const { return m_position; }
|
||||
inline int size() const { return m_size; }
|
||||
inline QString toString() const { return QString(m_string.constData() + m_position, m_size); }
|
||||
};
|
||||
Q_DECLARE_SHARED(QXmlStreamStringRef)
|
||||
|
||||
@ -89,15 +91,14 @@ public:
|
||||
QXmlStreamAttribute(const QString &qualifiedName, const QString &value);
|
||||
QXmlStreamAttribute(const QString &namespaceUri, const QString &name, const QString &value);
|
||||
|
||||
inline QStringRef namespaceUri() const { return m_namespaceUri; }
|
||||
inline QStringRef name() const { return m_name; }
|
||||
inline QStringRef qualifiedName() const { return m_qualifiedName; }
|
||||
inline QStringRef prefix() const {
|
||||
return QStringRef(m_qualifiedName.string(),
|
||||
m_qualifiedName.position(),
|
||||
inline QStringView namespaceUri() const { return m_namespaceUri; }
|
||||
inline QStringView name() const { return m_name; }
|
||||
inline QStringView qualifiedName() const { return m_qualifiedName; }
|
||||
inline QStringView prefix() const {
|
||||
return QStringView(m_qualifiedName.string()->constData() + m_qualifiedName.position(),
|
||||
qMax(0, m_qualifiedName.size() - m_name.size() - 1));
|
||||
}
|
||||
inline QStringRef value() const { return m_value; }
|
||||
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()
|
||||
@ -116,11 +117,11 @@ class QXmlStreamAttributes : public QList<QXmlStreamAttribute>
|
||||
{
|
||||
public:
|
||||
inline QXmlStreamAttributes() {}
|
||||
Q_CORE_EXPORT QStringRef value(const QString &namespaceUri, const QString &name) const;
|
||||
Q_CORE_EXPORT QStringRef value(const QString &namespaceUri, QLatin1String name) const;
|
||||
Q_CORE_EXPORT QStringRef value(QLatin1String namespaceUri, QLatin1String name) const;
|
||||
Q_CORE_EXPORT QStringRef value(const QString &qualifiedName) const;
|
||||
Q_CORE_EXPORT QStringRef value(QLatin1String qualifiedName) const;
|
||||
Q_CORE_EXPORT QStringView value(const QString &namespaceUri, const QString &name) const;
|
||||
Q_CORE_EXPORT QStringView value(const QString &namespaceUri, QLatin1String name) const;
|
||||
Q_CORE_EXPORT QStringView value(QLatin1String namespaceUri, QLatin1String name) const;
|
||||
Q_CORE_EXPORT QStringView value(const QString &qualifiedName) const;
|
||||
Q_CORE_EXPORT QStringView value(QLatin1String qualifiedName) const;
|
||||
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);
|
||||
|
||||
@ -150,8 +151,8 @@ public:
|
||||
QXmlStreamNamespaceDeclaration();
|
||||
QXmlStreamNamespaceDeclaration(const QString &prefix, const QString &namespaceUri);
|
||||
|
||||
inline QStringRef prefix() const { return m_prefix; }
|
||||
inline QStringRef namespaceUri() const { return m_namespaceUri; }
|
||||
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());
|
||||
}
|
||||
@ -169,9 +170,9 @@ class Q_CORE_EXPORT QXmlStreamNotationDeclaration {
|
||||
public:
|
||||
QXmlStreamNotationDeclaration();
|
||||
|
||||
inline QStringRef name() const { return m_name; }
|
||||
inline QStringRef systemId() const { return m_systemId; }
|
||||
inline QStringRef publicId() const { return m_publicId; }
|
||||
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());
|
||||
@ -190,11 +191,11 @@ class Q_CORE_EXPORT QXmlStreamEntityDeclaration {
|
||||
public:
|
||||
QXmlStreamEntityDeclaration();
|
||||
|
||||
inline QStringRef name() const { return m_name; }
|
||||
inline QStringRef notationName() const { return m_notationName; }
|
||||
inline QStringRef systemId() const { return m_systemId; }
|
||||
inline QStringRef publicId() const { return m_publicId; }
|
||||
inline QStringRef value() const { return m_value; }
|
||||
inline QStringView name() const { return m_name; }
|
||||
inline QStringView notationName() const { return m_notationName; }
|
||||
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()
|
||||
@ -276,8 +277,8 @@ public:
|
||||
inline bool isProcessingInstruction() const { return tokenType() == ProcessingInstruction; }
|
||||
|
||||
bool isStandaloneDocument() const;
|
||||
QStringRef documentVersion() const;
|
||||
QStringRef documentEncoding() const;
|
||||
QStringView documentVersion() const;
|
||||
QStringView documentEncoding() const;
|
||||
|
||||
qint64 lineNumber() const;
|
||||
qint64 columnNumber() const;
|
||||
@ -292,24 +293,24 @@ public:
|
||||
};
|
||||
QString readElementText(ReadElementTextBehaviour behaviour = ErrorOnUnexpectedElement);
|
||||
|
||||
QStringRef name() const;
|
||||
QStringRef namespaceUri() const;
|
||||
QStringRef qualifiedName() const;
|
||||
QStringRef prefix() const;
|
||||
QStringView name() const;
|
||||
QStringView namespaceUri() const;
|
||||
QStringView qualifiedName() const;
|
||||
QStringView prefix() const;
|
||||
|
||||
QStringRef processingInstructionTarget() const;
|
||||
QStringRef processingInstructionData() const;
|
||||
QStringView processingInstructionTarget() const;
|
||||
QStringView processingInstructionData() const;
|
||||
|
||||
QStringRef text() const;
|
||||
QStringView text() const;
|
||||
|
||||
QXmlStreamNamespaceDeclarations namespaceDeclarations() const;
|
||||
void addExtraNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &extraNamespaceDeclaraction);
|
||||
void addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclaractions);
|
||||
QXmlStreamNotationDeclarations notationDeclarations() const;
|
||||
QXmlStreamEntityDeclarations entityDeclarations() const;
|
||||
QStringRef dtdName() const;
|
||||
QStringRef dtdPublicId() const;
|
||||
QStringRef dtdSystemId() const;
|
||||
QStringView dtdName() const;
|
||||
QStringView dtdPublicId() const;
|
||||
QStringView dtdSystemId() const;
|
||||
|
||||
int entityExpansionLimit() const;
|
||||
void setEntityExpansionLimit(int limit);
|
||||
|
@ -104,7 +104,7 @@ void VkSpecParser::parseCommands()
|
||||
m_reader.readNext();
|
||||
if (m_reader.isEndElement() && m_reader.name() == QStringLiteral("commands"))
|
||||
return;
|
||||
if (m_reader.isStartElement() && m_reader.name() == "command")
|
||||
if (m_reader.isStartElement() && m_reader.name() == u"command")
|
||||
m_commands.append(parseCommand());
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ VkSpecParser::TypedName VkSpecParser::parseParamOrProto(const QString &tag)
|
||||
skip();
|
||||
}
|
||||
} else {
|
||||
QStringRef text = m_reader.text().trimmed();
|
||||
auto text = m_reader.text().trimmed();
|
||||
if (!text.isEmpty()) {
|
||||
if (text.startsWith(QLatin1Char('['))) {
|
||||
t.typeSuffix += text;
|
||||
|
@ -172,7 +172,7 @@ static double versionFromUiAttribute(QXmlStreamReader &reader)
|
||||
const QString versionAttribute = QLatin1String("version");
|
||||
if (!attributes.hasAttribute(versionAttribute))
|
||||
return 4.0;
|
||||
const QStringRef version = attributes.value(versionAttribute);
|
||||
const QStringView version = attributes.value(versionAttribute);
|
||||
return version.toDouble();
|
||||
}
|
||||
|
||||
|
@ -291,15 +291,6 @@ QT_WARNING_POP
|
||||
|
||||
#endif // QT_DEPRECATED_SINCE(5, 15)
|
||||
|
||||
inline QString stringRefToString(const QStringRef &stringRef)
|
||||
{
|
||||
// Calling QStringRef::toString() on a NULL QStringRef in some cases returns
|
||||
// an empty string (i.e. QString("")) instead of a NULL string (i.e. QString()).
|
||||
// QDom implementation differentiates between NULL and empty strings, so
|
||||
// we need this as workaround to keep the current behavior unchanged.
|
||||
return stringRef.isNull() ? QString() : stringRef.toString();
|
||||
}
|
||||
|
||||
bool QDomBuilder::startElement(const QString &nsURI, const QString &qName,
|
||||
const QXmlStreamAttributes &atts)
|
||||
{
|
||||
@ -317,12 +308,12 @@ bool QDomBuilder::startElement(const QString &nsURI, const QString &qName,
|
||||
for (const auto &attr : atts) {
|
||||
auto domElement = static_cast<QDomElementPrivate *>(node);
|
||||
if (nsProcessing) {
|
||||
domElement->setAttributeNS(stringRefToString(attr.namespaceUri()),
|
||||
stringRefToString(attr.qualifiedName()),
|
||||
stringRefToString(attr.value()));
|
||||
domElement->setAttributeNS(attr.namespaceUri().toString(),
|
||||
attr.qualifiedName().toString(),
|
||||
attr.value().toString());
|
||||
} else {
|
||||
domElement->setAttribute(stringRefToString(attr.qualifiedName()),
|
||||
stringRefToString(attr.value()));
|
||||
domElement->setAttribute(attr.qualifiedName().toString(),
|
||||
attr.value().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -513,9 +504,9 @@ bool QDomParser::parseProlog()
|
||||
}
|
||||
foundDtd = true;
|
||||
|
||||
if (!domBuilder.startDTD(stringRefToString(reader->dtdName()),
|
||||
stringRefToString(reader->dtdPublicId()),
|
||||
stringRefToString(reader->dtdSystemId()))) {
|
||||
if (!domBuilder.startDTD(reader->dtdName().toString(),
|
||||
reader->dtdPublicId().toString(),
|
||||
reader->dtdSystemId().toString())) {
|
||||
domBuilder.fatalError(
|
||||
QDomParser::tr("Error occurred while processing document type declaration"));
|
||||
return false;
|
||||
@ -550,13 +541,13 @@ bool QDomParser::parseBody()
|
||||
{
|
||||
Q_ASSERT(reader);
|
||||
|
||||
std::stack<QStringRef> tagStack;
|
||||
std::stack<QString> tagStack;
|
||||
while (!reader->atEnd() && !reader->hasError()) {
|
||||
switch (reader->tokenType()) {
|
||||
case QXmlStreamReader::StartElement:
|
||||
tagStack.push(reader->qualifiedName());
|
||||
if (!domBuilder.startElement(stringRefToString(reader->namespaceUri()),
|
||||
stringRefToString(reader->qualifiedName()),
|
||||
tagStack.push(reader->qualifiedName().toString());
|
||||
if (!domBuilder.startElement(reader->namespaceUri().toString(),
|
||||
reader->qualifiedName().toString(),
|
||||
reader->attributes())) {
|
||||
domBuilder.fatalError(
|
||||
QDomParser::tr("Error occurred while processing a start element"));
|
||||
@ -641,10 +632,10 @@ bool QDomParser::parseMarkupDecl()
|
||||
// parsed result. So we don't need to do anything for the Internal Entities.
|
||||
if (!entityDecl.publicId().isEmpty() || !entityDecl.systemId().isEmpty()) {
|
||||
// External Entity
|
||||
if (!domBuilder.unparsedEntityDecl(stringRefToString(entityDecl.name()),
|
||||
stringRefToString(entityDecl.publicId()),
|
||||
stringRefToString(entityDecl.systemId()),
|
||||
stringRefToString(entityDecl.notationName()))) {
|
||||
if (!domBuilder.unparsedEntityDecl(entityDecl.name().toString(),
|
||||
entityDecl.publicId().toString(),
|
||||
entityDecl.systemId().toString(),
|
||||
entityDecl.notationName().toString())) {
|
||||
domBuilder.fatalError(
|
||||
QDomParser::tr("Error occurred while processing entity declaration"));
|
||||
return false;
|
||||
@ -654,9 +645,9 @@ bool QDomParser::parseMarkupDecl()
|
||||
|
||||
const auto notations = reader->notationDeclarations();
|
||||
for (const auto ¬ationDecl : notations) {
|
||||
if (!domBuilder.notationDecl(stringRefToString(notationDecl.name()),
|
||||
stringRefToString(notationDecl.publicId()),
|
||||
stringRefToString(notationDecl.systemId()))) {
|
||||
if (!domBuilder.notationDecl(notationDecl.name().toString(),
|
||||
notationDecl.publicId().toString(),
|
||||
notationDecl.systemId().toString())) {
|
||||
domBuilder.fatalError(
|
||||
QDomParser::tr("Error occurred while processing notation declaration"));
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user