Attica

projectparser.cpp
1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2010 Sebastian Kügler <sebas@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#include "projectparser.h"
10#include <qdebug.h>
11
12using namespace Attica;
13
14Project Project::Parser::parseXml(QXmlStreamReader &xml)
15{
16 Project project;
17
18 // For specs about the XML provided, see here:
19 // http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft#Projects
20 while (!xml.atEnd()) {
21 // qCDebug(ATTICA) << "XML returned:" << xml.text().toString();
22 xml.readNext();
23
24 if (xml.isStartElement()) {
25 if (xml.name() == QLatin1String("projectid")) {
26 project.setId(xml.readElementText());
27 } else if (xml.name() == QLatin1String("name")) {
28 project.setName(xml.readElementText());
29 } else if (xml.name() == QLatin1String("version")) {
30 project.setVersion(xml.readElementText());
31 } else if (xml.name() == QLatin1String("license")) {
32 project.setLicense(xml.readElementText());
33 } else if (xml.name() == QLatin1String("url")) {
34 project.setUrl(xml.readElementText());
35 } else if (xml.name() == QLatin1String("summary")) {
36 project.setSummary(xml.readElementText());
37 } else if (xml.name() == QLatin1String("description")) {
38 project.setDescription(xml.readElementText());
39 } else if (xml.name() == QLatin1String("specfile")) {
40 project.setSpecFile(xml.readElementText());
41 } else if (xml.name() == QLatin1String("developers")) {
42 project.setDevelopers(xml.readElementText().split(QLatin1Char('\n')));
43 } else if (xml.name() == QLatin1String("projectlist")) {
44 QXmlStreamReader list_xml(xml.readElementText());
45 while (!list_xml.atEnd()) {
46 list_xml.readNext();
47 if (xml.name() == QLatin1String("projectid")) {
48 project.setSpecFile(xml.readElementText());
49 }
50 }
51 }
52 } else if (xml.isEndElement() && (xml.name() == QLatin1String("project") || xml.name() == QLatin1String("user"))) {
53 break;
54 }
55 }
56 return project;
57}
58
59QStringList Project::Parser::xmlElement() const
60{
61 return QStringList(QStringLiteral("project")) << QStringLiteral("user");
62}
Represents a project.
Definition project.h:30
The Attica namespace,.
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool atEnd() const const
bool isEndElement() const const
bool isStartElement() const const
QStringView name() const const
QString readElementText(ReadElementTextBehaviour behaviour)
TokenType readNext()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.