Printf-like assignment method for BString.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40695 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström 2011-02-26 07:26:19 +00:00
parent 9f0f6fcd99
commit c91c2de735

View File

@ -424,6 +424,25 @@ BString::AdoptChars(BString& string, int32 charCount)
}
BString&
BString::SetToArguments(const char *format, ...)
{
va_list arg;
va_start(arg, format);
int32 bytes = vsnprintf(LockBuffer(0), 0, format, arg);
va_end(arg);
UnlockBuffer(0);
va_list arg2;
va_start(arg2, format);
bytes = vsnprintf(LockBuffer(bytes), bytes + 1, format, arg2);
va_end(arg2);
UnlockBuffer(bytes);
return *this;
}
// #pragma mark - Substring copying