#include "atomchannelimage.h" #include #include "macros.h" AtomChannelImage::AtomChannelImage(QXmlStreamReader *xmlReader) { Q_ASSERT(xmlReader != nullptr); const QString urlTag{"url"}; const QString titleTag{"title"}; const QString linkTag{"link"}; const QString widthTag{"width"}; const QString heightTag{"height"}; while (!xmlReader->atEnd() && !xmlReader->hasError()) { const auto itemNext = xmlReader->readNext(); switch (itemNext) { case QXmlStreamReader::TokenType::StartElement: { const auto name = xmlReader->name(); // qDebug() << __func__ << ":" << name; const auto elementText = xmlReader->readElementText(); if (name == urlTag) url = elementText; else if (name == titleTag) title = elementText; else if (name == linkTag) link = elementText; else if (name == widthTag) width = elementText.toInt(); else if (name == heightTag) height = elementText.toInt(); break; } case QXmlStreamReader::TokenType::EndElement: // qDebug() << "EndElement: " << xmlReader->name(); return; case QXmlStreamReader::TokenType::Characters: const auto characters = xmlReader->text().toString().simplified(); if (characters.isEmpty()) break; qDebug() << "image: characters: " << characters; break; } } } QDebug operator<<(QDebug debug, const AtomChannelImage &image) { QDebugStateSaver saver{debug}; debug.nospace() << typeid(AtomChannelImage).name() << " {" << Qt::endl; PRINT_ATOM_FIELD(image, url); PRINT_ATOM_FIELD(image, title); PRINT_ATOM_FIELD(image, link); PRINT_ATOM_FIELD(image, width); PRINT_ATOM_FIELD(image, height); debug.nospace() << "}"; return debug; }