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 using namespace Attica;
12 
13 Config Config::Parser::parseXml(QXmlStreamReader &xml)
14 {
15  Config config;
16 
17  while (!xml.atEnd()) {
18  xml.readNext();
19 
20  if (xml.isStartElement()) {
21  if (xml.name() == QLatin1String("version")) {
22  config.setVersion(xml.readElementText());
23  } else if (xml.name() == QLatin1String("website")) {
24  config.setWebsite(xml.readElementText());
25  } else if (xml.name() == QLatin1String("host")) {
26  config.setHost(xml.readElementText());
27  } else if (xml.name() == QLatin1String("contact")) {
28  config.setContact(xml.readElementText());
29  } else if (xml.name() == QLatin1String("ssl")) {
30  config.setSsl(xml.readElementText() == QLatin1String("true"));
31  }
32  }
33 
34  if (xml.isEndElement() && xml.name() == QLatin1String("data")) {
35  break;
36  }
37  }
38 
39  return config;
40 }
41 
42 QStringList Config::Parser::xmlElement() const
43 {
44  return QStringList(QStringLiteral("data"));
45 }
bool isEndElement() const const
QStringRef name() const const
QXmlStreamReader::TokenType readNext()
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
KSharedConfigPtr config()
The Attica namespace,.
bool isStartElement() const const
bool atEnd() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:08:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.