Syndication

feedrss2impl.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2006 Frank Osterfeld <[email protected]>
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 
34 {
35  const QList<Syndication::RSS2::Item> entries = m_doc->items();
36 
38  items.reserve(entries.count());
39 
40  std::transform(entries.cbegin(), entries.cend(), std::back_inserter(items), [](const Syndication::RSS2::Item &entry) {
41  return ItemRSS2ImplPtr(new ItemRSS2Impl(entry));
42  });
43 
44  return items;
45 }
46 
48 {
49  const QList<Syndication::RSS2::Category> entries = m_doc->categories();
50 
52  categories.reserve(entries.count());
53 
54  std::transform(entries.cbegin(), entries.cend(), std::back_inserter(categories), [](const Syndication::RSS2::Category &entry) {
55  return CategoryRSS2ImplPtr(new CategoryRSS2Impl(entry));
56  });
57 
58  return categories;
59 }
60 
62 {
63  return m_doc->title();
64 }
65 
67 {
68  return m_doc->link();
69 }
70 
72 {
73  return m_doc->description();
74 }
75 
77 {
78  return QList<PersonPtr>();
79 }
80 
82 {
83  return m_doc->language();
84 }
85 
87 {
88  return m_doc->copyright();
89 }
90 
92 {
93  ImageRSS2ImplPtr ptr(new ImageRSS2Impl(m_doc->image()));
94  return ptr;
95 }
96 
98 {
100 
101  const auto unhandledElements = m_doc->unhandledElements();
102  for (const QDomElement &i : unhandledElements) {
103  ret.insert(i.namespaceURI() + i.localName(), i);
104  }
105 
106  return ret;
107 }
108 
110 {
111  ImageRSS2ImplPtr ptr(new ImageRSS2Impl({}));
112  return ptr;
113 }
114 
115 } // namespace Syndication
QList< CategoryPtr > categories() const override
returns a list of categories this feed is associated with.
Definition: feed.h:20
A category which can be assigned to items or whole feeds.
Definition: rss2/category.h:27
QString link() const override
returns a link pointing to a website associated with this channel.
int count(const T &value) const const
ImagePtr icon() const override
returns an icon associated with this item.
QMultiMap< QString, QDomElement > additionalProperties() const override
returns a list of feed metadata not covered by this class.
QList< PersonPtr > authors() const override
returns a list of persons who created the feed content.
QString description() const override
A description of the feed.
ImagePtr image() const override
returns an image associated with this item.
QString title() const override
The title of the feed.
QList::const_iterator cend() const const
typename QMap< Key, T >::iterator insert(const Key &key, const T &value)
QString language() const override
The language used in the feed.
QList::const_iterator cbegin() const const
QString copyright() const override
returns copyright information about the feed
Syndication::SpecificDocumentPtr specificDocument() const override
returns the format-specific document this abstraction wraps.
QList< ItemPtr > items() const override
A list of items, in the order they were parsed from the feed source.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Dec 8 2023 03:50:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.