Attica

buildserviceparser.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 "buildserviceparser.h"
10#include <qdebug.h>
11
12using namespace Attica;
13
14BuildService BuildService::Parser::parseXml(QXmlStreamReader &xml)
15{
16 // For specs about the XML provided, see here:
17 // http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft
18
19 BuildService buildservice;
20
21 while (!xml.atEnd()) {
22 xml.readNext();
23
24 if (xml.isStartElement()) {
25 if (xml.name() == QLatin1String("id")) {
26 buildservice.setId(xml.readElementText());
27 } else if (xml.name() == QLatin1String("name")) {
28 buildservice.setName(xml.readElementText());
29 } else if (xml.name() == QLatin1String("registrationurl")) {
30 buildservice.setUrl(xml.readElementText());
31 } else if (xml.name() == QLatin1String("supportedtargets")) {
32 while (!xml.atEnd()) {
34 if (xml.isStartElement()) {
35 if (xml.name() == QLatin1String("target")) {
36 Target t;
37 while (!xml.atEnd()) {
39 if (xml.isStartElement()) {
40 if (xml.name() == QLatin1String("id")) {
41 t.id = xml.readElementText();
42 } else if (xml.name() == QLatin1String("name")) {
43 t.name = xml.readElementText();
44 }
45 } else if (xml.isEndElement() && (xml.name() == QLatin1String("target"))) {
46 xml.readNext();
47 break;
48 }
49 }
50 buildservice.addTarget(t);
51 }
52 } else if (xml.isEndElement() && (xml.name() == QLatin1String("supportedtargets"))) {
53 xml.readNext();
54 break;
55 }
56 }
57 }
58 } else if (xml.isEndElement() //
59 && (xml.name() == QLatin1String("buildservice") || xml.name() == QLatin1String("user"))) {
60 break;
61 }
62 }
63 return buildservice;
64}
65
66QStringList BuildService::Parser::xmlElement() const
67{
68 return QStringList(QStringLiteral("buildservice")) << QStringLiteral("user");
69}
Represents a build service.
The Attica namespace,.
bool atEnd() const const
bool isEndElement() const const
bool isStartElement() const const
QStringView name() const const
QString readElementText(ReadElementTextBehaviour behaviour)
TokenType readNext()
bool readNextStartElement()
The target in a build service.
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.