G4strstreambuf Class Reference

#include <G4strstreambuf.hh>


Public Member Functions

 G4strstreambuf ()
 ~G4strstreambuf ()
virtual G4int overflow (G4int c=EOF)
virtual G4int sync ()
void SetDestination (G4coutDestination *dest)
G4int ReceiveString ()


Detailed Description

Definition at line 50 of file G4strstreambuf.hh.


Constructor & Destructor Documentation

G4strstreambuf::G4strstreambuf (  )  [inline]

Definition at line 34 of file G4strstreambuf.icc.

00035   : std::basic_streambuf<char>(),
00036     count(0), destination(0)
00038 {
00039   size= 4095;
00040   buffer= new char[size+1];
00041 }

G4strstreambuf::~G4strstreambuf (  )  [inline]

Definition at line 45 of file G4strstreambuf.icc.

00047 {
00048   // flushing buffer...
00049   // std::cout is used because destination object may not be alive.
00050   if(count !=0) std::cout << buffer;
00051 
00052   delete [] buffer;
00053 }


Member Function Documentation

G4int G4strstreambuf::overflow ( G4int  c = EOF  )  [inline, virtual]

Definition at line 83 of file G4strstreambuf.icc.

References sync().

00085 {
00086   G4int result= 0;
00087   if(count>=size) result= sync();
00088 
00089   buffer[count]= c;
00090   count++;
00091 
00092   return result;
00093 }

G4int G4strstreambuf::ReceiveString (  )  [inline]

Definition at line 124 of file G4strstreambuf.icc.

References G4cerrbuf, and G4coutbuf.

Referenced by sync().

00126 {
00127   G4String stringToSend(buffer);
00128   G4int result= 0;
00129 
00130   if(this == &G4coutbuf && destination != 0) {
00131     result=  destination-> ReceiveG4cout(stringToSend);
00132 
00133   } else if(this == &G4cerrbuf && destination != 0) {
00134     result=  destination-> ReceiveG4cerr(stringToSend);
00135 
00136   } else if(this == &G4coutbuf && destination == 0) {
00137     std::cout << stringToSend << std::flush;
00138     result= 0;
00139 
00140   } else if(this == &G4cerrbuf && destination == 0) {
00141     std::cerr << stringToSend << std::flush;
00142     result= 0;
00143   }
00144 
00145   return result;
00146 }

void G4strstreambuf::SetDestination ( G4coutDestination dest  )  [inline]

Definition at line 116 of file G4strstreambuf.icc.

Referenced by G4UImanager::SetCoutDestination().

00118 {
00119   destination= dest;
00120 }

G4int G4strstreambuf::sync (  )  [inline, virtual]

Definition at line 96 of file G4strstreambuf.icc.

References ReceiveString().

Referenced by overflow().

00098 {
00099   buffer[count] = '\0';
00100   count= 0;
00101   return ReceiveString();
00102 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:27 2013 for Geant4 by  doxygen 1.4.7