Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: include/core/SkStream.h

Issue 1044953002: Add a method to read a stream without advancing it. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Stop declaring parameters I do not use. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkStream.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkStream.h
diff --git a/include/core/SkStream.h b/include/core/SkStream.h
index c227765b363624afbf7a3f98f39d480c7f05726d..4c9c461e6480c27da8fa76a3c7a37d4d309d9853 100644
--- a/include/core/SkStream.h
+++ b/include/core/SkStream.h
@@ -63,6 +63,20 @@ public:
return this->read(NULL, size);
}
+ /**
+ * Attempt to peek at size bytes.
+ * If this stream supports peeking, and it can peek size bytes, copy size
+ * bytes into buffer, and return true.
+ * If the stream does not support peeking, or cannot peek size bytes,
+ * return false and leave buffer unchanged.
+ * The stream is guaranteed to be in the same visible state after this
+ * call, regardless of success or failure.
+ * @param buffer Must not be NULL. Destination to copy bytes.
+ * @param size Number of bytes to copy.
+ * @return Whether the peek was performed.
+ */
+ virtual bool peek(void* /* buffer */, size_t /* size */) const { return false; }
+
/** Returns true when all the bytes in the stream have been read.
* This may return true early (when there are no more bytes to be read)
* or late (after the first unsuccessful read).
@@ -319,6 +333,8 @@ public:
size_t read(void* buffer, size_t size) override;
bool isAtEnd() const override;
+ bool peek(void* buffer, size_t size) const override;
+
bool rewind() override;
SkMemoryStream* duplicate() const override;
« no previous file with comments | « no previous file | src/core/SkStream.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698