Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qabstractnetworkcache.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QABSTRACTNETWORKCACHE_H
5#define QABSTRACTNETWORKCACHE_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/qobject.h>
9#include <QtCore/qshareddata.h>
10#include <QtCore/qpair.h>
11#include <QtNetwork/qnetworkrequest.h>
12
14
15
16class QIODevice;
17class QDateTime;
18class QUrl;
19
21class Q_NETWORK_EXPORT QNetworkCacheMetaData
22{
23
24public:
25 typedef QPair<QByteArray, QByteArray> RawHeader;
26 typedef QList<RawHeader> RawHeaderList;
27 typedef QHash<QNetworkRequest::Attribute, QVariant> AttributesMap;
28
32
35
37 { d.swap(other.d); }
38
39 bool operator==(const QNetworkCacheMetaData &other) const;
40 inline bool operator!=(const QNetworkCacheMetaData &other) const
41 { return !(*this == other); }
42
43 bool isValid() const;
44
45 QUrl url() const;
46 void setUrl(const QUrl &url);
47
48 RawHeaderList rawHeaders() const;
49 void setRawHeaders(const RawHeaderList &headers);
50
51 QHttpHeaders headers() const;
52 void setHeaders(const QHttpHeaders &headers);
53
54 QDateTime lastModified() const;
55 void setLastModified(const QDateTime &dateTime);
56
57 QDateTime expirationDate() const;
58 void setExpirationDate(const QDateTime &dateTime);
59
60 bool saveToDisk() const;
61 void setSaveToDisk(bool allow);
62
63 AttributesMap attributes() const;
64 void setAttributes(const AttributesMap &attributes);
65
66private:
68 QSharedDataPointer<QNetworkCacheMetaDataPrivate> d;
69};
70
71Q_DECLARE_SHARED(QNetworkCacheMetaData)
72
73Q_NETWORK_EXPORT QDataStream &operator<<(QDataStream &, const QNetworkCacheMetaData &);
74Q_NETWORK_EXPORT QDataStream &operator>>(QDataStream &, QNetworkCacheMetaData &);
75
76
78class Q_NETWORK_EXPORT QAbstractNetworkCache : public QObject
79{
81
82public:
83 virtual ~QAbstractNetworkCache();
84
86 virtual void updateMetaData(const QNetworkCacheMetaData &metaData) = 0;
87 virtual QIODevice *data(const QUrl &url) = 0;
88 virtual bool remove(const QUrl &url) = 0;
89 virtual qint64 cacheSize() const = 0;
90
91 virtual QIODevice *prepare(const QNetworkCacheMetaData &metaData) = 0;
92 virtual void insert(QIODevice *device) = 0;
93
94public Q_SLOTS:
95 virtual void clear() = 0;
96
97protected:
98 explicit QAbstractNetworkCache(QObject *parent = nullptr);
100
101private:
102 Q_DECLARE_PRIVATE(QAbstractNetworkCache)
103 Q_DISABLE_COPY(QAbstractNetworkCache)
104};
105
107
108#endif
IOBluetoothDevice * device
The QAbstractNetworkCache class provides the interface for cache implementations.
virtual void insert(QIODevice *device)=0
Inserts the data in device and the prepared meta data into the cache.
virtual QIODevice * data(const QUrl &url)=0
Returns the data associated with url.
virtual void updateMetaData(const QNetworkCacheMetaData &metaData)=0
Updates the cache meta date for the metaData's url to metaData.
virtual QNetworkCacheMetaData metaData(const QUrl &url)=0
Returns the meta data for the url url.
virtual QIODevice * prepare(const QNetworkCacheMetaData &metaData)=0
Returns the device that should be populated with the data for the cache item metaData.
virtual qint64 cacheSize() const =0
Returns the current size taken up by the cache.
virtual void clear()=0
Removes all items from the cache.
virtual bool remove(const QUrl &url)=0
Removes the cache entry for url, returning true if success otherwise false.
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtCore \reentrant
Definition qiodevice.h:34
The QNetworkCacheMetaData class provides cache information.
bool operator!=(const QNetworkCacheMetaData &other) const
Returns true if this meta data is not equal to the other meta data; otherwise returns false.
void swap(QNetworkCacheMetaData &other) noexcept
QList< RawHeader > RawHeaderList
Synonym for QList<RawHeader>
QNetworkCacheMetaData & operator=(QNetworkCacheMetaData &&other) noexcept
QHash< QNetworkRequest::Attribute, QVariant > AttributesMap
Synonym for QHash<QNetworkRequest::Attribute, QVariant>
QPair< QByteArray, QByteArray > RawHeader
Synonym for QPair<QByteArray, QByteArray>
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
request setUrl(QUrl("http://qt-project.org"))
#define Q_OBJECT
#define Q_SLOTS
long long qint64
Definition qtypes.h:60
QUrl url("example.com")
[constructor-url-reference]
QDateTime dateTime
[12]
QSharedPointer< T > other(t)
[5]
this swap(other)