Syndication

global.cpp
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 "global.h"
9#include "documentsource.h"
10#include "parsercollectionimpl.h"
11
12#include "atom/parser.h"
13#include "mapper/mapperatomimpl.h"
14#include "mapper/mapperrdfimpl.h"
15#include "mapper/mapperrss2impl.h"
16#include "rdf/parser.h"
17#include "rss2/parser.h"
18
19#include <QCoreApplication>
20
21namespace
22{
23static bool collectionIsInitialized = false;
24}
25
26namespace Syndication
27{
28static ParserCollectionImpl<Syndication::Feed> *parserColl = nullptr;
29
30namespace
31{
32// only executed when then was a QCoreApplication
33static void cleanupParserCollection()
34{
35 delete parserColl;
36 parserColl = nullptr;
37}
38
39} // namespace
40
42{
43 if (!collectionIsInitialized) {
44 parserColl = new ParserCollectionImpl<Syndication::Feed>;
45 qAddPostRoutine(cleanupParserCollection);
46 parserColl->registerParser(new RSS2::Parser, new RSS2Mapper);
47 parserColl->registerParser(new Atom::Parser, new AtomMapper);
48 parserColl->registerParser(new RDF::Parser, new RDFMapper);
49 collectionIsInitialized = true;
50 }
51 return parserColl;
52}
53
54FeedPtr parse(const DocumentSource &src, const QString &formatHint)
55{
56 return parserCollection()->parse(src, formatHint);
57}
58
59} // namespace Syndication
parser implementation for Atom 1.0 and 0.3.
Definition atom/parser.h:32
Represents the source of a syndication document, as read from the downloaded file.
A collection of format-specific parser implementations.
Parser implementation for RDF-based RSS 0.9 and RSS 1.0 feeds.
Definition rdf/parser.h:28
Parser implementation for the RSS 0.9x/2.0 format family.
Definition rss2/parser.h:30
ParserCollection< Feed > * parserCollection()
The default ParserCollection instance parsing a DocumentSource into a Feed object.
Definition global.cpp:41
FeedPtr parse(const DocumentSource &src, const QString &formatHint)
parses a document from a source and returns a new Feed object wrapping the feed content.
Definition global.cpp:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.