BString: Add ScanWithFormat convenience method.
This commit is contained in:
@@ -61,6 +61,12 @@ public:
|
|||||||
va_list args)
|
va_list args)
|
||||||
__attribute__((__format__(__printf__, 2, 0)));
|
__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
|
// Substring copying
|
||||||
BString& CopyInto(BString& into, int32 fromOffset,
|
BString& CopyInto(BString& into, int32 fromOffset,
|
||||||
int32 length) const;
|
int32 length) const;
|
||||||
|
|||||||
@@ -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
|
// #pragma mark - Substring copying
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user