diff options
author | Johannes Schickel | 2008-03-27 20:53:52 +0000 |
---|---|---|
committer | Johannes Schickel | 2008-03-27 20:53:52 +0000 |
commit | ff2ba585b3efb3b4f37b287fcfbb66db9ac9c8e7 (patch) | |
tree | e0cf65dee054278b20948230af685927e1a920d9 | |
parent | 639c4597cd17e6accdbb779db4cb8bb0ed350f53 (diff) | |
download | scummvm-rg350-ff2ba585b3efb3b4f37b287fcfbb66db9ac9c8e7.tar.gz scummvm-rg350-ff2ba585b3efb3b4f37b287fcfbb66db9ac9c8e7.tar.bz2 scummvm-rg350-ff2ba585b3efb3b4f37b287fcfbb66db9ac9c8e7.zip |
Implemented SeekableSubReadStreamEndian moddeled after MemoryReadStreamEndian.
svn-id: r31270
-rw-r--r-- | common/stream.h | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/common/stream.h b/common/stream.h index 431acd3904..2aec133f61 100644 --- a/common/stream.h +++ b/common/stream.h @@ -359,6 +359,36 @@ public: }; /** + * This is a wrapper around SeekableSubReadStream, but it adds non-endian + * read methods whose endianness is set on the stream creation. + */ +class SeekableSubReadStreamEndian : public SeekableSubReadStream { +public: + bool _bigEndian; + + SeekableSubReadStreamEndian(SeekableReadStream *parentStream, uint32 begin, uint32 end, bool bigEndian = false, bool disposeParentStream = false) + : SeekableSubReadStream(parentStream, begin, end, disposeParentStream), _bigEndian(bigEndian) { + } + + inline uint16 readUint16() { + return (_bigEndian) ? readUint16BE() : readUint16LE(); + } + + inline uint32 readUint32() { + return (_bigEndian) ? readUint32BE() : readUint32LE(); + } + + inline int16 readSint16() { + return (int16)readUint16(); + } + + inline int32 readSint32() { + return (int32)readUint32(); + } +}; + + +/** * Simple memory based 'stream', which implements the ReadStream interface for * a plain memory block. */ @@ -414,11 +444,11 @@ public: MemoryReadStreamEndian(const byte *buf, uint32 len, bool bigEndian = false) : MemoryReadStream(buf, len), _bigEndian(bigEndian) {} inline uint16 readUint16() { - return (_bigEndian) ? readUint16BE(): readUint16LE(); + return (_bigEndian) ? readUint16BE() : readUint16LE(); } inline uint32 readUint32() { - return (_bigEndian) ? readUint32BE(): readUint32LE(); + return (_bigEndian) ? readUint32BE() : readUint32LE(); } inline int16 readSint16() { |