Attica

licenseparser.cpp
1 /*
2  SPDX-FileCopyrightText: 2010 Frederik Gladhorn <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
7 #include "licenseparser.h"
8 
9 using namespace Attica;
10 
11 QStringList License::Parser::xmlElement() const
12 {
13  return QStringList(QStringLiteral("license"));
14 }
15 
16 License License::Parser::parseXml(QXmlStreamReader &xml)
17 {
18  License item;
19 
20  while (!xml.atEnd()) {
21  xml.readNext();
22  if (xml.isStartElement()) {
23  if (xml.name() == QLatin1String("id")) {
24  item.setId(xml.readElementText().toInt());
25  } else if (xml.name() == QLatin1String("name")) {
26  item.setName(xml.readElementText());
27  } else if (xml.name() == QLatin1String("link")) {
28  item.setUrl(QUrl(xml.readElementText()));
29  }
30  }
31  if (xml.isEndElement() && xml.name() == QLatin1String("license")) {
32  break;
33  }
34  }
35  return item;
36 }
bool atEnd() const const
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
int toInt(bool *ok, int base) const const
QXmlStreamReader::TokenType readNext()
bool isStartElement() const const
The License class contains information about one license that the server offers.
Definition: license.h:21
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 Mon Jan 25 2021 23:06:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.