Anp::StreamBuf Class Reference

#include <StreamBuf.h>

List of all members.

Public Member Functions

 StreamBuf ()
 ~StreamBuf ()
bool Open (const std::string &fname)
bool Close ()

Private Member Functions

 StreamBuf (const StreamBuf &)
StreamBufoperator= (const StreamBuf &)

Private Attributes

std::ofstream fRedirect
std::streambuf * fBufCerr
std::streambuf * fBufCout

Detailed Description

Definition at line 16 of file StreamBuf.h.


Constructor & Destructor Documentation

Anp::StreamBuf::StreamBuf (  )  [inline]

Definition at line 43 of file StreamBuf.h.

00044       : fRedirect(), fBufCerr(0), fBufCout(0) {}

Anp::StreamBuf::~StreamBuf (  )  [inline]

Definition at line 46 of file StreamBuf.h.

References Close().

00047    {
00048       StreamBuf::Close();
00049    }

Anp::StreamBuf::StreamBuf ( const StreamBuf  )  [private]

Member Function Documentation

bool Anp::StreamBuf::Close (  )  [inline]

Definition at line 74 of file StreamBuf.h.

References fBufCerr, fBufCout, and fRedirect.

Referenced by ~StreamBuf().

00075    {
00076       if(fRedirect.is_open())
00077       {
00078          std::cout.rdbuf(fBufCout);
00079          std::cerr.rdbuf(fBufCerr);
00080          fRedirect.close();
00081          return true;
00082       }
00083 
00084       return false;
00085    }   

bool Anp::StreamBuf::Open ( const std::string &  fname  )  [inline]

Definition at line 51 of file StreamBuf.h.

References fBufCerr, fBufCout, and fRedirect.

Referenced by Anp::RunModule::Config().

00052    {
00053       fRedirect.open(fname.c_str());
00054       if(fRedirect.is_open())
00055       {
00056          std::cout << "StreamBuf - sending cout and cerr streams to file:" << std::endl
00057                    << "   " << fname << std::endl;
00058 
00059          fBufCout = std::cout.rdbuf();
00060          fBufCerr = std::cerr.rdbuf();
00061          
00062          std::cout.rdbuf(fRedirect.rdbuf());
00063          std::cerr.rdbuf(fRedirect.rdbuf());
00064          
00065          return true;
00066       }
00067       
00068       fRedirect.close();
00069       std::cerr << "StreamBuf::Config - failed to open file:" << std::endl
00070                 << "   " << fname << std::endl;
00071       return false;
00072    }

StreamBuf& Anp::StreamBuf::operator= ( const StreamBuf  )  [private]

Member Data Documentation

std::streambuf* Anp::StreamBuf::fBufCerr [private]

Definition at line 36 of file StreamBuf.h.

Referenced by Close(), and Open().

std::streambuf* Anp::StreamBuf::fBufCout [private]

Definition at line 37 of file StreamBuf.h.

Referenced by Close(), and Open().

std::ofstream Anp::StreamBuf::fRedirect [private]

Definition at line 35 of file StreamBuf.h.

Referenced by Close(), and Open().


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

Generated on 25 Apr 2018 for loon by  doxygen 1.6.1