tufao  0.8.1
An asynchronous web framework for C++ built on top of Qt
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Tufao::Session Class Reference

This class provides easier access to the session's properties. More...

+ Collaboration diagram for Tufao::Session:

Classes

class  PropertyWrapper
 Provides a object that give less verbose access to a session property. More...
 

Public Member Functions

 Session (SessionStore &store, const HttpServerRequest &request, HttpServerResponse &response)
 Constructs a new Session object. More...
 
bool hasValue (const QByteArray &key) const
 Returns true if the session has a property accessible through key. More...
 
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. More...
 
void setValue (const QByteArray &key, const QVariant &value)
 Sets the property's value referenced by key to value. More...
 
PropertyWrapper operator[] (const QByteArray &key)
 Returns a PropertyWrapper that will remember the key used to manipulate the session property.
 

Detailed Description

This class provides easier access to the session's properties.

It uses C++ features used in containers to provide a familiar interface, such as overloading the operator [].

bool RequestHandler::handleRequest(Tufao::HttpServerRequest *request,
const QStringList &)
{
Tufao::Session s(store, *request, *response);
s["access"] = s["access"]().toInt() + 1;
response->writeHead(200);
(*response) << "You have "
<< QByteArray::number(s["access"]().toInt())
<< " access";
response->end();
return true;
}
Note
All member functions of this class are inlined and should add the minimum (if any) of overhead.
See Also
SessionStore
Since
0.4

Constructor & Destructor Documentation

Tufao::Session::Session ( SessionStore store,
const HttpServerRequest request,
HttpServerResponse response 
)
inline

Constructs a new Session object.

The object will use store, request and response in every operation and you should ensure these objects aren't destructed before this Session object.

Member Function Documentation

bool Tufao::Session::hasValue ( const QByteArray &  key) const
inline

Returns true if the session has a property accessible through key.

See Also
SessionStore::hasProperty
void Tufao::Session::setValue ( const QByteArray &  key,
const QVariant &  value 
)
inline

Sets the property's value referenced by key to value.

See Also
SessionStore::setProperty
QVariant Tufao::Session::value ( const QByteArray &  key) const
inline

Returns the value of the property referenced by key, or a null QVariant if the property isn't found.

See Also
SessionStore::property

The documentation for this class was generated from the following file: