Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

gul::debug_streambuf Class Reference

#include <gul_std.h>

List of all members.

Public Methods

GULAPI debug_streambuf (FILE *logfile)
GULAPI ~debug_streambuf ()

Static Public Methods

void atexit_func (void)

Public Attributes

int m_bptr
char m_buf [1024]
FILE * m_logfile
streambufrecm_oldsb

Static Public Attributes

bool initialized = false

Protected Methods

int overflow (int c)


Constructor & Destructor Documentation

GULAPI gul::debug_streambuf::debug_streambuf FILE *    logfile
 

Definition at line 44 of file gul_std.cpp.

References GULAPI, initialized, m_bptr, m_logfile, and m_oldsb.

00045 {
00046   m_bptr = 0;
00047   m_logfile = logfile; 
00048 
00049   m_oldsb = new streambufrec;
00050   OldStreambufs.Append(m_oldsb); 
00051 
00052   m_oldsb->cerr_buf = std::cerr.rdbuf();
00053   m_oldsb->cout_buf = std::cout.rdbuf();
00054   std::cerr.rdbuf( this );
00055   std::cout.rdbuf( this );
00056   if( !initialized )
00057   {
00058     atexit(debug_streambuf::atexit_func);
00059     initialized = true;
00060   }
00061 }

GULAPI gul::debug_streambuf::~debug_streambuf  
 

Definition at line 99 of file gul_std.cpp.

References GULAPI, and m_oldsb.

00099 {
00100   if( OldStreambufs.nElems ) // atexit function wasn't called
00101   {
00102     OldStreambufs.Remove(m_oldsb);
00103     std::cerr.rdbuf( m_oldsb->cerr_buf );
00104     std::cout.rdbuf( m_oldsb->cout_buf );
00105     delete m_oldsb;
00106   }
00107 }
00108 bool debug_streambuf::initialized = false;}


Member Function Documentation

void gul::debug_streambuf::atexit_func void    [static]
 

Definition at line 82 of file gul_std.cpp.

00083 {
00084   streambufrec *oldsb,*oldsb_next;
00085 
00086   oldsb = OldStreambufs.First(); 
00087   OldStreambufs.ReleaseElems();
00088 
00089   while( oldsb )
00090   {
00091     std::cerr.rdbuf( oldsb->cerr_buf );
00092     std::cout.rdbuf( oldsb->cout_buf );
00093     oldsb_next = oldsb->next;
00094     delete oldsb;
00095     oldsb = oldsb_next;
00096   }
00097 }

int gul::debug_streambuf::overflow int    c [protected]
 

Definition at line 63 of file gul_std.cpp.

References m_bptr, m_buf, and m_logfile.

00064 {
00065   m_buf[m_bptr++] = c;
00066 
00067   if( (c == '\n') || (m_bptr == 1023) )
00068   {
00069     m_buf[m_bptr] = 0;
00070 
00071     if( m_logfile )
00072       fprintf(m_logfile,m_buf);
00073     printf(m_buf);
00074     #ifdef _MSC_VER
00075       OutputDebugStringA(m_buf);
00076     #endif
00077     m_bptr = 0;
00078   }
00079   return(c);
00080 }


Member Data Documentation

bool gul::debug_streambuf::initialized = false [static]
 

Definition at line 110 of file gul_std.cpp.

Referenced by debug_streambuf().

int gul::debug_streambuf::m_bptr
 

Definition at line 94 of file gul_std.h.

Referenced by debug_streambuf(), and overflow().

char gul::debug_streambuf::m_buf[1024]
 

Definition at line 95 of file gul_std.h.

Referenced by overflow().

FILE* gul::debug_streambuf::m_logfile
 

Definition at line 96 of file gul_std.h.

Referenced by debug_streambuf(), and overflow().

streambufrec* gul::debug_streambuf::m_oldsb
 

Definition at line 97 of file gul_std.h.

Referenced by debug_streambuf(), and ~debug_streambuf().


The documentation for this class was generated from the following files:
Generated on Mon Jan 21 04:17:57 2002 for GUL 0.6 - Geometry Utility Library by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001