libfossil
fsl::FslOutputFStreamBuf Class Reference

A std::streambuf impl which redirects a std::streambuf to a fsl_output_f(). More...

#include "fossil.hpp"

Inheritance diagram for fsl::FslOutputFStreamBuf:

Public Member Functions

 FslOutputFStreamBuf (fsl_output_f out, void *outState, std::ostream &os)
 Redirects os's buffer to use this object, such that all output sent to os will instead go through this buffer to fsl_output(f,...). More...
 
 FslOutputFStreamBuf (fsl_output_f out, void *outState)
 Sets up output sent to this stream to go throug out(outState,...). More...
 
virtual ~FslOutputFStreamBuf () throw ()
 If this object wraps a stream, that stream's buffer is restored to its prior state. More...
 
virtual int overflow (int c)
 Outputs c as a single byte via the output function provided to the ctor. More...
 
virtual int sync ()
 Does nothing. More...
 

Detailed Description

A std::streambuf impl which redirects a std::streambuf to a fsl_output_f().

It can be used, e.g. to redirect std::cout and std::cerr to a client-specific callback.

Definition at line 2107 of file fossil.hpp.

Constructor & Destructor Documentation

fsl::FslOutputFStreamBuf::FslOutputFStreamBuf ( fsl_output_f  out,
void *  outState,
std::ostream &  os 
)

Redirects os's buffer to use this object, such that all output sent to os will instead go through this buffer to fsl_output(f,...).

os must outlive this object. When this object destructs, os's old buffer is restored.

Throws if !out.

Example:

FslOutputFStreamBuf sb(myCallback, callbackState, std::cout);
std::cout << "This now goes through fsl_output(myFossil,...).\n";
fsl::FslOutputFStreamBuf::FslOutputFStreamBuf ( fsl_output_f  out,
void *  outState 
)

Sets up output sent to this stream to go throug out(outState,...).

Throws if !out.

virtual fsl::FslOutputFStreamBuf::~FslOutputFStreamBuf ( )
throw (
)
virtual

If this object wraps a stream, that stream's buffer is restored to its prior state.

Member Function Documentation

virtual int fsl::FslOutputFStreamBuf::overflow ( int  c)
virtual

Outputs c as a single byte via the output function provided to the ctor.

Throws on error.

virtual int fsl::FslOutputFStreamBuf::sync ( )
virtual

Does nothing.

Returns 0.


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