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
qnetworkcookie.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 QNETWORKCOOKIE_H
5#define QNETWORKCOOKIE_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/QSharedDataPointer>
9#include <QtCore/QList>
10#include <QtCore/QMetaType>
11#include <QtCore/QObject>
12
14
15
16class QByteArray;
17class QDateTime;
18class QString;
19class QUrl;
20
22class Q_NETWORK_EXPORT QNetworkCookie
23{
25public:
26 enum RawForm {
28 Full
29 };
30 enum class SameSite {
31 Default,
32 None,
33 Lax,
34 Strict
35 };
36 Q_ENUM(SameSite)
37
38 explicit QNetworkCookie(const QByteArray &name = QByteArray(), const QByteArray &value = QByteArray());
41 QNetworkCookie &operator=(QNetworkCookie &&other) noexcept { swap(other); return *this; }
42 QNetworkCookie &operator=(const QNetworkCookie &other);
43
44 void swap(QNetworkCookie &other) noexcept { d.swap(other.d); }
45
46 bool operator==(const QNetworkCookie &other) const;
47 inline bool operator!=(const QNetworkCookie &other) const
48 { return !(*this == other); }
49
50 bool isSecure() const;
51 void setSecure(bool enable);
52 bool isHttpOnly() const;
53 void setHttpOnly(bool enable);
54 SameSite sameSitePolicy() const;
55 void setSameSitePolicy(SameSite sameSite);
56
57 bool isSessionCookie() const;
58 QDateTime expirationDate() const;
59 void setExpirationDate(const QDateTime &date);
60
61 QString domain() const;
62 void setDomain(const QString &domain);
63
64 QString path() const;
65 void setPath(const QString &path);
66
67 QByteArray name() const;
68 void setName(const QByteArray &cookieName);
69
70 QByteArray value() const;
71 void setValue(const QByteArray &value);
72
73 QByteArray toRawForm(RawForm form = Full) const;
74
75 bool hasSameIdentifier(const QNetworkCookie &other) const;
76 void normalize(const QUrl &url);
77
78#if QT_NETWORK_REMOVED_SINCE(6, 7)
79 static QList<QNetworkCookie> parseCookies(const QByteArray &cookieString);
80#endif
81 static QList<QNetworkCookie> parseCookies(QByteArrayView cookieString);
82
83private:
84 QSharedDataPointer<QNetworkCookiePrivate> d;
86};
87
88Q_DECLARE_SHARED(QNetworkCookie)
89
90#ifndef QT_NO_DEBUG_STREAM
91class QDebug;
92Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QNetworkCookie &);
93#endif
94
96
98
99#endif
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtCore
The QNetworkCookie class holds one network cookie.
void swap(QNetworkCookie &other) noexcept
bool operator!=(const QNetworkCookie &other) const
Returns true if this cookie is not equal to other.
RawForm
This enum is used with the toRawForm() function to declare which form of a cookie shall be returned.
QNetworkCookie & operator=(QNetworkCookie &&other) noexcept
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
Definition qurl.h:94
QDate date
[1]
employee setName("Richard Schmit")
Combined button and popup list for selecting options.
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
@ None
Definition qhash.cpp:531
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition qmetatype.h:1388
Q_NETWORK_EXPORT QDebug operator<<(QDebug, const QNetworkCookie &)
GLboolean enable
GLuint name
GLsizei const GLchar *const * path
static void normalize(double &x, double &y)
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
static QT_BEGIN_NAMESPACE const uint Default
Definition qsplitter_p.h:27
#define Q_ENUM(x)
#define Q_GADGET
settings setValue("DataPump/bgcolor", color)
QUrl url("example.com")
[constructor-url-reference]
QSharedPointer< T > other(t)
[5]
this swap(other)