[ATL] Add CString::AppendFormat

This commit is contained in:
Mark Jansen 2023-04-12 22:21:41 +02:00
parent 28a305e26a
commit 9c8580a1e0
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
2 changed files with 50 additions and 14 deletions

View file

@ -749,6 +749,23 @@ public:
return CStringT(CThisSimpleString::GetString() + nLength - nCount, nCount);
}
void __cdecl AppendFormat(UINT nFormatID, ...)
{
va_list args;
va_start(args, nFormatID);
CStringT formatString;
if (formatString.LoadString(nFormatID))
AppendFormatV(formatString, args);
va_end(args);
}
void __cdecl AppendFormat(PCXSTR pszFormat, ...)
{
va_list args;
va_start(args, pszFormat);
AppendFormatV(pszFormat, args);
va_end(args);
}
void __cdecl Format(UINT nFormatID, ...)
{
@ -768,6 +785,16 @@ public:
va_end(args);
}
void AppendFormatV(PCXSTR pszFormat, va_list args)
{
int nLength = StringTraits::FormatV(NULL, pszFormat, args);
int nCurrent = CThisSimpleString::GetLength();
PXSTR pszBuffer = CThisSimpleString::GetBuffer(nLength + nCurrent);
StringTraits::FormatV(pszBuffer + nCurrent, pszFormat, args);
CThisSimpleString::ReleaseBufferSetLength(nLength + nCurrent);
}
void FormatV(PCXSTR pszFormat, va_list args)
{
int nLength = StringTraits::FormatV(NULL, pszFormat, args);