Attica

configparser.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2018 Ralf Habacker <[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 "configparser.h"
10 
11 
12 using namespace Attica;
13 
14 Config Config::Parser::parseXml(QXmlStreamReader& xml)
15 {
16  Config config;
17 
18  while (!xml.atEnd()) {
19  xml.readNext();
20 
21  if (xml.isStartElement()) {
22  if (xml.name() == QLatin1String("version")) {
23  config.setVersion( xml.readElementText());
24  } else if (xml.name() == QLatin1String("website")) {
25  config.setWebsite( xml.readElementText());
26  } else if (xml.name() == QLatin1String("host")) {
27  config.setHost( xml.readElementText());
28  } else if (xml.name() == QLatin1String("contact")) {
29  config.setContact( xml.readElementText());
30  } else if (xml.name() == QLatin1String("ssl")) {
31  config.setSsl(xml.readElementText() == QLatin1String("true"));
32  }
33  }
34 
35  if (xml.isEndElement() && xml.name() == QLatin1String("data")) {
36  break;
37  }
38  }
39 
40  return config;
41 }
42 
43 
44 QStringList Config::Parser::xmlElement() const {
45  return QStringList(QStringLiteral( "data" ));
46 }
bool atEnd() const const
Represents a server config.
Definition: config.h:21
KSharedConfigPtr config()
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 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.