libfossil
fsl::ContextOStreamBuf Class Reference

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

#include "fossil.hpp"

Inheritance diagram for fsl::ContextOStreamBuf:

Public Member Functions

 ContextOStreamBuf (fsl_cx *f, 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...
 
 ContextOStreamBuf (Context &cx, std::ostream &os)
 Equivalent to passing cx.handle() to the other two-arg ctor. More...
 
 ContextOStreamBuf (fsl_cx *f)
 Redirects all output sent to this buffer to fsl_output(f,...). More...
 
 ContextOStreamBuf (Context &cx)
 Equivalent to passing cx.handle() to the other one-arg ctor. More...
 
virtual ~ContextOStreamBuf () throw ()
 Flushes the buffer via this->sync();. More...
 
virtual int overflow (int c)
 Outputs c as a single char via fsl_output(), using the fsl_cx instance passed to the constructor. More...
 
virtual int sync ()
 Falls fsl_flush(), passing it the fsl_cx instance passed to the ctor. More...
 

Detailed Description

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

Can be used, e.g. to redirect std::cout and std::cerr to fsl_output().

Definition at line 1990 of file fossil.hpp.

Constructor & Destructor Documentation

fsl::ContextOStreamBuf::ContextOStreamBuf ( fsl_cx f,
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 f is NULL.

Example:

ContextOStreamBuf sb(myFossil, std::cout);
std::cout << "This now goes through fsl_output(myFossil,...).\n";
fsl::ContextOStreamBuf::ContextOStreamBuf ( Context cx,
std::ostream &  os 
)

Equivalent to passing cx.handle() to the other two-arg ctor.

fsl::ContextOStreamBuf::ContextOStreamBuf ( fsl_cx f)
explicit

Redirects all output sent to this buffer to fsl_output(f,...).

Throws if f is NULL.

fsl::ContextOStreamBuf::ContextOStreamBuf ( Context cx)
explicit

Equivalent to passing cx.handle() to the other one-arg ctor.

virtual fsl::ContextOStreamBuf::~ContextOStreamBuf ( )
throw (
)
virtual

Flushes the buffer via this->sync();.

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

Member Function Documentation

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

Outputs c as a single char via fsl_output(), using the fsl_cx instance passed to the constructor.

On a write error it throws, else it returns 0.

virtual int fsl::ContextOStreamBuf::sync ( )
virtual

Falls fsl_flush(), passing it the fsl_cx instance passed to the ctor.

Returns the result of that call.


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