File indexing completed on 2023-09-24 04:15:36

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()
0062 {
0063     delete d;
0064 }
0065 
0066 RSSVocab *RSSVocab::self()
0067 {
0068     static RSSVocabPrivate p;
0069     if (!p.sSelf) {
0070         p.sSelf = new RSSVocab;
0071         qAddPostRoutine(RSSVocabPrivate::cleanupRSSVocab);
0072     }
0073     return p.sSelf;
0074 }
0075 
0076 const QString &RSSVocab::namespaceURI() const
0077 {
0078     return d->namespaceURI;
0079 }
0080 
0081 PropertyPtr RSSVocab::title() const
0082 {
0083     return d->title;
0084 }
0085 
0086 PropertyPtr RSSVocab::description() const
0087 {
0088     return d->description;
0089 }
0090 
0091 PropertyPtr RSSVocab::link() const
0092 {
0093     return d->link;
0094 }
0095 
0096 PropertyPtr RSSVocab::name() const
0097 {
0098     return d->name;
0099 }
0100 
0101 PropertyPtr RSSVocab::url() const
0102 {
0103     return d->url;
0104 }
0105 
0106 PropertyPtr RSSVocab::image() const
0107 {
0108     return d->image;
0109 }
0110 
0111 PropertyPtr RSSVocab::textinput() const
0112 {
0113     return d->textinput;
0114 }
0115 
0116 PropertyPtr RSSVocab::items() const
0117 {
0118     return d->items;
0119 }
0120 
0121 ResourcePtr RSSVocab::item() const
0122 {
0123     return d->item;
0124 }
0125 
0126 ResourcePtr RSSVocab::channel() const
0127 {
0128     return d->channel;
0129 }
0130 
0131 class SYNDICATION_NO_EXPORT RSS09Vocab::RSS09VocabPrivate
0132 {
0133 public:
0134     QString namespaceURI;
0135     PropertyPtr title;
0136     PropertyPtr link;
0137     PropertyPtr description;
0138     PropertyPtr name;
0139     PropertyPtr url;
0140     PropertyPtr image;
0141     ResourcePtr channel;
0142     ResourcePtr item;
0143     PropertyPtr textinput;
0144     QStringList properties;
0145     QStringList classes;
0146 
0147     static RSS09Vocab *sSelf;
0148     static void cleanupRSS09Vocab()
0149     {
0150         delete sSelf;
0151         sSelf = nullptr;
0152     }
0153 };
0154 RSS09Vocab *RSS09Vocab::RSS09VocabPrivate::sSelf = nullptr;
0155 
0156 RSS09Vocab::RSS09Vocab()
0157     : d(new RSS09VocabPrivate)
0158 {
0159     QString ns = QStringLiteral("http://my.netscape.com/rdf/simple/0.9/");
0160 
0161     d->namespaceURI = ns;
0162 
0163     d->title = PropertyPtr(new Property(ns + QLatin1String("title")));
0164     d->properties.append(d->title->uri());
0165     d->link = PropertyPtr(new Property(ns + QLatin1String("link")));
0166     d->properties.append(d->link->uri());
0167     d->description = PropertyPtr(new Property(ns + QLatin1String("description")));
0168     d->properties.append(d->description->uri());
0169     d->name = PropertyPtr(new Property(ns + QLatin1String("name")));
0170     d->properties.append(d->name->uri());
0171     d->url = PropertyPtr(new Property(ns + QLatin1String("url")));
0172     d->properties.append(d->url->uri());
0173     d->image = PropertyPtr(new Property(ns + QLatin1String("image")));
0174     d->properties.append(d->image->uri());
0175     d->textinput = PropertyPtr(new Property(ns + QLatin1String("textinput")));
0176     d->properties.append(d->textinput->uri());
0177     d->item = ResourcePtr(new Resource(ns + QLatin1String("item")));
0178     d->classes.append(d->item->uri());
0179     d->channel = ResourcePtr(new Resource(ns + QLatin1String("channel")));
0180     d->classes.append(d->channel->uri());
0181 }
0182 
0183 RSS09Vocab::~RSS09Vocab()
0184 {
0185     delete d;
0186 }
0187 
0188 RSS09Vocab *RSS09Vocab::self()
0189 {
0190     if (!RSS09VocabPrivate::sSelf) {
0191         RSS09VocabPrivate::sSelf = new RSS09Vocab;
0192         qAddPostRoutine(RSS09VocabPrivate::cleanupRSS09Vocab);
0193     }
0194     return RSS09VocabPrivate::sSelf;
0195 }
0196 
0197 const QString &RSS09Vocab::namespaceURI() const
0198 {
0199     return d->namespaceURI;
0200 }
0201 
0202 PropertyPtr RSS09Vocab::title() const
0203 {
0204     return d->title;
0205 }
0206 
0207 PropertyPtr RSS09Vocab::description() const
0208 {
0209     return d->description;
0210 }
0211 
0212 PropertyPtr RSS09Vocab::link() const
0213 {
0214     return d->link;
0215 }
0216 
0217 PropertyPtr RSS09Vocab::name() const
0218 {
0219     return d->name;
0220 }
0221 
0222 PropertyPtr RSS09Vocab::url() const
0223 {
0224     return d->url;
0225 }
0226 
0227 PropertyPtr RSS09Vocab::image() const
0228 {
0229     return d->image;
0230 }
0231 
0232 PropertyPtr RSS09Vocab::textinput() const
0233 {
0234     return d->textinput;
0235 }
0236 
0237 ResourcePtr RSS09Vocab::item() const
0238 {
0239     return d->item;
0240 }
0241 
0242 ResourcePtr RSS09Vocab::channel() const
0243 {
0244     return d->channel;
0245 }
0246 
0247 QStringList RSS09Vocab::classes() const
0248 {
0249     return d->classes;
0250 }
0251 
0252 QStringList RSS09Vocab::properties() const
0253 {
0254     return d->properties;
0255 }
0256 
0257 } // namespace RDF
0258 } // namespace Syndication