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
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
const QDomElement & element() const
returns the wrapped resource.
ElementWrapper()
creates a element wrapper wrapping a null element.
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.
A parser and model classes for RSS 0.91 (Userland and Netscape flavor), 0.92, 0.93,...
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-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:48:38 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.