Syndication

rss2/enclosure.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2005 Frank Osterfeld <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #include "enclosure.h"
9 
10 namespace Syndication
11 {
12 namespace RSS2
13 {
14 
16 {
17 }
18 
20 {
21 }
22 
24 {
25  return attribute(QStringLiteral("url"));
26 }
27 
28 int Enclosure::length() const
29 {
30  int length = 0;
31 
32  if (hasAttribute(QStringLiteral("length"))) {
33  bool ok;
34  int c = attribute(QStringLiteral("length")).toInt(&ok);
35  length = ok ? c : 0;
36  }
37  return length;
38 }
39 
41 {
42  return attribute(QStringLiteral("type"));
43 }
44 
46 {
47  QString info = QLatin1String("### Enclosure: ###################\n");
48  if (!url().isNull()) {
49  info += QLatin1String("url: #") + url() + QLatin1String("#\n");
50  }
51  if (!type().isNull()) {
52  info += QLatin1String("type: #") + type() + QLatin1String("#\n");
53  }
54  if (length() != -1) {
55  info += QLatin1String("length: #") + QString::number(length()) + QLatin1String("#\n");
56  }
57  info += QLatin1String("### Enclosure end ################\n");
58  return info;
59 }
60 
61 } // namespace RSS2
62 } // namespace Syndication
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
A wrapper for XML elements.
bool hasAttribute(const QString &name) const
Returns true if this element has an attribute called name; otherwise returns false.
Enclosure()
Default constructor, creates a null object, for which isNull() is true.
QString number(int n, int base)
QString url() const
returns the URL of the enclosure
int toInt(bool *ok, int base) const const
QString type() const
returns the mime type of the enclosure (e.g.
bool isNull() const
returns whether the wrapped element is a null element
QString debugInfo() const
Returns a description of the object for debugging purposes.
const QDomElement & element() const
returns the wrapped resource.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Aug 3 2020 23:01:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.