CppCMS
|
Copy the output stream part - "tee" filter. More...
#include <cppcms/copy_filter.h>
Public Member Functions | |
copy_filter (std::ostream &output) | |
~copy_filter () | |
std::string | detach () |
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()); }
cppcms::copy_filter::copy_filter | ( | std::ostream & | output | ) |
Create a filter copying all output to internal buffer
When destroyed, if the stream wasn't detached aborts coping the data, making it exception safe.
std::string cppcms::copy_filter::detach | ( | ) |
Stop the coping process and return all collected data as string.