From c49058ffb738c87271e58a76a0ecf3814db1c4ac Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Thu, 13 Mar 2014 00:03:56 +0100 Subject: Reading is no longer little endian by default. It's now having explicit little endian accessors, and a mode flag that can be toggled. --- includes/Handle.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'includes/Handle.h') diff --git a/includes/Handle.h b/includes/Handle.h index ba710b2..412c6c9 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -64,6 +64,14 @@ class Handle { virtual time_t getMTime(); virtual bool isPendingComplete() { return true; } + enum Endianness { + LITTLE_ENDIAN; + BIG_ENDIAN; + }; + + void setEndianness(Endianness endianness) { m_bigEndianMode = endianness == BIG_ENDIAN; } + Endianness getEndianness() { return m_bigEndianMode ? BIG_ENDIAN : LITTLE_ENDIAN; } + // helpers off64_t tell() { return rtell(); } void seek(off64_t offset, int whence = SEEK_SET) { rseek(offset, whence); } @@ -76,13 +84,22 @@ class Handle { Future readI16(); Future readI32(); Future readI64(); - Future readBEU16(); - Future readBEU32(); - Future readBEU64(); - Future readBEI16(); - Future readBEI32(); - Future readBEI64(); - Future writeU8(uint8_t); + + Future readBEU16(); + Future readBEU32(); + Future readBEU64(); + Future readBEI16(); + Future readBEI32(); + Future readBEI64(); + + Future readLEU16(); + Future readLEU32(); + Future readLEU64(); + Future readLEI16(); + Future readLEI32(); + Future readLEI64(); + + Future writeU8(uint8_t); Future writeU16(uint16_t); Future writeU32(uint32_t); Future writeU64(uint64_t); @@ -118,6 +135,8 @@ class Handle { std::atomic m_refCount; + bool m_bigEndianMode = false; + Handle(const Handle &) = delete; Handle & operator=(const Handle &) = delete; }; -- cgit v1.2.3