Syndication

rss2/enclosure.cpp
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{
18
20 : ElementWrapper(element)
21{
22}
23
25{
26 return attribute(QStringLiteral("url"));
27}
28
30{
31 int length = 0;
32
33 if (hasAttribute(QStringLiteral("length"))) {
34 bool ok;
35 int c = attribute(QStringLiteral("length")).toInt(&ok);
36 length = ok ? c : 0;
37 }
38 return length;
39}
40
42{
43 return attribute(QStringLiteral("type"));
44}
45
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
A wrapper for XML elements.
bool isNull() const
returns whether the wrapped element is a null element
bool hasAttribute(const QString &name) const
Returns true if this element has an attribute called name; otherwise returns false.
QString attribute(const QString &name, const QString &defValue=QString()) const
Returns the attribute called name.
int length() const
returns the size of the enclosure in bytes
QString url() const
returns the URL of the enclosure
QString type() const
returns the mime type of the enclosure (e.g.
Enclosure()
Default constructor, creates a null object, for which isNull() is true.
QString debugInfo() const
Returns a description of the object for debugging purposes.
QString number(double n, char format, int precision)
int toInt(bool *ok, int base) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:02:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.