From b199455adeb01250743ba36e13d0905980326335 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 22 Dec 2013 15:46:50 -0800 Subject: Adding formatted append to the String class. --- includes/BString.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'includes') diff --git a/includes/BString.h b/includes/BString.h index e783935..392f720 100644 --- a/includes/BString.h +++ b/includes/BString.h @@ -13,11 +13,11 @@ #include #ifdef _MSC_VER -#ifdef _WIN64 -typedef __int64 ssize_t; -#else /* _WIN64 */ -typedef _W64 int ssize_t; -#endif /* _WIN64 */ +#ifdef _WIN64 +typedef __int64 ssize_t; +#else /* _WIN64 */ +typedef _W64 int ssize_t; +#endif /* _WIN64 */ #define printfwarning(a, b) #else #define printfwarning(a, b) __attribute__((format(printf, a, b))) @@ -50,6 +50,10 @@ class String : private std::string { String & set(const char * fmt, ...) printfwarning(2, 3) { 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; } + String & append(const char * fmt, va_list) printfwarning(2, 0); + String & append(const char * fmt, ...) printfwarning(2, 3) { va_list ap; va_start(ap, fmt); append(fmt, ap); va_end(ap); return *this; } + String & append(const String & fmt, ...) { va_list ap; va_start(ap, fmt); append(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 printfwarning(2, 3) { va_list ap; va_start(ap, fmt); int r = scanf(fmt, ap); va_end(ap); return r; } int scanf(const String & fmt, ...) const { va_list ap; va_start(ap, fmt); int r = scanf(fmt.to_charp(), ap); va_end(ap); return r; } @@ -96,8 +100,8 @@ class String : private std::string { String operator+(const String & v) const { String r = *this; r += v; return r; } String operator+(const char * v) const { String r = *this; r += v; return r; } - String & operator+=(const String & v) { *this = append(v); return *this; } - String & operator+=(const char * v) { *this = append(v); return *this; } + String & operator+=(const String & v) { *this = std::string::append(v); return *this; } + String & operator+=(const char * v) { *this = std::string::append(v); return *this; } int compare(const String & v) const { return std::string::compare(v); } int compare(const char * v) const { return std::string::compare(v); } -- cgit v1.2.3 From e977ca1e5f6a10bab7af8b2736591f709783566f Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 23 Dec 2013 00:32:02 -0800 Subject: Few minor fixes... --- includes/Selectable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'includes') diff --git a/includes/Selectable.h b/includes/Selectable.h index 8667415..5dab7cb 100644 --- a/includes/Selectable.h +++ b/includes/Selectable.h @@ -26,7 +26,7 @@ class Selectable : public Handle { public: SelectableEvent(int fd, int evt = ev::READ | ev::WRITE) : m_task(NULL), m_evtType(evt), m_fd(fd) { Printer::elog(E_SELECT, "Got a new SelectableEvent at %p", this); m_evt.set(this); m_evt.set(fd, evt); } virtual ~SelectableEvent() { Printer::elog(E_SELECT, "Destroying a SelectableEvent at %p", this); m_evt.stop(); } - void stop() { Printer::elog(E_SELECT, "Stopping a SelectableEvent at %p", this); reset(); m_evt.stop(); } + void stop() { Printer::elog(E_SELECT, "Stopping a SelectableEvent at %p", this); resetMaybe(); m_evt.stop(); } private: void evt_cb(ev::io & w, int revents) { Printer::elog(E_SELECT, "Got a libev callback on a SelectableEvent at %p", this); doSignal(); } virtual void gotOwner(Task * task); -- cgit v1.2.3