GME
13
|
00001 00002 #include "stdafx.h" 00003 #include "CommonStl.h" 00004 #include <stdio.h> 00005 00006 // --------------------------- string 00007 00008 void vFormat(std::string &s, const char *format, va_list args) 00009 { 00010 const int maxsize = 1024; 00011 00012 s.resize(maxsize); 00013 int len = _vsnprintf(&s[0], maxsize-1, format, args); 00014 ASSERT( len <= maxsize-1 ); 00015 00016 if( len < 0 ) 00017 { 00018 ASSERT(false); // output was truncated 00019 len = maxsize-1; 00020 } 00021 00022 s.resize(len); 00023 } 00024 00025 void vFormat(std::wstring &s, const wchar_t *format, va_list args) 00026 { 00027 const int maxsize = 1024; 00028 00029 s.resize(maxsize); 00030 int len = _vsnwprintf(&s[0], maxsize-1, format, args); 00031 ASSERT( len <= maxsize-1 ); 00032 00033 if( len < 0 ) 00034 { 00035 ASSERT(false); // output was truncated 00036 len = maxsize-1; 00037 } 00038 00039 s.resize(len); 00040 } 00041