本文整理汇总了C++中DeviceInfo::ParseXml方法的典型用法代码示例。如果您正苦于以下问题:C++ DeviceInfo::ParseXml方法的具体用法?C++ DeviceInfo::ParseXml怎么用?C++ DeviceInfo::ParseXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceInfo
的用法示例。
在下文中一共展示了DeviceInfo::ParseXml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseXml
bool FirmwareInfo::ParseXml(QXmlStreamReader& xml)
{
Clear();
bool foundName = false;
bool foundVersion = false;
bool foundPlatform = false;
bool foundDevelopers = false;
bool foundUrl = false;
bool foundDonateUrl = false;
bool foundDevices = false;
bool foundPit = false;
bool foundRepartition = false;
bool foundNoReboot = false;
bool foundFiles = false;
if (!xml.readNextStartElement())
{
Alerts::DisplayError("Failed to find <firmware> element.");
return (false);
}
if (xml.name() != "firmware")
{
Alerts::DisplayError(QString("Expected <firmware> element but found <%1>.").arg(xml.name().toString()));
return (false);
}
QString formatVersionString;
formatVersionString += xml.attributes().value("version");
if (formatVersionString.isEmpty())
{
Alerts::DisplayError("<firmware> is missing the version attribute.");
return (false);
}
bool parsedVersion = false;
int formatVersion = formatVersionString.toInt(&parsedVersion);
if (!parsedVersion)
{
Alerts::DisplayError("<firmware> contains a malformed version.");
return (false);
}
if (formatVersion > kVersion)
{
Alerts::DisplayError("Package is for a newer version of Heimdall Frontend.\nPlease download the latest version of Heimdall Frontend.");
return (false);
}
while (!xml.atEnd())
{
QXmlStreamReader::TokenType nextToken = xml.readNext();
if (nextToken == QXmlStreamReader::StartElement)
{
if (xml.name() == "name")
{
if (foundName)
{
Alerts::DisplayError("Found multiple <name> elements in <firmware>.");
return (false);
}
foundName = true;
name = xml.readElementText();
}
else if (xml.name() == "version")
{
if (foundVersion)
{
Alerts::DisplayError("Found multiple <version> elements in <firmware>.");
return (false);
}
foundVersion = true;
version = xml.readElementText();
}
else if (xml.name() == "platform")
{
if (foundPlatform)
{
Alerts::DisplayError("Found multiple <platform> elements in <firmware>.");
return (false);
}
foundPlatform = true;
if (!platformInfo.ParseXml(xml))
return (false);
}
else if (xml.name() == "developers")
{
if (foundDevelopers)
{
Alerts::DisplayError("Found multiple <developers> elements in <firmware>.");
return (false);
}
//.........这里部分代码省略.........