CppCMS
Public Member Functions | List of all members
cppcms::copy_filter Class Reference

Copy the output stream part - "tee" filter. More...

#include <cppcms/copy_filter.h>

Inheritance diagram for cppcms::copy_filter:
booster::noncopyable

Public Member Functions

 copy_filter (std::ostream &output)
 
 ~copy_filter ()
 
std::string detach ()
 

Detailed Description

Copy the output stream part - "tee" filter.

This simple class designed to "copy" all the output that comes to the stream to internal buffer and the stream itself and return the copied data on detaching the filter.

It is very useful to use with caching, for example:

std::string frame;
if(cache().fetch_frame("key",frame)) {
out() << frame;
}
else {
cppcms::copy_filter tee(out());
...
// generate something heavy
...
cache().store_frame("key",tee.detach());
}

Constructor & Destructor Documentation

cppcms::copy_filter::copy_filter ( std::ostream &  output)

Create a filter copying all output to internal buffer

cppcms::copy_filter::~copy_filter ( )

When destroyed, if the stream wasn't detached aborts coping the data, making it exception safe.

Member Function Documentation

std::string cppcms::copy_filter::detach ( )

Stop the coping process and return all collected data as string.


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