QXmlStream: use more ranged for loops
More compact and isolates against decltype(size()) issues. Had to make QXmlStreamSimpleStack iterable. Change-Id: Icfa7b2ab09995c7a442fd8a5b2f5d6ce90120822 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
f490ac6712
commit
0beaed7384
@ -1586,8 +1586,7 @@ void QXmlStreamReaderPrivate::resolveTag()
|
|||||||
int n = attributeStack.size();
|
int n = attributeStack.size();
|
||||||
|
|
||||||
if (namespaceProcessing) {
|
if (namespaceProcessing) {
|
||||||
for (int a = 0; a < dtdAttributes.size(); ++a) {
|
for (DtdAttribute &dtdAttribute : dtdAttributes) {
|
||||||
DtdAttribute &dtdAttribute = dtdAttributes[a];
|
|
||||||
if (!dtdAttribute.isNamespaceAttribute
|
if (!dtdAttribute.isNamespaceAttribute
|
||||||
|| dtdAttribute.defaultValue.isNull()
|
|| dtdAttribute.defaultValue.isNull()
|
||||||
|| dtdAttribute.tagName != qualifiedName
|
|| dtdAttribute.tagName != qualifiedName
|
||||||
@ -1657,8 +1656,7 @@ void QXmlStreamReaderPrivate::resolveTag()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int a = 0; a < dtdAttributes.size(); ++a) {
|
for (DtdAttribute &dtdAttribute : dtdAttributes) {
|
||||||
DtdAttribute &dtdAttribute = dtdAttributes[a];
|
|
||||||
if (dtdAttribute.isNamespaceAttribute
|
if (dtdAttribute.isNamespaceAttribute
|
||||||
|| dtdAttribute.defaultValue.isNull()
|
|| dtdAttribute.defaultValue.isNull()
|
||||||
|| dtdAttribute.tagName != qualifiedName
|
|| dtdAttribute.tagName != qualifiedName
|
||||||
@ -2120,8 +2118,8 @@ void QXmlStreamReader::addExtraNamespaceDeclaration(const QXmlStreamNamespaceDec
|
|||||||
*/
|
*/
|
||||||
void QXmlStreamReader::addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclarations)
|
void QXmlStreamReader::addExtraNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &extraNamespaceDeclarations)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < extraNamespaceDeclarations.size(); ++i)
|
for (const auto &extraNamespaceDeclaration : extraNamespaceDeclarations)
|
||||||
addExtraNamespaceDeclaration(extraNamespaceDeclarations.at(i));
|
addExtraNamespaceDeclaration(extraNamespaceDeclaration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2730,8 +2728,7 @@ Returns the entity's value.
|
|||||||
*/
|
*/
|
||||||
QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QString &name) const
|
QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QString &name) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size(); ++i) {
|
for (const QXmlStreamAttribute &attribute : *this) {
|
||||||
const QXmlStreamAttribute &attribute = at(i);
|
|
||||||
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
||||||
return attribute.value();
|
return attribute.value();
|
||||||
}
|
}
|
||||||
@ -2745,8 +2742,7 @@ QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, const QStrin
|
|||||||
*/
|
*/
|
||||||
QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const
|
QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1String name) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size(); ++i) {
|
for (const QXmlStreamAttribute &attribute : *this) {
|
||||||
const QXmlStreamAttribute &attribute = at(i);
|
|
||||||
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
||||||
return attribute.value();
|
return attribute.value();
|
||||||
}
|
}
|
||||||
@ -2760,8 +2756,7 @@ QStringRef QXmlStreamAttributes::value(const QString &namespaceUri, QLatin1Strin
|
|||||||
*/
|
*/
|
||||||
QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const
|
QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String name) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size(); ++i) {
|
for (const QXmlStreamAttribute &attribute : *this) {
|
||||||
const QXmlStreamAttribute &attribute = at(i);
|
|
||||||
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
if (attribute.name() == name && attribute.namespaceUri() == namespaceUri)
|
||||||
return attribute.value();
|
return attribute.value();
|
||||||
}
|
}
|
||||||
@ -2782,8 +2777,7 @@ QStringRef QXmlStreamAttributes::value(QLatin1String namespaceUri, QLatin1String
|
|||||||
*/
|
*/
|
||||||
QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const
|
QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size(); ++i) {
|
for (const QXmlStreamAttribute &attribute : *this) {
|
||||||
const QXmlStreamAttribute &attribute = at(i);
|
|
||||||
if (attribute.qualifiedName() == qualifiedName)
|
if (attribute.qualifiedName() == qualifiedName)
|
||||||
return attribute.value();
|
return attribute.value();
|
||||||
}
|
}
|
||||||
@ -2804,8 +2798,7 @@ QStringRef QXmlStreamAttributes::value(const QString &qualifiedName) const
|
|||||||
*/
|
*/
|
||||||
QStringRef QXmlStreamAttributes::value(QLatin1String qualifiedName) const
|
QStringRef QXmlStreamAttributes::value(QLatin1String qualifiedName) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < size(); ++i) {
|
for (const QXmlStreamAttribute &attribute : *this) {
|
||||||
const QXmlStreamAttribute &attribute = at(i);
|
|
||||||
if (attribute.qualifiedName() == qualifiedName)
|
if (attribute.qualifiedName() == qualifiedName)
|
||||||
return attribute.value();
|
return attribute.value();
|
||||||
}
|
}
|
||||||
@ -3595,8 +3588,8 @@ void QXmlStreamWriter::writeAttributes(const QXmlStreamAttributes& attributes)
|
|||||||
Q_D(QXmlStreamWriter);
|
Q_D(QXmlStreamWriter);
|
||||||
Q_ASSERT(d->inStartElement);
|
Q_ASSERT(d->inStartElement);
|
||||||
Q_UNUSED(d);
|
Q_UNUSED(d);
|
||||||
for (int i = 0; i < attributes.size(); ++i)
|
for (const auto &attr : attributes)
|
||||||
writeAttribute(attributes.at(i));
|
writeAttribute(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,6 +179,15 @@ public:
|
|||||||
inline void resize(int s) { tos = s - 1; }
|
inline void resize(int s) { tos = s - 1; }
|
||||||
inline bool isEmpty() const { return tos < 0; }
|
inline bool isEmpty() const { return tos < 0; }
|
||||||
inline void clear() { tos = -1; }
|
inline void clear() { tos = -1; }
|
||||||
|
|
||||||
|
using const_iterator = const T*;
|
||||||
|
using iterator = T*;
|
||||||
|
T *begin() { return data; }
|
||||||
|
const T *begin() const { return data; }
|
||||||
|
const T *cbegin() const { return begin(); }
|
||||||
|
T *end() { return data + size(); }
|
||||||
|
const T *end() const { return data + size(); }
|
||||||
|
const T *cend() const { return end(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -668,6 +668,15 @@ public:
|
|||||||
inline void resize(int s) { tos = s - 1; }
|
inline void resize(int s) { tos = s - 1; }
|
||||||
inline bool isEmpty() const { return tos < 0; }
|
inline bool isEmpty() const { return tos < 0; }
|
||||||
inline void clear() { tos = -1; }
|
inline void clear() { tos = -1; }
|
||||||
|
|
||||||
|
using const_iterator = const T*;
|
||||||
|
using iterator = T*;
|
||||||
|
T *begin() { return data; }
|
||||||
|
const T *begin() const { return data; }
|
||||||
|
const T *cbegin() const { return begin(); }
|
||||||
|
T *end() { return data + size(); }
|
||||||
|
const T *end() const { return data + size(); }
|
||||||
|
const T *cend() const { return end(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user