aboutsummaryrefslogtreecommitdiff
path: root/common/stream.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/stream.h')
-rw-r--r--common/stream.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/common/stream.h b/common/stream.h
index abe5192b70..30107720dc 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -103,6 +103,14 @@ public:
flush();
}
+ /**
+ * Obtains the current value of the stream position indicator of the
+ * stream.
+ *
+ * @return the current position indicator, or -1 if an error occurred.
+ */
+ virtual int32 pos() const = 0;
+
// The remaining methods all have default implementations; subclasses
// need not (and should not) overload them.
@@ -394,6 +402,22 @@ public:
#endif
/**
+ * Read a 32-bit floating point value stored in little endian (LSB first)
+ * order from the stream and return it.
+ * Performs no error checking. The return value is undefined
+ * if a read error occurred (for which client code can check by
+ * calling err() and eos() ).
+ */
+ FORCEINLINE float readFloatLE() {
+ uint32 n = readUint32LE();
+ float f;
+
+ memcpy(&f, &n, 4);
+
+ return f;
+ }
+
+ /**
* Read the specified amount of data into a malloc'ed buffer
* which then is wrapped into a MemoryReadStream.
* The returned stream might contain less data than requested,
@@ -490,6 +514,15 @@ public:
* err() or eos() to determine whether an exception occurred.
*/
virtual String readLine();
+
+ /**
+ * Print a hexdump of the stream while maintaing position. The number
+ * of bytes per line is customizable.
+ * @param len the length of that data
+ * @param bytesPerLine number of bytes to print per line (default: 16)
+ * @param startOffset shift the shown offsets by the starting offset (default: 0)
+ */
+ void hexdump(int len, int bytesPerLine = 16, int startOffset = 0);
};
/**