Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
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 QDateTime lastModified() const;
52 void setLastModified(const QDateTime &dateTime);
53
54 QDateTime expirationDate() const;
55 void setExpirationDate(const QDateTime &dateTime);
56
57 bool saveToDisk() const;
58 void setSaveToDisk(bool allow);
59
60 AttributesMap attributes() const;
61 void setAttributes(const AttributesMap &attributes);
62
63private:
66};
67
68Q_DECLARE_SHARED(QNetworkCacheMetaData)
69
70Q_NETWORK_EXPORT QDataStream &operator<<(QDataStream &, const QNetworkCacheMetaData &);
71Q_NETWORK_EXPORT QDataStream &operator>>(QDataStream &, QNetworkCacheMetaData &);
72
73
75class Q_NETWORK_EXPORT QAbstractNetworkCache : public QObject
76{
78
79public:
80 virtual ~QAbstractNetworkCache();
81
83 virtual void updateMetaData(const QNetworkCacheMetaData &metaData) = 0;
84 virtual QIODevice *data(const QUrl &url) = 0;
85 virtual bool remove(const QUrl &url) = 0;
86 virtual qint64 cacheSize() const = 0;
87
88 virtual QIODevice *prepare(const QNetworkCacheMetaData &metaData) = 0;
89 virtual void insert(QIODevice *device) = 0;
90
91public Q_SLOTS:
92 virtual void clear() = 0;
93
94protected:
95 explicit QAbstractNetworkCache(QObject *parent = nullptr);
97
98private:
99 Q_DECLARE_PRIVATE(QAbstractNetworkCache)
100 Q_DISABLE_COPY(QAbstractNetworkCache)
101};
102
104
105#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:30
\inmodule QtCore\reentrant
Definition qdatetime.h:257
\inmodule QtCore
Definition qhash.h:818
\inmodule QtCore \reentrant
Definition qiodevice.h:34
Definition qlist.h:74
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:90
\inmodule QtCore
Definition qshareddata.h:35
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
std::pair< T1, T2 > QPair
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1219
request setUrl(QUrl("http://qt-project.org"))
#define Q_OBJECT
#define Q_SLOTS
long long qint64
Definition qtypes.h:55
QUrl url("example.com")
[constructor-url-reference]
QDateTime dateTime
[12]
QSharedPointer< T > other(t)
[5]
this swap(other)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent