aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorEugene Sandulenko2007-09-23 09:59:10 +0000
committerEugene Sandulenko2007-09-23 09:59:10 +0000
commit9a9e9d21a8a0d80982f38d561275051bf5108f40 (patch)
treeb564b98512778b39c4234af93ea97ccdbe1af71e /common
parent352566ee646e3a6b9399bc928d4c10a4f5a8fcc8 (diff)
downloadscummvm-rg350-9a9e9d21a8a0d80982f38d561275051bf5108f40.tar.gz
scummvm-rg350-9a9e9d21a8a0d80982f38d561275051bf5108f40.tar.bz2
scummvm-rg350-9a9e9d21a8a0d80982f38d561275051bf5108f40.zip
Moved MemoryStreamEndian from Saga to Common.
svn-id: r29038
Diffstat (limited to 'common')
-rw-r--r--common/stream.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/stream.h b/common/stream.h
index d7d96f3605..deb018aad5 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -402,6 +402,35 @@ public:
void seek(int32 offs, int whence = SEEK_SET);
};
+
+/**
+ * This is a wrapper around MemoryReadStream, but it adds non-endian
+ * read methods whose endianness is set on the stream creation.
+ */
+class MemoryReadStreamEndian : public Common::MemoryReadStream {
+private:
+public:
+ bool _bigEndian;
+ MemoryReadStreamEndian(const byte *buf, uint32 len, bool bigEndian = false) : MemoryReadStream(buf, len), _bigEndian(bigEndian) {}
+
+ uint16 readUint16() {
+ return (_bigEndian) ? readUint16BE(): readUint16LE();
+ }
+
+ 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 WriteStream interface for
* a plain memory block.