From b9e2cb295e8f53f0311d8e3b5b0edf69bb76ea78 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 19 Nov 2011 23:49:49 -0800 Subject: Having String.set returning this. --- includes/BString.h | 6 +++--- src/BString.cc | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/includes/BString.h b/includes/BString.h index 8242af8..b5527d7 100644 --- a/includes/BString.h +++ b/includes/BString.h @@ -26,9 +26,9 @@ class String : private std::string { String(const String & s) : std::string(s) { } String(const std::string & s) : std::string(s) { } - void set(const char * fmt, va_list); - void set(const char * fmt, ...) { va_list ap; va_start(ap, fmt); set(fmt, ap); va_end(ap); } - void set(const String & fmt, ...) { va_list ap; va_start(ap, fmt); set(fmt.to_charp(), ap); va_end(ap); } + String & set(const char * fmt, va_list); + String & set(const char * fmt, ...) { va_list ap; va_start(ap, fmt); set(fmt, ap); va_end(ap); return *this; } + String & set(const String & fmt, ...) { va_list ap; va_start(ap, fmt); set(fmt.to_charp(), ap); va_end(ap); return *this; } int scanf(const char * fmt, va_list ap) const { return ::vsscanf(c_str(), fmt, ap); } int scanf(const char * fmt, ...) const { va_list ap; va_start(ap, fmt); int r = scanf(fmt, ap); va_end(ap); return r; } diff --git a/src/BString.cc b/src/BString.cc index 74156bf..74bc7d9 100644 --- a/src/BString.cc +++ b/src/BString.cc @@ -4,7 +4,7 @@ #include "Printer.h" #include "BString.h" -void Balau::String::set(const char * fmt, va_list ap) { +Balau::String & Balau::String::set(const char * fmt, va_list ap) { unsigned int l; #ifdef _WIN32 // Microsoft is stupid. @@ -18,6 +18,8 @@ void Balau::String::set(const char * fmt, va_list ap) { assign(t, l); free(t); #endif + + return *this; } int Balau::String::strchrcnt(char c) const { -- cgit v1.2.3