TreeFrogFramework 2.10
Loading...
Searching...
No Matches
tsession.h
Go to the documentation of this file.
1#pragma once
2#include <QByteArray>
3#include <QVariant>
4#include <TGlobal>
5
6
7class T_CORE_EXPORT TSession : public QVariantMap {
8public:
9 TSession(const QByteArray &id = QByteArray());
10 TSession(const TSession &other);
11 TSession &operator=(const TSession &other);
12
13 QByteArray id() const { return sessionId; }
14 void reset();
15 iterator insert(const QString &key, const QVariant &value);
16 int remove(const QString &key);
17 QVariant take(const QString &key);
18 const QVariant value(const QString &key) const;
19 const QVariant value(const QString &key, const QVariant &defaultValue) const;
20 static QByteArray sessionName();
21
22private:
23 QByteArray sessionId;
24
25 void clear(); // disabled
26 friend class TSessionCookieStore;
27 friend class TActionContext;
28};
29
30
31inline TSession::TSession(const QByteArray &id) :
32 sessionId(id)
33{
34}
35
36inline TSession::TSession(const TSession &other) :
37 QVariantMap(*static_cast<const QVariantMap *>(&other)), sessionId(other.sessionId)
38{
39}
40
42{
43 QVariantMap::operator=(*static_cast<const QVariantMap *>(&other));
44 sessionId = other.sessionId;
45 return *this;
46}
47
48inline TSession::iterator TSession::insert(const QString &key, const QVariant &value)
49{
50 return QVariantMap::insert(key, value);
51}
52
53inline int TSession::remove(const QString &key)
54{
55 return QVariantMap::remove(key);
56}
57
58inline QVariant TSession::take(const QString &key)
59{
60 return QVariantMap::take(key);
61}
62
63inline const QVariant TSession::value(const QString &key) const
64{
65 return QVariantMap::value(key);
66}
67
68inline const QVariant TSession::value(const QString &key, const QVariant &defaultValue) const
69{
70 return QVariantMap::value(key, defaultValue);
71}
72
The TSession class holds information associated with individual visitors.
Definition tsession.h:7
TSession & operator=(const TSession &other)
Definition tsession.h:41
QVariant take(const QString &key)
Definition tsession.h:58
TSession(const QByteArray &id=QByteArray())
Constructs a empty session with the ID id.
Definition tsession.h:31
const QVariant value(const QString &key) const
Returns the value associated with the key.
Definition tsession.h:63
int remove(const QString &key)
Definition tsession.h:53
iterator insert(const QString &key, const QVariant &value)
Inserts a new item with the key and a value of value.
Definition tsession.h:48
QByteArray id() const
Returns the ID.
Definition tsession.h:13
#define T_CORE_EXPORT
Definition tdeclexport.h:28