BString: Add ScanWithFormat convenience method.

This commit is contained in:
Michael Lotz 2014-11-02 11:36:21 +01:00
parent 969af8044a
commit 3fe7b3f72c
2 changed files with 25 additions and 0 deletions

View File

@ -61,6 +61,12 @@ public:
va_list args)
__attribute__((__format__(__printf__, 2, 0)));
int ScanWithFormat(const char* format, ...)
__attribute__((__format__(__scanf__, 2, 3)));
int ScanWithFormatVarArgs(const char* format,
va_list args)
__attribute__((__format__(__scanf__, 2, 0)));
// Substring copying
BString& CopyInto(BString& into, int32 fromOffset,
int32 length) const;

View File

@ -474,6 +474,25 @@ BString::SetToFormatVarArgs(const char* format, va_list args)
}
int
BString::ScanWithFormat(const char* format, ...)
{
va_list args;
va_start(args, format);
int result = ScanWithFormatVarArgs(format, args);
va_end(args);
return result;
}
int
BString::ScanWithFormatVarArgs(const char* format, va_list args)
{
return vsscanf(fPrivateData, format, args);
}
// #pragma mark - Substring copying