diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2012-02-28 04:57:12 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2012-02-28 04:57:12 +0100 |
commit | 3998f46d06ec5235ade776ec8615e081dd909920 (patch) | |
tree | bed2b0d0fe42f6461e8315f26b7df5469675a211 | |
parent | 89b50a242479f74fcbe48c64f2458a26adeab548 (diff) |
Being better at handling constant strings in Handle's writes.
-rw-r--r-- | includes/Handle.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/includes/Handle.h b/includes/Handle.h index 1b04556..fede9c7 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -40,7 +40,8 @@ class Handle { virtual const char * getName() = 0; virtual ssize_t read(void * buf, size_t count) throw (GeneralException); virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); - void writeString(const char * str, ssize_t len = -1) { if (len < 0) len = strlen(str); forceWrite(str, len); } + template <ssize_t L> void writeString(const char str[L]) { writeString(str, L - 1); } + 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()); } void seek(off_t offset, int whence = SEEK_SET) { rseek(offset, whence); } virtual void rseek(off_t offset, int whence = SEEK_SET) throw (GeneralException); |