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

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: 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 | « no previous file | runtime/bin/output_stream.dart » ('j') | runtime/bin/output_stream.dart » ('J')
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..694cf83edd7e06a31dab67d3faa9abc1cbe5391e 100644
--- a/runtime/bin/input_stream.dart
+++ b/runtime/bin/input_stream.dart
@@ -10,15 +10,74 @@
*/
interface InputStream {
dcarlson 2011/10/17 21:05:20 Is there a reason to not have a way to just regist
Søren Gjesse 2011/10/18 15:23:20 I think it will make sense to have a way of regist
/**
- * Reads [len] bytes into [buffer] buffer starting at [offset] offset.
- * [callback] callback is invoked on completion unless it is null.
+ * Reads [len] bytes from the stream. When the bytes have been read the
+ * specified [callback] is called with the data.
dcarlson 2011/10/17 21:05:20 Address EOF case.
Søren Gjesse 2011/10/18 15:23:20 The current handling of EOF is that if [len] chara
+ void readFully(int len, void callback(List<int> buffer));
dcarlson 2011/10/17 21:05:20 Seems like this is the most common case -- perhaps
Søren Gjesse 2011/10/18 15:23:20 I have not tried to split the stream interface and
+
+ /**
+ * Reads data from the stream into a buffer until the specified [pattern]
rchandia 2011/10/17 21:53:46 When I hear pattern I think RegEx'es which is not
Søren Gjesse 2011/10/18 15:23:20 Currently it is simple string matching.
+ * occurs. When the pattern occours the specified [callback] is called with
+ * the data including the pattern. If the pattern is not found before
+ * [maxLength] bytes have been received the error handler will be called.
rchandia 2011/10/17 21:53:46 How can errorHandler recover?
Søren Gjesse 2011/10/18 15:23:20 Currently not known.
+ */
dcarlson 2011/10/17 21:05:20 Also: clarify what happens when you hit EOF prior
Søren Gjesse 2011/10/18 15:23:20 Currently there will be not callback if EOF is hit
+ void readUntil(List<int> pattern,
+ void callback(List<int> buffer),
+ [int maxLength = -1]);
+
+ /**
+ * Reads as much data as is available from the stream. If no data is
+ * available null will be returned and the specified callback will
+ * be called when data becomes available.
rchandia 2011/10/17 21:53:46 What happens when readFully() is followed by read(
Søren Gjesse 2011/10/18 15:23:20 It is a problem with these different functions on
+ */
+ List<int> read(void callback());
dcarlson 2011/10/17 21:05:20 make callback optional named param?
Søren Gjesse 2011/10/18 15:23:20 Removed the callback in favor the dataHandler.
+
+ /**
+ * Close the stream. This will normally also close the underlying
rchandia 2011/10/17 21:53:46 Does this prevent further reads?
Søren Gjesse 2011/10/18 15:23:20 We should make it possible to read all data after
+ * communication channel.
+ */
+ void close();
+
+ /**
+ * The close handler gets called when the underlying communication
+ * channel gets closed. 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(StreamError error));
+}
+
+interface StringInputStream extends InputStream {
+ /**
+ * Reads [len] characters from the stream. When the bytes have been read the
+ * specified [callback] is called with the data.
+ void readFully(int len, void callback(String data));
+
+ /**
+ * Reads string data from the stream into a until the specified [pattern]
+ * occurs. When the pattern occours the specified [callback] is called with
+ * the string data including the pattern. If the pattern is not found before
+ * [maxLength] characters have been received the error handler will be
+ * called.
+ */
+ void readUntil(String pattern,
+ void callback(String data),
+ [int maxLength = -1]);
+
+ /**
+ * Reads as many characters as is available from the stream. If no data is
+ * available null will be returned and the specified callback will
+ * be called when data becomes available.
*/
- bool read(List<int> buffer, int offset, int len, void callback());
+ String read(void callback());
dcarlson 2011/10/17 21:05:20 optional param -- see above.
Søren Gjesse 2011/10/18 15:23:20 Removed the callback instead.
/**
- * 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.
+ * Sets the encoding to be used when reading string data to the
+ * stream. The default encoding is UTF-8.
*/
- void readUntil(List<int> pattern, void callback(List<int> buffer));
+ void set encoding(String encoding);
dcarlson 2011/10/17 21:05:20 getter?
Søren Gjesse 2011/10/18 15:23:20 Only getter now - removed setter.
}
« no previous file with comments | « no previous file | runtime/bin/output_stream.dart » ('j') | runtime/bin/output_stream.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698