1 | /* |
---|---|
2 | This file is part of the syndication library |
3 | SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #include "feedrss2impl.h" |
9 | #include "categoryrss2impl.h" |
10 | #include "imagerss2impl.h" |
11 | #include "itemrss2impl.h" |
12 | #include <personimpl.h> |
13 | #include <rss2/category.h> |
14 | #include <rss2/item.h> |
15 | |
16 | #include <QDomElement> |
17 | #include <QList> |
18 | #include <QMultiMap> |
19 | #include <QString> |
20 | |
21 | namespace Syndication |
22 | { |
23 | FeedRSS2Impl::FeedRSS2Impl(Syndication::RSS2::DocumentPtr doc) |
24 | : m_doc(doc) |
25 | { |
26 | } |
27 | |
28 | Syndication::SpecificDocumentPtr FeedRSS2Impl::specificDocument() const |
29 | { |
30 | return m_doc; |
31 | } |
32 | |
33 | QList<Syndication::ItemPtr> FeedRSS2Impl::items() const |
34 | { |
35 | const QList<Syndication::RSS2::Item> entries = m_doc->items(); |
36 | |
37 | QList<ItemPtr> items; |
38 | items.reserve(asize: entries.count()); |
39 | |
40 | std::transform(first: entries.cbegin(), last: entries.cend(), result: std::back_inserter(x&: items), unary_op: [](const Syndication::RSS2::Item &entry) { |
41 | return ItemRSS2ImplPtr(new ItemRSS2Impl(entry)); |
42 | }); |
43 | |
44 | return items; |
45 | } |
46 | |
47 | QList<Syndication::CategoryPtr> FeedRSS2Impl::categories() const |
48 | { |
49 | const QList<Syndication::RSS2::Category> entries = m_doc->categories(); |
50 | |
51 | QList<CategoryPtr> categories; |
52 | categories.reserve(asize: entries.count()); |
53 | |
54 | std::transform(first: entries.cbegin(), last: entries.cend(), result: std::back_inserter(x&: categories), unary_op: [](const Syndication::RSS2::Category &entry) { |
55 | return CategoryRSS2ImplPtr(new CategoryRSS2Impl(entry)); |
56 | }); |
57 | |
58 | return categories; |
59 | } |
60 | |
61 | QString FeedRSS2Impl::title() const |
62 | { |
63 | return m_doc->title(); |
64 | } |
65 | |
66 | QString FeedRSS2Impl::link() const |
67 | { |
68 | return m_doc->link(); |
69 | } |
70 | |
71 | QString FeedRSS2Impl::description() const |
72 | { |
73 | return m_doc->description(); |
74 | } |
75 | |
76 | QList<PersonPtr> FeedRSS2Impl::authors() const |
77 | { |
78 | return QList<PersonPtr>(); |
79 | } |
80 | |
81 | QString FeedRSS2Impl::language() const |
82 | { |
83 | return m_doc->language(); |
84 | } |
85 | |
86 | QString FeedRSS2Impl::copyright() const |
87 | { |
88 | return m_doc->copyright(); |
89 | } |
90 | |
91 | ImagePtr FeedRSS2Impl::image() const |
92 | { |
93 | ImageRSS2ImplPtr ptr(new ImageRSS2Impl(m_doc->image())); |
94 | return ptr; |
95 | } |
96 | |
97 | QMultiMap<QString, QDomElement> FeedRSS2Impl::additionalProperties() const |
98 | { |
99 | QMultiMap<QString, QDomElement> ret; |
100 | |
101 | const auto unhandledElements = m_doc->unhandledElements(); |
102 | for (const QDomElement &i : unhandledElements) { |
103 | ret.insert(key: i.namespaceURI() + i.localName(), value: i); |
104 | } |
105 | |
106 | return ret; |
107 | } |
108 | |
109 | ImagePtr FeedRSS2Impl::icon() const |
110 | { |
111 | ImageRSS2ImplPtr ptr(new ImageRSS2Impl({})); |
112 | return ptr; |
113 | } |
114 | |
115 | } // namespace Syndication |
116 |