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 "enclosure.h"
9
10namespace Syndication
11{
12namespace RSS2
13{
14Enclosure::Enclosure()
15 : ElementWrapper()
16{
17}
18
19Enclosure::Enclosure(const QDomElement &element)
20 : ElementWrapper(element)
21{
22}
23
24QString Enclosure::url() const
25{
26 return attribute(QStringLiteral("url"));
27}
28
29int Enclosure::length() const
30{
31 int length = 0;
32
33 if (hasAttribute(QStringLiteral("length"))) {
34 bool ok;
35 int c = attribute(QStringLiteral("length")).toInt(ok: &ok);
36 length = ok ? c : 0;
37 }
38 return length;
39}
40
41QString Enclosure::type() const
42{
43 return attribute(QStringLiteral("type"));
44}
45
46QString Enclosure::debugInfo() const
47{
48 QString info = QLatin1String("### Enclosure: ###################\n");
49 if (!url().isNull()) {
50 info += QLatin1String("url: #") + url() + QLatin1String("#\n");
51 }
52 if (!type().isNull()) {
53 info += QLatin1String("type: #") + type() + QLatin1String("#\n");
54 }
55 if (length() != -1) {
56 info += QLatin1String("length: #") + QString::number(length()) + QLatin1String("#\n");
57 }
58 info += QLatin1String("### Enclosure end ################\n");
59 return info;
60}
61
62} // namespace RSS2
63} // namespace Syndication
64

source code of syndication/src/rss2/enclosure.cpp