hrev48211 adds 2 changesets to branch 'master' old head: 5e654f6ab87bab3407c44fbce6b6f2987e10d885 new head: 3fe7b3f72c545aae15ca08f85f5f5dad4c55817b overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=3fe7b3f+%5E5e654f6 ---------------------------------------------------------------------------- 969af80: BString: Add format attribute to SetToFormatVarArgs. 3fe7b3f: BString: Add ScanWithFormat convenience method. [ Michael Lotz <mmlr@xxxxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 27 insertions(+), 1 deletion(-) headers/os/support/String.h | 9 ++++++++- src/kits/support/String.cpp | 19 +++++++++++++++++++ ############################################################################ Commit: 969af8044aeec17f9154065f24f2b7ff8827c97c URL: http://cgit.haiku-os.org/haiku/commit/?id=969af80 Author: Michael Lotz <mmlr@xxxxxxxx> Date: Sun Nov 2 10:34:12 2014 UTC BString: Add format attribute to SetToFormatVarArgs. ---------------------------------------------------------------------------- diff --git a/headers/os/support/String.h b/headers/os/support/String.h index 9dcc88c..60e6967 100644 --- a/headers/os/support/String.h +++ b/headers/os/support/String.h @@ -58,7 +58,8 @@ public: BString& SetToFormat(const char* format, ...) __attribute__((__format__(__printf__, 2, 3))); BString& SetToFormatVarArgs(const char* format, - va_list args); + va_list args) + __attribute__((__format__(__printf__, 2, 0))); // Substring copying BString& CopyInto(BString& into, int32 fromOffset, ############################################################################ Revision: hrev48211 Commit: 3fe7b3f72c545aae15ca08f85f5f5dad4c55817b URL: http://cgit.haiku-os.org/haiku/commit/?id=3fe7b3f Author: Michael Lotz <mmlr@xxxxxxxx> Date: Sun Nov 2 10:36:21 2014 UTC BString: Add ScanWithFormat convenience method. ---------------------------------------------------------------------------- diff --git a/headers/os/support/String.h b/headers/os/support/String.h index 60e6967..9e33c3c 100644 --- a/headers/os/support/String.h +++ b/headers/os/support/String.h @@ -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; diff --git a/src/kits/support/String.cpp b/src/kits/support/String.cpp index 5b4ac34..5533f03 100644 --- a/src/kits/support/String.cpp +++ b/src/kits/support/String.cpp @@ -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