From 60589fcd0c7afc4f4cf0d832fd603ae75bc9c71a Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 13 Aug 2013 06:50:21 +0200 Subject: Cleaning up the Handle API a bit. --- includes/Handle.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'includes') diff --git a/includes/Handle.h b/includes/Handle.h index fdadef5..b167256 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -44,9 +44,8 @@ class Handle { virtual bool canSeek(); virtual bool canRead(); virtual bool canWrite(); - virtual ssize_t read(void * buf, size_t count) throw (GeneralException); - virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); - template void writeString(const char (&str)[L]) { writeString(str, L - 1); } + virtual ssize_t read(void * buf, size_t count) throw (GeneralException) __attribute__((warn_unused_result)); + virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) __attribute__((warn_unused_result)); virtual void rseek(off_t offset, int whence = SEEK_SET) throw (GeneralException); virtual void wseek(off_t offset, int whence = SEEK_SET) throw (GeneralException); virtual off_t rtell() throw (GeneralException); @@ -77,12 +76,12 @@ class Handle { Future writeI64(int64_t); // these need to be changed into Future<>s - ssize_t write(const String & str) { return write(str.to_charp(), str.strlen()); } - void writeString(const char * str, ssize_t len) { if (len < 0) len = strlen(str); forceWrite(str, len); } - void writeString(const String & str) { forceWrite(str.to_charp(), str.strlen()); } - ssize_t forceRead(void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException); - ssize_t forceWrite(const void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException); - ssize_t forceWrite(const String & str) { return forceWrite(str.to_charp(), str.strlen()); } + template + ssize_t writeString(const char (&str)[L]) { return writeString(str, L - 1); } + ssize_t writeString(const String & str) __attribute__((warn_unused_result)) { return forceWrite(str.to_charp(), str.strlen()); } + ssize_t writeString(const char * str, ssize_t len) __attribute__((warn_unused_result)) { return forceWrite(str, len); } + ssize_t forceRead(void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) __attribute__((warn_unused_result)); + ssize_t forceWrite(const void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) __attribute__((warn_unused_result)); protected: Handle() { } -- cgit v1.2.3