Attica

buildserviceparser.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2010 Sebastian K├╝gler <[email protected]>
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 
12 using namespace Attica;
13 
14 BuildService 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 
26  if (xml.name() == QLatin1String("id")) {
27  buildservice.setId(xml.readElementText());
28  } else if (xml.name() == QLatin1String("name")) {
29  buildservice.setName(xml.readElementText());
30  } else if (xml.name() == QLatin1String("registrationurl")) {
31  buildservice.setUrl(xml.readElementText());
32  } else if (xml.name() == QLatin1String("supportedtargets")) {
33  while (!xml.atEnd()) {
35  if (xml.isStartElement()) {
36  if (xml.name() == QLatin1String("target")) {
37  Target t;
38  while (!xml.atEnd()) {
40  if (xml.isStartElement()) {
41  if (xml.name() == QLatin1String("id")) {
42  t.id = xml.readElementText();
43  } else if (xml.name() == QLatin1String("name")) {
44  t.name = xml.readElementText();
45  }
46  } else if (xml.isEndElement() && (xml.name() == QLatin1String("target"))) {
47  xml.readNext();
48  break;
49  }
50  }
51  buildservice.addTarget(t);
52  }
53  } else if (xml.isEndElement() && (xml.name() == QLatin1String("supportedtargets"))) {
54  xml.readNext();
55  break;
56  }
57  }
58  }
59  } else if (xml.isEndElement()
60  && ((xml.name() == QLatin1String("buildservice"))
61  || (xml.name() == QLatin1String("user")))) {
62  break;
63  }
64  }
65  return buildservice;
66 }
67 
68 QStringList BuildService::Parser::xmlElement() const
69 {
70  return QStringList(QStringLiteral("buildservice")) << QStringLiteral("user");
71 }
bool atEnd() const const
bool readNextStartElement()
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
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.