From 2e5344109da2abc59a7882521ea8378ca01c174c Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Sun, 10 Aug 2014 16:16:35 -0700 Subject: Properly adding little and big endian versions of writes, plus a few other tweaks. --- includes/Handle.h | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'includes/Handle.h') diff --git a/includes/Handle.h b/includes/Handle.h index 1cbcabf..83884ef 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -59,9 +59,9 @@ class Handle { virtual ssize_t read(void * buf, size_t count) throw (GeneralException) WARN_UNUSED_RESULT; virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) WARN_UNUSED_RESULT; virtual void rseek(off64_t offset, int whence = SEEK_SET) throw (GeneralException); - virtual void wseek(off64_t offset, int whence = SEEK_SET) throw (GeneralException); + virtual void wseek(off64_t offset, int whence = SEEK_SET) throw (GeneralException) { return rseek(offset, whence); } virtual off64_t rtell() throw (GeneralException); - virtual off64_t wtell() throw (GeneralException); + virtual off64_t wtell() throw (GeneralException) { return rtell(); } virtual off64_t getSize() { return -1; } virtual time_t getMTime() { return -1; } virtual bool isPendingComplete() { return true; } @@ -101,7 +101,7 @@ class Handle { Future readLEI32(); Future readLEI64(); - Future writeU8(uint8_t); + Future writeU8 (uint8_t); Future writeU16(uint16_t); Future writeU32(uint32_t); Future writeU64(uint64_t); @@ -110,9 +110,23 @@ class Handle { Future writeI32(int32_t); Future writeI64(int64_t); + Future writeBEU16(uint16_t); + Future writeBEU32(uint32_t); + Future writeBEU64(uint64_t); + Future writeBEI16(int16_t); + Future writeBEI32(int32_t); + Future writeBEI64(int64_t); + + Future writeLEU16(uint16_t); + Future writeLEU32(uint32_t); + Future writeLEU64(uint64_t); + Future writeLEI16(int16_t); + Future writeLEI32(int32_t); + Future writeLEI64(int64_t); + // these need to be changed into Future<>s template - ssize_t writeString(const char (&str)[L]) WARN_UNUSED_RESULT; + ssize_t writeString(const char (&str)[L]) WARN_UNUSED_RESULT { return writeString(str, L - 1); } ssize_t writeString(const String & str) WARN_UNUSED_RESULT { return forceWrite(str.to_charp(), str.strlen()); } ssize_t writeString(const char * str, ssize_t len) WARN_UNUSED_RESULT { return forceWrite(str, len); } ssize_t forceRead(void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) WARN_UNUSED_RESULT; @@ -143,10 +157,7 @@ class Handle { Handle & operator=(const Handle &) = delete; }; -template -ssize_t Handle::writeString(const char (&str)[L]) { return writeString(str, L - 1); } - -class HPrinter : public Handle { + class HPrinter : public Handle { public: virtual void close() throw (GeneralException) { } virtual bool isClosed() { return false; } @@ -197,7 +208,7 @@ class IO : public IOBase { class SeekableHandle : public Handle { public: SeekableHandle() : m_wOffset(0), m_rOffset(0) { } - virtual bool canSeek(); + virtual bool canSeek() { return true; } virtual void rseek(off64_t offset, int whence = SEEK_SET) throw (GeneralException); virtual void wseek(off64_t offset, int whence = SEEK_SET) throw (GeneralException); virtual off64_t rtell() throw (GeneralException); -- cgit v1.2.3