• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

Syndication Library

  • Syndication
  • ParserCollection
Public Member Functions
Syndication::ParserCollection< T > Class Template Reference

#include <parsercollection.h>

List of all members.

Public Member Functions

virtual ~ParserCollection ()
virtual void changeMapper (const QString &format, Mapper< T > *mapper)=0
virtual ErrorCode lastError () const =0
virtual boost::shared_ptr< T > parse (const DocumentSource &source, const QString &formatHint=QString())=0
virtual bool registerParser (AbstractParser *parser, Mapper< T > *mapper)=0

Detailed Description

template<class T>
class Syndication::ParserCollection< T >

A collection of format-specific parser implementations.

To parse a feed source, pass it to the parse() method of this class. In most cases, you should use the global singleton instance Syndication::parserCollection(). When loading the source from the web, use Loader instead of using this class directly.

Example code:

...
QFile someFile(somePath);
...
DocumentSource src(someFile.readAll());
someFile.close();
FeedPtr feed = parserCollection()->parse(src);
if (feed)
{
QString title = feed->title();
QList<ItemPtr> items = feed->items();
...
}

The template parameter T is the abstraction class parsed documents should be mapped to. If you want to use your own abstraction MyFeed, implement ParserCollection<MyFeed> (Note that you have to provide mapper implementations for every feed format then).

Author:
Frank Osterfeld

Definition at line 73 of file parsercollection.h.


Constructor & Destructor Documentation

template<class T >
virtual Syndication::ParserCollection< T >::~ParserCollection ( )
inlinevirtual

destructor

Definition at line 78 of file parsercollection.h.


Member Function Documentation

template<class T >
virtual void Syndication::ParserCollection< T >::changeMapper ( const QString &  format,
Mapper< T > *  mapper 
)
pure virtual

Changes the specific format to abstraction mapping for a parser.

Parameters:
formatthe format string of the parser whose mapping should be changed. See AbstractParser::format.
mapperMapper implementation doing the mapping from the format specific representation to abstraction of type T.
template<class T >
virtual ErrorCode Syndication::ParserCollection< T >::lastError ( ) const
pure virtual

returns the error code of the last parse() call.

Returns:
the last error, or Success if parse() was successful or not yet called at all.
template<class T >
virtual boost::shared_ptr<T> Syndication::ParserCollection< T >::parse ( const DocumentSource &  source,
const QString &  formatHint = QString() 
)
pure virtual

tries to parse a given source with the parsers registered.

The source is passed to the first parser that accepts it.

Parameters:
sourceThe source to be parsed
formatHintAn optional hint which parser to test first. If there is a parser with the given hint as format string (e.g., "rss2", "atom", "rdf"...), it is asked first to accept the source. This can avoid unnecessary AbstractParser::accept() checks and speed up parsing. See also AbstractParser::format().
Returns:
The feed document parsed from the source, or NULL if no parser accepted the source.
template<class T >
virtual bool Syndication::ParserCollection< T >::registerParser ( AbstractParser *  parser,
Mapper< T > *  mapper 
)
pure virtual

Adds a parser and corresponding mapper to the collection.

AbstractParser::format() must be unique in the collection. If there is already a parser with the same format string, the parser isn't added.

Note:
ownership for both parser and mapper is taken by the implementation, so don't delete them in your code!
Parameters:
parserThe parser to be registered
mapperthe mapper that should be used for building the abstraction
Returns:
whether the parser was successfully registered or not.

The documentation for this class was generated from the following file:
  • parsercollection.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Wed Jul 24 2013 01:05:45 by doxygen 1.8.1.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Syndication Library

Skip menu "Syndication Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal