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

Unified Diff: runtime/bin/input_stream.dart

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 years, 2 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 | « runtime/bin/file_impl.dart ('k') | runtime/bin/process_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/input_stream.dart
diff --git a/runtime/bin/input_stream.dart b/runtime/bin/input_stream.dart
index 48320138d136e70f4d746a33113404c3bbb1ee70..e7394aa44b252201867e61098e89dae683e73297 100644
--- a/runtime/bin/input_stream.dart
+++ b/runtime/bin/input_stream.dart
@@ -10,15 +10,105 @@
*/
interface InputStream {
/**
- * Reads [len] bytes into [buffer] buffer starting at [offset] offset.
- * [callback] callback is invoked on completion unless it is null.
+ * Reads data from the stream. Returns a system allocated buffer
+ * with up to [len] bytes. If no value is passed for [len] all
+ * available data will be returned. If no data is available null will
+ * be returned.
*/
- bool read(List<int> buffer, int offset, int len, void callback());
+ List<int> read([int len]);
/**
- * Reads data from the stream into a buffer until a given [pattern] occurs and
- * hands that buffer over as an input to the registered [callback].
- * The callback is not invoked if a read error occurs.
+ * Reads up to [len] bytes into buffer [buffer] starting at offset
+ * [offset]. Returns the number of bytes actually read which might
+ * be zero. If [offset] is not specified 0 is used. If [len] is not
+ * specified the length of [buffer] is used.
*/
- void readUntil(List<int> pattern, void callback(List<int> buffer));
+ int readInto(List<int> buffer, [int offset, int len]);
+
+ /**
+ * Returns the number of bytes available for immediate reading.
+ */
+ int available();
+
+ /**
+ * Returns whether the stream has been closed. There might still be
+ * more data to read.
+ */
+ bool closed();
+
+ /**
+ * Sets the data which handler gets called when data is available.
+ */
+ void set dataHandler(void callback());
+
+ /**
+ * The close handler gets called when the underlying communication
+ * channel is closed and no more data will become available. Not all
+ * types of communication channels will emit close events.
+ */
+ void set closeHandler(void callback());
+
+ /**
+ * The error handler gets called when the underlying communication
+ * channel gets into some kind of error situation.
+ */
+ void set errorHandler(void callback());
+}
+
+
+interface StringInputStream factory _StringInputStream {
+ /**
+ * Decodes a binary input stream into characters using the specified
+ * encoding.
+ */
+ StringInputStream(InputStream input, [String encoding]);
+
+ /**
+ * Reads as many characters as is available from the stream. If no data is
+ * available null will be returned.
+ */
+ String read();
+
+ /**
+ * Reads the next line from the stream. The line ending characters
+ * will not be part og the returned string. If a full line is not
+ * available null will be returned.
+ */
+ String readLine();
+
+ /**
+ * Returns whether the stream has been closed. There might still be
+ * more data to read.
+ */
+ bool get closed();
+
+ /**
+ * Returns the encoding used to decode the binary data into characters.
+ */
+ String get encoding();
+
+ /**
+ * The data handler gets called when data is available.
+ */
+ void set dataHandler(void callback());
+
+ /**
+ * The close handler gets called when the underlying communication
+ * channel is closed and no more data will become available. Not all
+ * types of communication channels will emit close events.
+ */
+ void set closeHandler(void callback());
+
+ /**
+ * The error handler gets called when the underlying communication
+ * channel gets into some kind of error situation.
+ */
+ void set errorHandler(void callback());
+}
+
+
+class StreamException implements Exception {
+ const StreamException([String this.message = ""]);
+ String toString() => "StreamException: $message";
+ final String message;
}
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/process_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698