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 | |
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(document: 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() = default; |
58 | |
59 | Parser &Parser::operator=(const Parser & /*other*/) |
60 | { |
61 | return *this; |
62 | } |
63 | |
64 | } // namespace RSS2 |
65 | } // namespace Syndication |
66 |