template class void Parser parseMetadataXml QXmlStreamReader xml while

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
template <class T>
void Parser<T>::parseMetadataXml(QXmlStreamReader &xml)
{
while (!xml.atEnd()) {
xml.readNext();
if (xml.isEndElement() && xml.name() == QLatin1String("meta")) {
break;
} else if (xml.isStartElement()) {
if (xml.name() == QLatin1String("status")) {
m_metadata.setStatusString(xml.readElementText());
} else if (xml.name() == QLatin1String("statuscode")) {
m_metadata.setStatusCode(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("message")) {
m_metadata.setMessage(xml.readElementText());
} else if (xml.name() == QLatin1String("totalitems")) {
m_metadata.setTotalItems(xml.readElementText().toInt());
} else if (xml.name() == QLatin1String("itemsperpage")) {
m_metadata.setItemsPerPage(xml.readElementText().toInt());
}
}
}
if (xml.hasError()) {
// TODO: error handling in metadata?
qWarning() << "XML Error: " << xml.errorString();
}
}