Attica

distributionparser.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2010 Intel Corporation
5  SPDX-FileContributor: Mateu Batle Sastre <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
8 */
9 
10 #include "distributionparser.h"
11 
12 using namespace Attica;
13 
14 QStringList Distribution::Parser::xmlElement() const
15 {
16  return QStringList(QStringLiteral("distribution"));
17 }
18 
19 Distribution Distribution::Parser::parseXml(QXmlStreamReader &xml)
20 {
21  Distribution item;
22 
23  while (!xml.atEnd()) {
24  xml.readNext();
25  if (xml.isStartElement()) {
26  if (xml.name() == QLatin1String("id")) {
27  item.setId(xml.readElementText().toInt());
28  } else if (xml.name() == QLatin1String("name")) {
29  item.setName(xml.readElementText());
30  }
31  }
32  if (xml.isEndElement() && xml.name() == QLatin1String("distribution")) {
33  break;
34  }
35  }
36  return item;
37 }
bool atEnd() const const
The Distribution class contains information about one distribution that the server offers...
Definition: distribution.h:24
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
int toInt(bool *ok, int base) const const
QXmlStreamReader::TokenType readNext()
bool isStartElement() const const
QStringRef name() const const
bool isEndElement() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 03:59:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.