23 #ifndef TUFAO_SESSION_H
24 #define TUFAO_SESSION_H
26 #include "sessionstore.h"
27 #include <QtCore/QVariant>
89 session.setValue(key, value);
96 QVariant operator ()()
98 return session.value(key);
103 const QByteArray key;
128 return store.hasProperty(request, response, key);
138 QVariant
value(
const QByteArray &key)
const
140 return store.property(request, response, key);
149 void setValue(
const QByteArray &key,
const QVariant &value)
151 store.setProperty(request, response, key, value);
181 QVariant v = store.
property(request, response, property);
207 QMap<QByteArray, QVariant> properties;
209 for (
const auto &property: store.
properties(request, response))
210 properties[property] = store.
property(request, response, property);
214 for (
auto i = properties.begin();i != properties.end();++i)
215 store.
setProperty(request, response, i.key(), i.value());
226 #endif // TUFAO_SESSION_H
virtual QVariant property(const HttpServerRequest &request, HttpServerResponse &response, const QByteArray &key) const =0
Returns the property referenced by key in the session, or a null QVariant if the property isn't found...
PropertyWrapper(Session &session, const QByteArray &key)
Constructs a new PropertyWrappe object.
Definition: session.h:71
The Tufao::HttpServerResponse is used to respond to a Tufao::HttpServerRequest.
Definition: httpserverresponse.h:142
The Tufao::HttpServer represents a HTTP request received by Tufao::HttpServer.
Definition: httpserverrequest.h:54
This class provides easier access to the session's properties.
Definition: session.h:48
virtual QList< QByteArray > properties(const HttpServerRequest &request, const HttpServerResponse &response) const =0
Returns a list of set properties to this session.
Provides a object that give less verbose access to a session property.
Definition: session.h:60
QVariant value(const QByteArray &key) const
Returns the value of the property referenced by key, or a null QVariant if the property isn't found...
Definition: session.h:138
static void apply(SessionStore &store, const HttpServerRequest &request, HttpServerResponse &response, F f)
Takes a functor to access the session's properties.
Definition: session.h:204
virtual void setProperty(const HttpServerRequest &request, HttpServerResponse &response, const QByteArray &key, const QVariant &value)=0
Sets the property's value referenced by key to value.
static void apply(SessionStore &store, const QByteArray &property, const HttpServerRequest &request, HttpServerResponse &response, F f)
Takes a functor to access a session's property.
Definition: session.h:177
bool hasValue(const QByteArray &key) const
Returns true if the session has a property accessible through key.
Definition: session.h:126
This is the namespace where all Tufão facilities are grouped.
Definition: abstracthttpserverrequesthandler.h:30
Session(SessionStore &store, const HttpServerRequest &request, HttpServerResponse &response)
Constructs a new Session object.
Definition: session.h:113
void setValue(const QByteArray &key, const QVariant &value)
Sets the property's value referenced by key to value.
Definition: session.h:149
SessionStore class can be used to store data that must persist among different requests.
Definition: sessionstore.h:220