Search for usage in LXR

Syndication::DocumentSource Class Reference

#include <documentsource.h>

Public Member Functions

 DocumentSource ()
 DocumentSource (const DocumentSource &other)
 DocumentSource (const QByteArray &source, const QString &url)
 ~DocumentSource ()
QByteArray asByteArray () const
QDomDocument asDomDocument () const
unsigned int hash () const
DocumentSourceoperator= (const DocumentSource &other)
unsigned int size () const
QString url () const

Detailed Description

Represents the source of a syndication document, as read from the downloaded file.

It provides a (cached) DOM representation of the document, but keeps the raw data available (for (rarely used) non-XML formats like Okay! News).

This way the document can be passed to all available parsers (to find the right one for the source), regardless whether they parse XML formats or non-XML formats, without having every parser to do the XML parsing again.

Frank Osterfeld

Definition at line 35 of file documentsource.h.

Constructor & Destructor Documentation

◆ DocumentSource() [1/3]

Syndication::DocumentSource::DocumentSource ( )

Creates an empty document source.

The raw representation is empty and the DOM representation will be invalid.

Definition at line 28 of file documentsource.cpp.

◆ DocumentSource() [2/3]

Syndication::DocumentSource::DocumentSource ( const QByteArray source,
const QString url 

Creates a DocumentSource object from a raw byte array.

sourcethe raw source (of the downloaded feed file usually)
urlthe URL/path the source was read from

Definition at line 36 of file documentsource.cpp.

◆ DocumentSource() [3/3]

Syndication::DocumentSource::DocumentSource ( const DocumentSource other)

Copy constructor.

The d pointer is shared, so this is a cheap operation.

otherDocumentSource to copy

Definition at line 45 of file documentsource.cpp.

◆ ~DocumentSource()

Syndication::DocumentSource::~DocumentSource ( )


Definition at line 51 of file documentsource.cpp.

Member Function Documentation

◆ asByteArray()

QByteArray Syndication::DocumentSource::asByteArray ( ) const

Returns the feed source as byte array.

the feed source as raw byte array.

Definition at line 61 of file documentsource.cpp.

◆ asDomDocument()

QDomDocument Syndication::DocumentSource::asDomDocument ( ) const

Returns the feed source as DOM document.

The document is parsed only on the first call of this method and then cached.

If the feed source cannot be parsed successfully then the returned DOM node will be null (eg. asDomDocument().isNull() will return true)

XML representation parsed from the raw source

Definition at line 66 of file documentsource.cpp.

◆ hash()

unsigned int Syndication::DocumentSource::hash ( ) const

calculates a hash value for the source array.

This can be used to decide whether the feed has changed since the last fetch. If the hash hasn't changed since the last fetch, the feed wasn't modified with high probability.

the hash calculated from the source, 0 if the source is empty

Definition at line 88 of file documentsource.cpp.

◆ operator=()

DocumentSource & Syndication::DocumentSource::operator= ( const DocumentSource other)

Assignment operator.

The d pointer is shared, so this is a cheap operation.

otherDocumentSource to assign to this instance
reference to this instance

Definition at line 55 of file documentsource.cpp.

◆ size()

unsigned int Syndication::DocumentSource::size ( ) const

returns the size the source array in bytes.

the size of the byte array in bytes. See also QByteArray::size()

Definition at line 83 of file documentsource.cpp.

◆ url()

QString Syndication::DocumentSource::url ( ) const

returns the URL the document source was loaded from

Definition at line 98 of file documentsource.cpp.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 6 2023 04:02:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.