SemiDebug Class Reference

This class is used to output debugging information either to standard output or to a specified file. More...

#include <SemiGlobals.hpp>

List of all members.


Public Member Functions

 SemiDebug (char *logfilename=NULL)
 default constructor
 ~SemiDebug ()
 default destructor
void enableStdOut ()
 enable output of messages to standard-output
void enableFlush ()
 enable immediate output of messages
void doFlush ()
 flush messages in output.
void writeLogfile ()
 write all messages in vector to the output-file and close it
void writeTimestamp (char *str)
 write the current timestamp to the output-file
SemiDebugoperator<< (unsigned int n)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (int n)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (long n)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (unsigned long n)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (float f)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (double d)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (char c)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (char *str)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (const char *str)
 convert the parameter to a string and push it to the vector.
SemiDebugoperator<< (string &str)
 convert the parameter to a string and push it to the vector.

Detailed Description

This class is used to output debugging information either to standard output or to a specified file.

Author:
Klaus Schoeffmann

Definition at line 316 of file SemiGlobals.hpp.


Member Function Documentation

void SemiDebug::doFlush  ) 
 

flush messages in output.

Thereby all messages will be written immediately to the output-file (and to standard-output) Definition at line 77 of file SemiGlobals.cpp.

Referenced by operator<<(), and writeTimestamp().

00078 { 00079 cout.flush(); 00080 00081 if (logfile) { 00082 uint i = 0; 00083 while (i < log.size()) 00084 { 00085 outfile << log[i]; 00086 log.erase(log.begin()); 00087 } 00088 //force write of file 00089 outfile.close(); 00090 outfile.open(logfile, ios::app); 00091 } 00092 }

SemiDebug & SemiDebug::operator<< string &  str  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
str parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 249 of file SemiGlobals.cpp.

References doFlush(), and semifunc::replaceStr().

00250 { 00251 string strg (str); 00252 semifunc::replaceStr(strg, "\r\n", "\r \n\t", true); 00253 if (logfile) log.push_back(strg); 00254 00255 if (stdOutEnabled) cout << strg; 00256 if (shouldFlush) doFlush(); 00257 return *this; 00258 }

SemiDebug & SemiDebug::operator<< const char *  str  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
str parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 242 of file SemiGlobals.cpp.
00243 { 00244 return *this << (char*)str; 00245 }

SemiDebug & SemiDebug::operator<< char *  str  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
str parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 230 of file SemiGlobals.cpp.

References doFlush(), and semifunc::replaceStr().

00231 { 00232 string strg (str); 00233 semifunc::replaceStr(strg, "\r\n", "\r \n\t", true); 00234 if (logfile) log.push_back(strg); 00235 00236 if (stdOutEnabled) cout << strg; 00237 if (shouldFlush) doFlush(); 00238 return *this; 00239 }

SemiDebug & SemiDebug::operator<< char  c  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
c parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 219 of file SemiGlobals.cpp.

References doFlush().

00220 { 00221 if (logfile) log.push_back(semifunc::toString(c)); 00222 00223 if (stdOutEnabled) cout << c; 00224 if (shouldFlush) doFlush(); 00225 return *this; 00226 }

SemiDebug & SemiDebug::operator<< double  d  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
d parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 208 of file SemiGlobals.cpp.

References doFlush().

00209 { 00210 if (logfile) log.push_back(semifunc::toString(d)); 00211 00212 if (stdOutEnabled) cout << d; 00213 if (shouldFlush) doFlush(); 00214 return *this; 00215 }

SemiDebug & SemiDebug::operator<< float  f  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
f parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 197 of file SemiGlobals.cpp.

References doFlush().

00198 { 00199 if (logfile) log.push_back(semifunc::toString(f)); 00200 00201 if (stdOutEnabled) cout << f; 00202 if (shouldFlush) doFlush(); 00203 return *this; 00204 }

SemiDebug & SemiDebug::operator<< unsigned long  n  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
n parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 175 of file SemiGlobals.cpp.

References doFlush().

00176 { 00177 if (logfile) log.push_back(semifunc::toString(n)); 00178 00179 if (stdOutEnabled) cout << n; 00180 if (shouldFlush) doFlush(); 00181 return *this; 00182 }

SemiDebug & SemiDebug::operator<< long  n  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
n parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 186 of file SemiGlobals.cpp.

References doFlush().

00187 { 00188 if (logfile) log.push_back(semifunc::toString(n)); 00189 00190 if (stdOutEnabled) cout << n; 00191 if (shouldFlush) doFlush(); 00192 return *this; 00193 }

SemiDebug & SemiDebug::operator<< int  n  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
n parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 165 of file SemiGlobals.cpp.

References doFlush().

00166 { 00167 if (logfile) log.push_back(semifunc::toString(n)); 00168 00169 if (stdOutEnabled) cout << n; 00170 if (shouldFlush) doFlush(); 00171 return *this; 00172 }

SemiDebug & SemiDebug::operator<< unsigned int  n  ) 
 

convert the parameter to a string and push it to the vector.

if the flag stdOutEnabled is set, also output parameter to standard-out.

Parameters:
n parameter to convert to a string
Returns:
a pointer to this object itself
Definition at line 154 of file SemiGlobals.cpp.

References doFlush().

00155 { 00156 if (logfile) log.push_back(semifunc::toString(n)); 00157 00158 if (stdOutEnabled) cout << n; 00159 if (shouldFlush) doFlush(); 00160 return *this; 00161 }


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