Syndication

rss2/parser.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2005 Frank Osterfeld <[email protected]>
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 
16 namespace Syndication
17 {
18 namespace RSS2
19 {
20 class SYNDICATION_NO_EXPORT Parser::ParserPrivate
21 {
22 };
23 
24 bool 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 
36 Syndication::SpecificDocumentPtr Parser::parse(const DocumentSource &source) const
37 {
38  return DocumentPtr(new Document(Document::fromXML(source.asDomDocument())));
39 }
40 
41 QString Parser::format() const
42 {
43  return QStringLiteral("rss2");
44 }
45 
46 Parser::Parser()
47  : d(nullptr)
48 {
49  Q_UNUSED(d) // silence -Wunused-private-field
50 }
51 
52 Parser::Parser(const Parser &other)
53  : AbstractParser(other)
54  , d(nullptr)
55 {
56 }
57 Parser::~Parser()
58 {
59 }
60 Parser &Parser::operator=(const Parser & /*other*/)
61 {
62  return *this;
63 }
64 
65 } // namespace RSS2
66 } // namespace Syndication
QDomElement toElement() const const
bool isNull() const const
QDomNode namedItem(const QString &name) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 1 2023 03:52:05 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.