#include <Wt/WMemoryResource>
Public Member Functions | |
WMemoryResource (WObject *parent=0) | |
Create a new resource. | |
WMemoryResource (const std::string &mimeType, WObject *parent=0) | |
Create a new resource with given mime-type. | |
WMemoryResource (const std::string &mimeType, const std::vector< char > &data, WObject *parent=0) | |
Create a new resource with given mime-type and data. | |
void | setData (const std::vector< char > &data) |
Set new data for the resource to serve. | |
void | setData (const char *data, int count) |
Set new data for the resource to serve. | |
const std::string | mimeType () const |
Get the mime-type. | |
void | setMimeType (const std::string &mimeType) |
Set the mime-type. | |
Protected Member Functions | |
virtual const std::string | resourceMimeType () const |
Return the mimetype. |
Use this resource if you want to serve resource data from memory. This is suitable for relatively small resources, which still require some computation.
If you require little computation for creating the data, then you may want to reimplement WResource and compute the data on the fly while streaming.
If you have a lot of data, you may want to use a WFileResource instead.
Wt::WMemoryResource::WMemoryResource | ( | WObject * | parent = 0 |
) |
Create a new resource.
You must call setMimeType() and setData() before using the resource.
Wt::WMemoryResource::WMemoryResource | ( | const std::string & | mimeType, | |
WObject * | parent = 0 | |||
) |
Create a new resource with given mime-type.
You must call setData() before using the resource.
void Wt::WMemoryResource::setData | ( | const char * | data, | |
int | count | |||
) |
Set new data for the resource to serve.
Sets the data from using the first count bytes from the C-style data array.
const std::string Wt::WMemoryResource::resourceMimeType | ( | ) | const [protected, virtual] |
Return the mimetype.
Implement this method to return the correct mime type for your resource, e.g. "text/html".
Implements Wt::WResource.