Qt 4.8
Public Types | Public Functions | Properties | Friends | Related Functions | List of all members
QNetworkCacheMetaData Class Reference

The QNetworkCacheMetaData class provides cache information. More...

#include <qabstractnetworkcache.h>

Public Types

typedef QHash< QNetworkRequest::Attribute, QVariantAttributesMap
 Synonym for QHash<QNetworkRequest::Attribute, QVariant> More...
 
typedef QPair< QByteArray, QByteArrayRawHeader
 Synonym for QPair<QByteArray, QByteArray> More...
 
typedef QList< RawHeaderRawHeaderList
 Synonym for QList<RawHeader> More...
 

Public Functions

AttributesMap attributes () const
 Returns all the attributes stored with this cache item. More...
 
QDateTime expirationDate () const
 Returns the date and time when the meta data expires. More...
 
bool isValid () const
 Returns true if this network cache meta data has attributes that have been set otherwise false. More...
 
QDateTime lastModified () const
 Returns the date and time when the meta data was last modified. More...
 
bool operator!= (const QNetworkCacheMetaData &other) const
 Returns true if this meta data is not equal to the other meta data; otherwise returns false. More...
 
QNetworkCacheMetaDataoperator= (const QNetworkCacheMetaData &other)
 Makes a copy of the other QNetworkCacheMetaData and returns a reference to the copy. More...
 
bool operator== (const QNetworkCacheMetaData &other) const
 Returns true if this meta data is equal to the other meta data; otherwise returns false. More...
 
 QNetworkCacheMetaData ()
 Constructs an invalid network cache meta data. More...
 
 QNetworkCacheMetaData (const QNetworkCacheMetaData &other)
 Constructs a copy of the other QNetworkCacheMetaData. More...
 
RawHeaderList rawHeaders () const
 Returns a list of all raw headers that are set in this meta data. More...
 
bool saveToDisk () const
 Returns is this cache should be allowed to be stored on disk. More...
 
void setAttributes (const AttributesMap &attributes)
 Sets all attributes of this cache item to be the map attributes. More...
 
void setExpirationDate (const QDateTime &dateTime)
 Sets the date and time when the meta data expires to dateTime. More...
 
void setLastModified (const QDateTime &dateTime)
 Sets the date and time when the meta data was last modified to dateTime. More...
 
void setRawHeaders (const RawHeaderList &headers)
 Sets the raw headers to list. More...
 
void setSaveToDisk (bool allow)
 Sets whether this network cache meta data and associated content should be allowed to be stored on disk to allow. More...
 
void setUrl (const QUrl &url)
 Sets the URL this network cache meta data to to be url. More...
 
QUrl url () const
 Returns the URL this network cache meta data is referring to. More...
 
 ~QNetworkCacheMetaData ()
 Destroys the network cache meta data. More...
 

Properties

QSharedDataPointer< QNetworkCacheMetaDataPrivated
 

Friends

class QNetworkCacheMetaDataPrivate
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &out, const QNetworkCacheMetaData &metaData)
 Writes metaData to the out stream. More...
 
QDataStreamoperator>> (QDataStream &in, QNetworkCacheMetaData &metaData)
 Reads a QNetworkCacheMetaData from the stream in into metaData. More...
 

Detailed Description

The QNetworkCacheMetaData class provides cache information.

Since
4.5
Attention
Module: QtNetwork

QNetworkCacheMetaData provides information about a cache file including the url, when it was last modified, when the cache file was created, headers for file and if the file should be saved onto a disk.

See also
QAbstractNetworkCache

Definition at line 62 of file qabstractnetworkcache.h.

Typedefs

◆ AttributesMap

◆ RawHeader

Synonym for QPair<QByteArray, QByteArray>

Definition at line 66 of file qabstractnetworkcache.h.

◆ RawHeaderList

Synonym for QList<RawHeader>

Definition at line 67 of file qabstractnetworkcache.h.

Constructors and Destructors

◆ QNetworkCacheMetaData() [1/2]

QNetworkCacheMetaData::QNetworkCacheMetaData ( )

Constructs an invalid network cache meta data.

See also
isValid()

Definition at line 123 of file qabstractnetworkcache.cpp.

