Syndication

abstractparser.h
1/*
2 This file is part of the syndication library
3 SPDX-FileCopyrightText: 2005 Frank Osterfeld <osterfeld@kde.org>
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 "specificdocument.h"
12
13#include "syndication_export.h"
14
15class QString;
16
17namespace Syndication
18{
19class 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 */
27class SYNDICATION_EXPORT AbstractParser
28{
29public:
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
Interface for all parsers.
virtual QString format() const =0
Returns the name of the format supported by this parser.
virtual SpecificDocumentPtr parse(const DocumentSource &source) const =0
Lets the parser parse a document source.
virtual bool accept(const DocumentSource &source) const =0
Lets the parser check if it can parse the passed source.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:15 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.