From 625cc465df179040356cd49668ab69481a7f290c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 14 Mar 2017 12:54:45 +0100 Subject: Typedatabase: Improve debug output Add debug operator for TemplateEntry and output sizes. Task-number: PYSIDE-323 Change-Id: I6a03f5c908ea5a0a3e8f14b640b1575bc49b6bd8 Reviewed-by: Alexandru Croitor --- ApiExtractor/typedatabase.cpp | 83 ++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/ApiExtractor/typedatabase.cpp b/ApiExtractor/typedatabase.cpp index 59d34d80b..c80efcaba 100644 --- a/ApiExtractor/typedatabase.cpp +++ b/ApiExtractor/typedatabase.cpp @@ -570,34 +570,6 @@ bool TypeDatabase::checkApiVersion(const QString& package, const QByteArray& ver } #ifndef QT_NO_DEBUG_STREAM -void TypeDatabase::formatDebug(QDebug &d) const -{ - typedef TypeEntryHash::ConstIterator Eit; - typedef TemplateEntryHash::ConstIterator TplIt; - d << "TypeDatabase(" - << "entries="; - for (Eit it = m_entries.cbegin(), end = m_entries.cend(); it != end; ++it) { - d << '"' << it.key() << "\": ["; - for (int t = 0, cnt = it.value().size(); t < cnt; ++t) { - if (t) - d << ", "; - d << it.value().at(t); - } - d << "]\n"; - } - if (!m_templates.isEmpty()) { - d << "templates=["; - const TplIt begin = m_templates.cbegin(); - for (TplIt it = begin, end = m_templates.cend(); it != end; ++it) { - if (it != begin) - d << ", "; - d << it.value(); - } - d << "]\n"; - } - d <<"\nglobalUserFunctions=" << m_globalUserFunctions << ')'; -} - QDebug operator<<(QDebug d, const TypeEntry *te) { QDebugStateSaver saver(d); @@ -624,6 +596,61 @@ QDebug operator<<(QDebug d, const TypeEntry *te) return d; } +QDebug operator<<(QDebug d, const TemplateEntry *te) +{ + QDebugStateSaver saver(d); + d.noquote(); + d.nospace(); + d << "TemplateEntry("; + if (te) { + d << '"' << te->name() << "\", version=" << te->version(); + } else { + d << '0'; + } + d << ')'; + return d; +} + +void TypeDatabase::formatDebug(QDebug &d) const +{ + typedef TypeEntryHash::ConstIterator Eit; + typedef SingleTypeEntryHash::ConstIterator Sit; + typedef TemplateEntryHash::ConstIterator TplIt; + d << "TypeDatabase(" + << "entries[" << m_entries.size() << "]="; + for (Eit it = m_entries.cbegin(), end = m_entries.cend(); it != end; ++it) { + const int count = it.value().size(); + d << '"' << it.key() << "\" [" << count << "]: ("; + for (int t = 0; t < count; ++t) { + if (t) + d << ", "; + d << it.value().at(t); + } + d << ")\n"; + } + if (!m_templates.isEmpty()) { + d << "templates[" << m_templates.size() << "]=("; + const TplIt begin = m_templates.cbegin(); + for (TplIt it = begin, end = m_templates.cend(); it != end; ++it) { + if (it != begin) + d << ", "; + d << it.value(); + } + d << ")\n"; + } + if (!m_flagsEntries.isEmpty()) { + d << "flags[" << m_flagsEntries.size() << "]=("; + const Sit begin = m_flagsEntries.cbegin(); + for (Sit it = begin, end = m_flagsEntries.cend(); it != end; ++it) { + if (it != begin) + d << ", "; + d << it.value(); + } + d << ")\n"; + } + d <<"\nglobalUserFunctions=" << m_globalUserFunctions << ')'; +} + QDebug operator<<(QDebug d, const TypeDatabase &db) { QDebugStateSaver saver(d); -- cgit v1.2.3