diff options
author | Max Horn | 2010-11-23 22:26:27 +0000 |
---|---|---|
committer | Max Horn | 2010-11-23 22:26:27 +0000 |
commit | 382982d6e3b99ae8890133e08c063332c00aa221 (patch) | |
tree | fcdb71b3faff1ce4543b36b3ce2c3fbc8e6d7907 /common/memstream.h | |
parent | c9fdaa74178c702d7f6ce136cedc9ea1fbbde6ca (diff) | |
download | scummvm-rg350-382982d6e3b99ae8890133e08c063332c00aa221.tar.gz scummvm-rg350-382982d6e3b99ae8890133e08c063332c00aa221.tar.bz2 scummvm-rg350-382982d6e3b99ae8890133e08c063332c00aa221.zip |
COMMON: Add ReadStreamEndian mixin class
svn-id: r54438
Diffstat (limited to 'common/memstream.h')
-rw-r--r-- | common/memstream.h | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/common/memstream.h b/common/memstream.h index 5ba259b842..d6a55c3b75 100644 --- a/common/memstream.h +++ b/common/memstream.h @@ -76,35 +76,13 @@ public: /** - * This is a wrapper around MemoryReadStream, but it adds non-endian + * This is a MemoryReadStream subclass which adds non-endian * read methods whose endianness is set on the stream creation. */ -class MemoryReadStreamEndian : public MemoryReadStream { -private: - const bool _bigEndian; - +class MemoryReadStreamEndian : public MemoryReadStream, public ReadStreamEndian { public: - MemoryReadStreamEndian(const byte *buf, uint32 len, bool bigEndian = false) : MemoryReadStream(buf, len), _bigEndian(bigEndian) {} - - uint16 readUint16() { - uint16 val; - read(&val, 2); - return (_bigEndian) ? TO_BE_16(val) : TO_LE_16(val); - } - - uint32 readUint32() { - uint32 val; - read(&val, 4); - return (_bigEndian) ? TO_BE_32(val) : TO_LE_32(val); - } - - FORCEINLINE int16 readSint16() { - return (int16)readUint16(); - } - - FORCEINLINE int32 readSint32() { - return (int32)readUint32(); - } + MemoryReadStreamEndian(const byte *buf, uint32 len, bool bigEndian = false) + : MemoryReadStream(buf, len), ReadStreamEndian(bigEndian) {} }; /** |