Syndication

abstractparser.h
1 /*
2  This file is part of the syndication library
3  SPDX-FileCopyrightText: 2005 Frank Osterfeld <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef SYNDICATION_ABSTRACTPARSER_H
9 #define SYNDICATION_ABSTRACTPARSER_H
10 
11 #include <syndication/specificdocument.h>
12 
13 #include "syndication_export.h"
14 
15 class QString;
16 
17 namespace Syndication
18 {
19 class DocumentSource;
20 
21 /**
22  * Interface for all parsers. The parsers for the various formats must
23  * implement this interface and register themselves at the ParserRegistry.
24  *
25  * @author Frank Osterfeld
26  */
27 class SYNDICATION_EXPORT AbstractParser
28 {
29 public:
30  /**
31  * virtual destructor
32  */
33  virtual ~AbstractParser();
34 
35  /**
36  * Lets the parser check if it can parse the passed source.
37  * Parser implementations should do a _quick_ check for the file
38  * format (i.e. check for feed format and version number in the root
39  * element) to find out if the source is in a supported format. They
40  * should _not_ completely parse the document to test for full
41  * compliance to the format specification.
42  *
43  * @param source the document source to be checked
44  * @return whether @c source seems to be in a format supported by the
45  * parser
46  */
47  virtual bool accept(const DocumentSource &source) const = 0;
48 
49  /**
50  * Lets the parser parse a document source. The parser returns a
51  * valid document instance if successful, or an invalid one if
52  * not.
53  *
54  * @see SpecificDocument::isValid()
55  * @param source The document source to be parsed
56  * @return a newly created document parsed from @c source
57  */
58  virtual SpecificDocumentPtr parse(const DocumentSource &source) const = 0;
59 
60  /**
61  * Returns the name of the format supported by this
62  * parser.
63  *
64  * @return a string like "rss2", "atom" or "rdf"
65  */
66  virtual QString format() const = 0;
67 };
68 
69 } // namespace Syndication
70 
71 #endif // SYNDICATION_ABSTRACTPARSER_H
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.
Interface for all parsers.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Nov 29 2021 22:54:35 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.