| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

FormString.cc

Go to the documentation of this file.
00001 #include "../include/FormString.hh"
00002 #include <stdarg.h>
00003 #include <iostream>
00004 #include <cstdio>
00005 
00006 using namespace Logging;
00007 
00008 std::string Logging::FormString(const char* fmt, ...)
00009 {
00010   static int sBufSize = 100;
00011   static char* sBuffer = new char[sBufSize];
00012   
00013   va_list ap;
00014   va_start(ap,fmt);
00015   int res = vsnprintf(sBuffer, sBufSize, fmt, ap);
00016   va_end(ap);
00017         if(res >= sBufSize) {
00018           sBufSize = res+20;
00019     //std::cerr << "Increasing buffer size to " << sBufSize << std::endl;
00020           delete [] sBuffer;
00021     sBuffer = new char[sBufSize];
00022     
00023     // And try again.
00024     va_list ap2;
00025     va_start(ap2,fmt);
00026     vsnprintf(sBuffer, sBufSize, fmt, ap2);
00027     va_end(ap2);    
00028   }
00029         
00030   return std::string(sBuffer);  
00031 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:06:22 2011 for Log by doxygen 1.4.7