1/*
2 This file is part of the syndication library
3 SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "link.h"
9#include "constants.h"
10
11#include <QString>
12
13namespace Syndication
14{
15namespace Atom
16{
17Link::Link()
18 : ElementWrapper()
19{
20}
21
22Link::Link(const QDomElement &element)
23 : ElementWrapper(element)
24{
25}
26
27QString Link::href() const
28{
29 return completeURI(uri: attribute(QStringLiteral("href")));
30}
31
32QString Link::rel() const
33{
34 //"alternate" is default
35 return attribute(QStringLiteral("rel"), QStringLiteral("alternate"));
36}
37
38QString Link::type() const
39{
40 return attribute(QStringLiteral("type"));
41}
42
43QString Link::hrefLanguage() const
44{
45 return attribute(QStringLiteral("hreflang"));
46}
47
48QString Link::title() const
49{
50 return attribute(QStringLiteral("title"));
51}
52
53uint Link::length() const
54{
55 QString lengthStr = attribute(QStringLiteral("length"));
56
57 bool ok;
58 uint c = lengthStr.toUInt(ok: &ok);
59 return ok ? c : 0;
60}
61
62QString Link::debugInfo() const
63{
64 QString info = QLatin1String("### Link: ###################\n");
65 if (!title().isEmpty()) {
66 info += QLatin1String("title: #") + title() + QLatin1String("#\n");
67 }
68 if (!href().isEmpty()) {
69 info += QLatin1String("href: #") + href() + QLatin1String("#\n");
70 }
71 if (!rel().isEmpty()) {
72 info += QLatin1String("rel: #") + rel() + QLatin1String("#\n");
73 }
74 if (!type().isEmpty()) {
75 info += QLatin1String("type: #") + type() + QLatin1String("#\n");
76 }
77 if (length() != 0) {
78 info += QLatin1String("length: #") + QString::number(length()) + QLatin1String("#\n");
79 }
80 if (!hrefLanguage().isEmpty()) {
81 info += QLatin1String("hrefLanguage: #") + hrefLanguage() + QLatin1String("#\n");
82 }
83 info += QLatin1String("### Link end ################\n");
84 return info;
85}
86
87} // namespace Atom
88} // namespace Syndication
89

source code of syndication/src/atom/link.cpp