[commit] r1234 - trunk/GME/Common

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Thu Mar 31 10:17:25 CDT 2011


Author: ksmyth
Date: Thu Mar 31 10:17:24 2011
New Revision: 1234

Log:
wstring Format

Modified:
   trunk/GME/Common/CommonStl.cpp
   trunk/GME/Common/CommonStl.h

Modified: trunk/GME/Common/CommonStl.cpp
==============================================================================
--- trunk/GME/Common/CommonStl.cpp	Thu Mar 31 10:15:57 2011	(r1233)
+++ trunk/GME/Common/CommonStl.cpp	Thu Mar 31 10:17:24 2011	(r1234)
@@ -22,3 +22,20 @@
 	s.resize(len);
 }
 
+void vFormat(std::wstring &s, const wchar_t *format, va_list args)
+{
+	const int maxsize = 1024;
+
+	s.resize(maxsize);
+	int len = _vsnwprintf(&s[0], maxsize-1, format, args);
+	ASSERT( len <= maxsize-1 );
+
+	if( len < 0 )
+	{
+		ASSERT(false);	// output was truncated
+		len = maxsize-1;
+	}
+
+	s.resize(len);
+}
+

Modified: trunk/GME/Common/CommonStl.h
==============================================================================
--- trunk/GME/Common/CommonStl.h	Thu Mar 31 10:15:57 2011	(r1233)
+++ trunk/GME/Common/CommonStl.h	Thu Mar 31 10:17:24 2011	(r1234)
@@ -48,6 +48,7 @@
 }
 
 void vFormat(std::string &s, const char *format, va_list args);
+void vFormat(std::wstring &s, const wchar_t *format, va_list args);
 
 inline void Format(std::string &s, const char *format, ...)
 {
@@ -57,6 +58,14 @@
 	vFormat(s, format, args);
 }
 
+inline void Format(std::wstring &s, const wchar_t *format, ...)
+{
+	va_list args;
+	va_start(args, format);
+
+	vFormat(s, format, args);
+}
+
 typedef wchar_t* bstr_iterator;
 typedef const wchar_t* bstr_const_iterator;
 


More information about the gme-commit mailing list