Syndication

global.cpp
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2006 Frank Osterfeld <[email protected]>
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 
21 namespace
22 {
23 static bool collectionIsInitialized = false;
24 }
25 
26 namespace Syndication
27 {
28 static ParserCollectionImpl<Syndication::Feed> *parserColl = nullptr;
29 
30 namespace
31 {
32 // only executed when then was a QCoreApplication
33 static 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 
54 FeedPtr parse(const DocumentSource &src, const QString &formatHint)
55 {
56  return parserCollection()->parse(src, formatHint);
57 }
58 
59 } // namespace Syndication
Parser implementation for RDF-based RSS 0.9 and RSS 1.0 feeds.
Definition: rdf/parser.h:25
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
Represents the source of a syndication document, as read from the downloaded file.
A collection of format-specific parser implementations.
Definition: global.h:21
ParserCollection< Feed > * parserCollection()
The default ParserCollection instance parsing a DocumentSource into a Feed object.
Definition: global.cpp:41
Parser implementation for the RSS 0.9x/2.0 format family.
Definition: rss2/parser.h:27
parser implementation for Atom 1.0 and 0.3.
Definition: atom/parser.h:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 19 2021 23:04:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.