Syndication

rss2/parser.cpp
1/*
2 This file is part of the syndication library
3 SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "parser.h"
9#include "document.h"
10
11#include <documentsource.h>
12
13#include <QDomDocument>
14#include <QString>
15
16namespace Syndication
17{
18namespace RSS2
19{
20class SYNDICATION_NO_EXPORT Parser::ParserPrivate
21{
22};
23
24bool Parser::accept(const Syndication::DocumentSource &source) const
25{
26 QDomDocument doc = source.asDomDocument();
27 if (doc.isNull()) {
28 return false;
29 }
30
31 QDomNode root = doc.namedItem(QStringLiteral("rss")).toElement();
32
33 return !root.isNull();
34}
35
36Syndication::SpecificDocumentPtr Parser::parse(const DocumentSource &source) const
37{
38 return DocumentPtr(new Document(Document::fromXML(source.asDomDocument())));
39}
40
41QString Parser::format() const
42{
43 return QStringLiteral("rss2");
44}
45
46Parser::Parser()
47 : d(nullptr)
48{
49 Q_UNUSED(d) // silence -Wunused-private-field
50}
51
52Parser::Parser(const Parser &other)
53 : AbstractParser(other)
54 , d(nullptr)
55{
56}
57Parser::~Parser() = default;
58
59Parser &Parser::operator=(const Parser & /*other*/)
60{
61 return *this;
62}
63
64} // namespace RSS2
65} // namespace Syndication
bool isNull() const const
QDomNode namedItem(const QString &name) const const
QDomElement toElement() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:15 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.