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 "mapper/mapperatomimpl.h"
13 #include "mapper/mapperrdfimpl.h"
14 #include "mapper/mapperrss2impl.h"
15 #include "atom/parser.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 
29 static ParserCollectionImpl<Syndication::Feed> *parserColl = nullptr;
30 
31 namespace
32 {
33 
34 // only executed when then was a QCoreApplication
35 static void cleanupParserCollection()
36 {
37  delete parserColl;
38  parserColl = nullptr;
39 }
40 
41 } // namespace
42 
44 {
45  if (!collectionIsInitialized) {
46  parserColl = new ParserCollectionImpl<Syndication::Feed>;
47  qAddPostRoutine(cleanupParserCollection);
48  parserColl->registerParser(new RSS2::Parser, new RSS2Mapper);
49  parserColl->registerParser(new Atom::Parser, new AtomMapper);
50  parserColl->registerParser(new RDF::Parser, new RDFMapper);
51  collectionIsInitialized = true;
52  }
53  return parserColl;
54 }
55 
56 FeedPtr parse(const DocumentSource &src, const QString &formatHint)
57 {
58  return parserCollection()->parse(src, formatHint);
59 }
60 
61 } // namespace Syndication
62 
Parser implementation for RDF-based RSS 0.9 and RSS 1.0 feeds.
Definition: rdf/parser.h:27
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:56
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:43
Parser implementation for the RSS 0.9x/2.0 format family.
Definition: rss2/parser.h:29
parser implementation for Atom 1.0 and 0.3.
Definition: atom/parser.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 04:01:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.