125 {
126 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ QNetworkCacheMetaData() [2/2]

QNetworkCacheMetaData::QNetworkCacheMetaData ( const QNetworkCacheMetaData other)

Constructs a copy of the other QNetworkCacheMetaData.

Definition at line 139 of file qabstractnetworkcache.cpp.

140  : d(other.d)
141 {
142 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ ~QNetworkCacheMetaData()

QNetworkCacheMetaData::~QNetworkCacheMetaData ( )

Destroys the network cache meta data.

Definition at line 131 of file qabstractnetworkcache.cpp.

132 {
133  // QSharedDataPointer takes care of freeing d
134 }

Functions

◆ attributes()

QNetworkCacheMetaData::AttributesMap QNetworkCacheMetaData::attributes ( ) const

Returns all the attributes stored with this cache item.

Since
4.6
See also
setAttributes(), QNetworkRequest::Attribute

Definition at line 301 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::fetchCacheMetaData(), QNetworkReplyImplPrivate::initCacheSaveDevice(), QNetworkCacheMetaDataPrivate::save(), QNetworkAccessCacheBackend::sendCacheContents(), QNetworkAccessHttpBackend::sendCacheContents(), and setAttributes().

302 {
303  return d->attributes;
304 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d
QNetworkCacheMetaData::AttributesMap attributes

◆ expirationDate()

QDateTime QNetworkCacheMetaData::expirationDate ( ) const

Returns the date and time when the meta data expires.

Definition at line 278 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::loadFromCacheIfAllowed(), and QNetworkCacheMetaDataPrivate::save().

279 {
280  return d->expirationDate;
281 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ isValid()

bool QNetworkCacheMetaData::isValid ( ) const

Returns true if this network cache meta data has attributes that have been set otherwise false.

Definition at line 181 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), QNetworkAccessCacheBackend::sendCacheContents(), and QNetworkAccessHttpBackend::sendCacheContents().

182 {
183  return !(*d == *metadata_shared_invalid());
184 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ lastModified()

QDateTime QNetworkCacheMetaData::lastModified ( ) const

Returns the date and time when the meta data was last modified.

Definition at line 262 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::loadFromCacheIfAllowed(), and QNetworkCacheMetaDataPrivate::save().

263 {
264  return d->lastModified;
265 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ operator!=()

bool QNetworkCacheMetaData::operator!= ( const QNetworkCacheMetaData other) const
inline

Returns true if this meta data is not equal to the other meta data; otherwise returns false.

See also
operator==()

Definition at line 76 of file qabstractnetworkcache.h.

77  { return !(*this == other); }

◆ operator=()

QNetworkCacheMetaData & QNetworkCacheMetaData::operator= ( const QNetworkCacheMetaData other)

Makes a copy of the other QNetworkCacheMetaData and returns a reference to the copy.

Definition at line 147 of file qabstractnetworkcache.cpp.

148 {
149  d = other.d;
150  return *this;
151 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ operator==()

bool QNetworkCacheMetaData::operator== ( const QNetworkCacheMetaData other) const

Returns true if this meta data is equal to the other meta data; otherwise returns false.

See also
operator!=()

Definition at line 158 of file qabstractnetworkcache.cpp.

159 {
160  if (d == other.d)
161  return true;
162  if (d && other.d)
163  return *d == *other.d;
164  return false;
165 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ rawHeaders()

QNetworkCacheMetaData::RawHeaderList QNetworkCacheMetaData::rawHeaders ( ) const

Returns a list of all raw headers that are set in this meta data.

The list is in the same order that the headers were set.

See also
setRawHeaders()

Definition at line 244 of file qabstractnetworkcache.cpp.

Referenced by QCacheItem::canCompress(), QNetworkAccessHttpBackend::fetchCacheMetaData(), QNetworkAccessHttpBackend::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), QNetworkAccessHttpBackend::replyDownloadMetaData(), QNetworkCacheMetaDataPrivate::save(), QNetworkAccessCacheBackend::sendCacheContents(), and QNetworkAccessHttpBackend::sendCacheContents().

245 {
246  return d->headers;
247 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d
QNetworkCacheMetaData::RawHeaderList headers

◆ saveToDisk()

bool QNetworkCacheMetaData::saveToDisk ( ) const

Returns is this cache should be allowed to be stored on disk.

Some cache implementations can keep these cache items in memory for performance reasons, but for security reasons they should not be written to disk.

Specifically with http, documents marked with Pragma: no-cache, or have a Cache-control set to no-store or no-cache or any https document that doesn't have "Cache-control: public" set will set the saveToDisk to false.

See also
setSaveToDisk()

Definition at line 198 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::loadFromCacheIfAllowed(), QNetworkDiskCache::prepare(), QNetworkCacheMetaDataPrivate::save(), and QNetworkDiskCachePrivate::storeItem().

199 {
200  return d->saveToDisk;
201 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ setAttributes()

void QNetworkCacheMetaData::setAttributes ( const AttributesMap attributes)

Sets all attributes of this cache item to be the map attributes.

Since
4.6
See also
attributes(), QNetworkRequest::setAttribute()

Definition at line 316 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::fetchCacheMetaData(), and QNetworkReplyImplPrivate::initCacheSaveDevice().

317 {
319 }
AttributesMap attributes() const
Returns all the attributes stored with this cache item.
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d
QNetworkCacheMetaData::AttributesMap attributes

◆ setExpirationDate()

void QNetworkCacheMetaData::setExpirationDate ( const QDateTime dateTime)

Sets the date and time when the meta data expires to dateTime.

Definition at line 286 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::fetchCacheMetaData().

287 {
288  d->expirationDate = dateTime;
289 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ setLastModified()

void QNetworkCacheMetaData::setLastModified ( const QDateTime dateTime)

Sets the date and time when the meta data was last modified to dateTime.

Definition at line 270 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::fetchCacheMetaData().

271 {
272  d->lastModified = dateTime;
273 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ setRawHeaders()

void QNetworkCacheMetaData::setRawHeaders ( const RawHeaderList list)

Sets the raw headers to list.

See also
rawHeaders()

Definition at line 254 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::fetchCacheMetaData().

255 {
256  d->headers = list;
257 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d
QNetworkCacheMetaData::RawHeaderList headers

◆ setSaveToDisk()

void QNetworkCacheMetaData::setSaveToDisk ( bool  allow)

Sets whether this network cache meta data and associated content should be allowed to be stored on disk to allow.

See also
saveToDisk()

Definition at line 209 of file qabstractnetworkcache.cpp.

Referenced by QNetworkAccessHttpBackend::fetchCacheMetaData().

210 {
211  d->saveToDisk = allow;
212 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

◆ setUrl()

void QNetworkCacheMetaData::setUrl ( const QUrl url)

Sets the URL this network cache meta data to to be url.

The password and fragment are removed from the url.

See also
url()

Definition at line 231 of file qabstractnetworkcache.cpp.

Referenced by QNetworkReplyImplPrivate::initCacheSaveDevice().

232 {
233  d->url = url;
234  d->url.setPassword(QString());
235  d->url.setFragment(QString());
236 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
QUrl url() const
Returns the URL this network cache meta data is referring to.
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d
void setFragment(const QString &fragment)
Sets the fragment of the URL to fragment.
Definition: qurl.cpp:5669
void setPassword(const QString &password)
Sets the URL&#39;s password to password.
Definition: qurl.cpp:4736

◆ url()

QUrl QNetworkCacheMetaData::url ( ) const

Returns the URL this network cache meta data is referring to.

See also
setUrl()

Definition at line 219 of file qabstractnetworkcache.cpp.

Referenced by QNetworkDiskCache::prepare(), QNetworkDiskCache::remove(), QNetworkCacheMetaDataPrivate::save(), setUrl(), QNetworkDiskCachePrivate::storeItem(), and QNetworkDiskCache::updateMetaData().

220 {
221  return d->url;
222 }
QSharedDataPointer< QNetworkCacheMetaDataPrivate > d

Friends and Related Functions

◆ operator<<()

QDataStream & operator<< ( QDataStream out,
const QNetworkCacheMetaData metaData 
)
related

Writes metaData to the out stream.

Since
4.5
See also
{Serializing Qt Data Types}

Definition at line 332 of file qabstractnetworkcache.cpp.

333 {
334  QNetworkCacheMetaDataPrivate::save(out, metaData);
335  return out;
336 }
static void save(QDataStream &out, const QNetworkCacheMetaData &metaData)

◆ operator>>()

QDataStream & operator>> ( QDataStream in,
QNetworkCacheMetaData metaData 
)
related

Reads a QNetworkCacheMetaData from the stream in into metaData.

Since
4.5
See also
{Serializing Qt Data Types}

Definition at line 373 of file qabstractnetworkcache.cpp.

374 {
376  return in;
377 }
static void load(QDataStream &in, QNetworkCacheMetaData &metaData)

◆ QNetworkCacheMetaDataPrivate

Definition at line 100 of file qabstractnetworkcache.h.

Properties

◆ d

QSharedDataPointer<QNetworkCacheMetaDataPrivate> QNetworkCacheMetaData::d
private

The documentation for this class was generated from the following files: