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 {
15  : ElementWrapper()
16 {
17 }
18 
20  : ElementWrapper(element)
21 {
22 }
23 
25 {
26  return attribute(QStringLiteral("url"));
27 }
28 
29 int 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);
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
QString number(int n, int base)
QString type() const
returns the mime type of the enclosure (e.g.
QString url() const
returns the URL of the enclosure
Enclosure()
Default constructor, creates a null object, for which isNull() is true.
QString debugInfo() const
Returns a description of the object for debugging purposes.
int length() const
returns the size of the enclosure in bytes
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:57:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.