QDebug: clean up handling of QMap/QHash
Prepare for the fact that the multi-key containers will no longer inherit from the single-key ones. Refactor the code to follow the existing. Change-Id: I5fd4d7e33f8184c015e18e169af72e11a5e84f0d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
f35745a30c
commit
18693916a4
@ -250,6 +250,20 @@ inline QDebug printSequentialContainer(QDebug debug, const char *which, const Se
|
|||||||
return debug.maybeSpace();
|
return debug.maybeSpace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename AssociativeContainer>
|
||||||
|
inline QDebug printAssociativeContainer(QDebug debug, const char *which, const AssociativeContainer &c)
|
||||||
|
{
|
||||||
|
const bool oldSetting = debug.autoInsertSpaces();
|
||||||
|
debug.nospace() << which << "(";
|
||||||
|
for (typename AssociativeContainer::const_iterator it = c.constBegin();
|
||||||
|
it != c.constEnd(); ++it) {
|
||||||
|
debug << '(' << it.key() << ", " << it.value() << ')';
|
||||||
|
}
|
||||||
|
debug << ')';
|
||||||
|
debug.setAutoInsertSpaces(oldSetting);
|
||||||
|
return debug.maybeSpace();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace QtPrivate
|
} // namespace QtPrivate
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -285,28 +299,25 @@ inline QDebug operator<<(QDebug debug, const std::multimap<Key, T, Compare, Allo
|
|||||||
template <class Key, class T>
|
template <class Key, class T>
|
||||||
inline QDebug operator<<(QDebug debug, const QMap<Key, T> &map)
|
inline QDebug operator<<(QDebug debug, const QMap<Key, T> &map)
|
||||||
{
|
{
|
||||||
const bool oldSetting = debug.autoInsertSpaces();
|
return QtPrivate::printAssociativeContainer(debug, "QMap", map);
|
||||||
debug.nospace() << "QMap(";
|
}
|
||||||
for (typename QMap<Key, T>::const_iterator it = map.constBegin();
|
|
||||||
it != map.constEnd(); ++it) {
|
template <class Key, class T>
|
||||||
debug << '(' << it.key() << ", " << it.value() << ')';
|
inline QDebug operator<<(QDebug debug, const QMultiMap<Key, T> &map)
|
||||||
}
|
{
|
||||||
debug << ')';
|
return QtPrivate::printAssociativeContainer(debug, "QMultiMap", map);
|
||||||
debug.setAutoInsertSpaces(oldSetting);
|
|
||||||
return debug.maybeSpace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Key, class T>
|
template <class Key, class T>
|
||||||
inline QDebug operator<<(QDebug debug, const QHash<Key, T> &hash)
|
inline QDebug operator<<(QDebug debug, const QHash<Key, T> &hash)
|
||||||
{
|
{
|
||||||
const bool oldSetting = debug.autoInsertSpaces();
|
return QtPrivate::printAssociativeContainer(debug, "QHash", hash);
|
||||||
debug.nospace() << "QHash(";
|
}
|
||||||
for (typename QHash<Key, T>::const_iterator it = hash.constBegin();
|
|
||||||
it != hash.constEnd(); ++it)
|
template <class Key, class T>
|
||||||
debug << '(' << it.key() << ", " << it.value() << ')';
|
inline QDebug operator<<(QDebug debug, const QMultiHash<Key, T> &hash)
|
||||||
debug << ')';
|
{
|
||||||
debug.setAutoInsertSpaces(oldSetting);
|
return QtPrivate::printAssociativeContainer(debug, "QMultiHash", hash);
|
||||||
return debug.maybeSpace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user