Syndication::DocumentSource
#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 |
DocumentSource & | operator= (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.
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.
- Parameters
-
source the raw source (of the downloaded feed file usually) url the 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.
- Parameters
-
other DocumentSource to copy
Definition at line 45 of file documentsource.cpp.
◆ ~DocumentSource()
Syndication::DocumentSource::~DocumentSource | ( | ) |
destructor
Definition at line 51 of file documentsource.cpp.
Member Function Documentation
◆ asByteArray()
QByteArray Syndication::DocumentSource::asByteArray | ( | ) | const |
Returns the feed source as byte array.
- Returns
- 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)
- Returns
- 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.
- Returns
- the hash calculated from the source, 0 if the source is empty
Definition at line 86 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.
- Parameters
-
other DocumentSource to assign to this instance
- Returns
- 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.
- Returns
- the size of the byte array in bytes. See also QByteArray::size()
Definition at line 81 of file documentsource.cpp.
◆ url()
QString Syndication::DocumentSource::url | ( | ) | const |
returns the URL the document source was loaded from
Definition at line 96 of file documentsource.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.