[Scummvm-cvs-logs] SF.net SVN: scummvm: [31270] scummvm/trunk/common/stream.h

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Mar 27 21:53:52 CET 2008


Revision: 31270
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31270&view=rev
Author:   lordhoto
Date:     2008-03-27 13:53:52 -0700 (Thu, 27 Mar 2008)

Log Message:
-----------
Implemented SeekableSubReadStreamEndian moddeled after MemoryReadStreamEndian.

Modified Paths:
--------------
    scummvm/trunk/common/stream.h

Modified: scummvm/trunk/common/stream.h
===================================================================
--- scummvm/trunk/common/stream.h	2008-03-27 20:24:41 UTC (rev 31269)
+++ scummvm/trunk/common/stream.h	2008-03-27 20:53:52 UTC (rev 31270)
@@ -359,6 +359,36 @@
 };
 
 /**
+ * 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 @@
 	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() {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list