File indexing completed on 2024-04-14 03:58:24

0001 /*
0002     This file is part of the syndication library
0003     SPDX-FileCopyrightText: 2006 Frank Osterfeld <osterfeld@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #include "category.h"
0009 #include "constants.h"
0010 
0011 #include <QDomElement>
0012 #include <QString>
0013 
0014 namespace Syndication
0015 {
0016 namespace Atom
0017 {
0018 Category::Category()
0019     : ElementWrapper()
0020 {
0021 }
0022 
0023 Category::Category(const QDomElement &element)
0024     : ElementWrapper(element)
0025 {
0026 }
0027 
0028 QString Category::term() const
0029 {
0030     return attribute(QStringLiteral("term"));
0031 }
0032 
0033 QString Category::scheme() const
0034 {
0035     // NOTE: The scheme IRI is not completed by purpose.
0036     // According to Atom spec, it must be an absolute IRI.
0037     // If this is a problem with real-world feeds, it might be changed.
0038     return attribute(QStringLiteral("scheme"));
0039 }
0040 
0041 QString Category::label() const
0042 {
0043     return attribute(QStringLiteral("label"));
0044 }
0045 
0046 QString Category::debugInfo() const
0047 {
0048     QString info = QLatin1String("### Category: ###################\n");
0049     info += QLatin1String("term: #") + term() + QLatin1String("#\n");
0050     if (!scheme().isEmpty()) {
0051         info += QLatin1String("scheme: #") + scheme() + QLatin1String("#\n");
0052     }
0053     if (!label().isEmpty()) {
0054         info += QLatin1String("label: #") + label() + QLatin1String("#\n");
0055     }
0056     info += QLatin1String("### Category end ################\n");
0057 
0058     return info;
0059 }
0060 
0061 } // namespace Atom
0062 } // namespace Syndication