File indexing completed on 2024-07-14 03:59:04

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 "rssvocab.h"
0009 #include "property.h"
0010 
0011 #include <QCoreApplication>
0012 #include <QString>
0013 
0014 namespace Syndication
0015 {
0016 namespace RDF
0017 {
0018 class SYNDICATION_NO_EXPORT RSSVocab::RSSVocabPrivate
0019 {
0020 public:
0021     QString namespaceURI;
0022     PropertyPtr title;
0023     PropertyPtr link;
0024     PropertyPtr description;
0025     PropertyPtr name;
0026     PropertyPtr url;
0027     PropertyPtr image;
0028     ResourcePtr channel;
0029     ResourcePtr item;
0030     PropertyPtr items;
0031     PropertyPtr textinput;
0032 
0033     static RSSVocab *sSelf;
0034     static void cleanupRSSVocab()
0035     {
0036         delete sSelf;
0037         sSelf = nullptr;
0038     }
0039 };
0040 RSSVocab *RSSVocab::RSSVocabPrivate::sSelf = nullptr;
0041 
0042 RSSVocab::RSSVocab()
0043     : d(new RSSVocabPrivate)
0044 {
0045     QString ns = QStringLiteral("http://purl.org/rss/1.0/");
0046 
0047     d->namespaceURI = ns;
0048 
0049     d->title = PropertyPtr(new Property(ns + QLatin1String("title")));
0050     d->link = PropertyPtr(new Property(ns + QLatin1String("link")));
0051     d->description = PropertyPtr(new Property(ns + QLatin1String("description")));
0052     d->name = PropertyPtr(new Property(ns + QLatin1String("name")));
0053     d->url = PropertyPtr(new Property(ns + QLatin1String("url")));
0054     d->image = PropertyPtr(new Property(ns + QLatin1String("image")));
0055     d->textinput = PropertyPtr(new Property(ns + QLatin1String("textinput")));
0056     d->items = PropertyPtr(new Property(ns + QLatin1String("items")));
0057     d->channel = ResourcePtr(new Resource(ns + QLatin1String("channel")));
0058     d->item = ResourcePtr(new Resource(ns + QLatin1String("item")));
0059 }
0060 
0061 RSSVocab::~RSSVocab() = default;
0062 
0063 RSSVocab *RSSVocab::self()
0064 {
0065     static RSSVocabPrivate p;
0066     if (!p.sSelf) {
0067         p.sSelf = new RSSVocab;
0068         qAddPostRoutine(RSSVocabPrivate::cleanupRSSVocab);
0069     }
0070     return p.sSelf;
0071 }
0072 
0073 const QString &RSSVocab::namespaceURI() const
0074 {
0075     return d->namespaceURI;
0076 }
0077 
0078 PropertyPtr RSSVocab::title() const
0079 {
0080     return d->title;
0081 }
0082 
0083 PropertyPtr RSSVocab::description() const
0084 {
0085     return d->description;
0086 }
0087 
0088 PropertyPtr RSSVocab::link() const
0089 {
0090     return d->link;
0091 }
0092 
0093 PropertyPtr RSSVocab::name() const
0094 {
0095     return d->name;
0096 }
0097 
0098 PropertyPtr RSSVocab::url() const
0099 {
0100     return d->url;
0101 }
0102 
0103 PropertyPtr RSSVocab::image() const
0104 {
0105     return d->image;
0106 }
0107 
0108 PropertyPtr RSSVocab::textinput() const
0109 {
0110     return d->textinput;
0111 }
0112 
0113 PropertyPtr RSSVocab::items() const
0114 {
0115     return d->items;
0116 }
0117 
0118 ResourcePtr RSSVocab::item() const
0119 {
0120     return d->item;
0121 }
0122 
0123 ResourcePtr RSSVocab::channel() const
0124 {
0125     return d->channel;
0126 }
0127 
0128 class SYNDICATION_NO_EXPORT RSS09Vocab::RSS09VocabPrivate
0129 {
0130 public:
0131     QString namespaceURI;
0132     PropertyPtr title;
0133     PropertyPtr link;
0134     PropertyPtr description;
0135     PropertyPtr name;
0136     PropertyPtr url;
0137     PropertyPtr image;
0138     ResourcePtr channel;
0139     ResourcePtr item;
0140     PropertyPtr textinput;
0141     QStringList properties;
0142     QStringList classes;
0143 
0144     static RSS09Vocab *sSelf;
0145     static void cleanupRSS09Vocab()
0146     {
0147         delete sSelf;
0148         sSelf = nullptr;
0149     }
0150 };
0151 RSS09Vocab *RSS09Vocab::RSS09VocabPrivate::sSelf = nullptr;
0152 
0153 RSS09Vocab::RSS09Vocab()
0154     : d(new RSS09VocabPrivate)
0155 {
0156     QString ns = QStringLiteral("http://my.netscape.com/rdf/simple/0.9/");
0157 
0158     d->namespaceURI = ns;
0159 
0160     d->title = PropertyPtr(new Property(ns + QLatin1String("title")));
0161     d->properties.append(d->title->uri());
0162     d->link = PropertyPtr(new Property(ns + QLatin1String("link")));
0163     d->properties.append(d->link->uri());
0164     d->description = PropertyPtr(new Property(ns + QLatin1String("description")));
0165     d->properties.append(d->description->uri());
0166     d->name = PropertyPtr(new Property(ns + QLatin1String("name")));
0167     d->properties.append(d->name->uri());
0168     d->url = PropertyPtr(new Property(ns + QLatin1String("url")));
0169     d->properties.append(d->url->uri());
0170     d->image = PropertyPtr(new Property(ns + QLatin1String("image")));
0171     d->properties.append(d->image->uri());
0172     d->textinput = PropertyPtr(new Property(ns + QLatin1String("textinput")));
0173     d->properties.append(d->textinput->uri());
0174     d->item = ResourcePtr(new Resource(ns + QLatin1String("item")));
0175     d->classes.append(d->item->uri());
0176     d->channel = ResourcePtr(new Resource(ns + QLatin1String("channel")));
0177     d->classes.append(d->channel->uri());
0178 }
0179 
0180 RSS09Vocab::~RSS09Vocab() = default;
0181 
0182 RSS09Vocab *RSS09Vocab::self()
0183 {
0184     if (!RSS09VocabPrivate::sSelf) {
0185         RSS09VocabPrivate::sSelf = new RSS09Vocab;
0186         qAddPostRoutine(RSS09VocabPrivate::cleanupRSS09Vocab);
0187     }
0188     return RSS09VocabPrivate::sSelf;
0189 }
0190 
0191 const QString &RSS09Vocab::namespaceURI() const
0192 {
0193     return d->namespaceURI;
0194 }
0195 
0196 PropertyPtr RSS09Vocab::title() const
0197 {
0198     return d->title;
0199 }
0200 
0201 PropertyPtr RSS09Vocab::description() const
0202 {
0203     return d->description;
0204 }
0205 
0206 PropertyPtr RSS09Vocab::link() const
0207 {
0208     return d->link;
0209 }
0210 
0211 PropertyPtr RSS09Vocab::name() const
0212 {
0213     return d->name;
0214 }
0215 
0216 PropertyPtr RSS09Vocab::url() const
0217 {
0218     return d->url;
0219 }
0220 
0221 PropertyPtr RSS09Vocab::image() const
0222 {
0223     return d->image;
0224 }
0225 
0226 PropertyPtr RSS09Vocab::textinput() const
0227 {
0228     return d->textinput;
0229 }
0230 
0231 ResourcePtr RSS09Vocab::item() const
0232 {
0233     return d->item;
0234 }
0235 
0236 ResourcePtr RSS09Vocab::channel() const
0237 {
0238     return d->channel;
0239 }
0240 
0241 QStringList RSS09Vocab::classes() const
0242 {
0243     return d->classes;
0244 }
0245 
0246 QStringList RSS09Vocab::properties() const
0247 {
0248     return d->properties;
0249 }
0250 
0251 } // namespace RDF
0252 } // namespace Syndication