[Scummvm-git-logs] scummvm master -> 3071bb40d8773b7c24cb87a11fc8b8ea73e6284b
sev-
sev at scummvm.org
Wed Oct 26 19:20:10 CEST 2016
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3071bb40d8 COMMON: Added debug method for printing out stream contents
Commit: 3071bb40d8773b7c24cb87a11fc8b8ea73e6284b
https://github.com/scummvm/scummvm/commit/3071bb40d8773b7c24cb87a11fc8b8ea73e6284b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-10-26T19:00:13+02:00
Commit Message:
COMMON: Added debug method for printing out stream contents
Changed paths:
common/stream.cpp
common/stream.h
diff --git a/common/stream.cpp b/common/stream.cpp
index a8446a9..0877431 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -247,6 +247,19 @@ uint32 SafeSeekableSubReadStream::read(void *dataPtr, uint32 dataSize) {
return SeekableSubReadStream::read(dataPtr, dataSize);
}
+void SeekableReadStream::hexdump(int len, int bytesPerLine, int startOffset) {
+ uint pos_ = pos();
+ uint size_ = size();
+ uint toRead = MIN<uint>(len + startOffset, size_ - pos_);
+ byte *data = (byte *)calloc(toRead, 1);
+
+ read(data, toRead);
+ Common::hexdump(data, toRead, bytesPerLine, startOffset);
+
+ free(data);
+
+ seek(pos_);
+}
#pragma mark -
diff --git a/common/stream.h b/common/stream.h
index e0ffc47..3010772 100644
--- a/common/stream.h
+++ b/common/stream.h
@@ -514,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);
};
/**
More information about the Scummvm-git-logs
mailing list