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

Unified Diff: runtime/bin/input_stream.dart

Issue 8698018: Update of the input stream interface (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 | no next file » | 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 e9f496b66b2c0b847f153ce8d5eb40ea29d257cc..36bd40eb7a12e2f7495e9327831082f2bee92c9c 100644
--- a/runtime/bin/input_stream.dart
+++ b/runtime/bin/input_stream.dart
@@ -3,90 +3,84 @@
// BSD-style license that can be found in the LICENSE file.
/**
- * Input is read from a given input stream. Such an input stream can
- * be an endpoint, e.g., a socket or a file, or another input stream.
- * Multiple input streams can be chained together to operate collaboratively
- * on a given input.
+ * An input stream is used to read data sequentially from a data source.
*/
interface InputStream {
/**
- * 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.
+ * Reads data from the stream. If no encoding is set fir the stream
Mads Ager (google) 2011/11/30 10:44:07 fir -> for
+ * it returns a system allocated buffer with up to [len] bytes. If
+ * encoding is set it returns a [String] with up to [len]
+ * characters. If no value is passed for [len] all available data
+ * will be returned. If no data is available null will be returned.
*/
- List<int> read([int len]);
+ Object read([int len]);
+
+ /**
+ * Reads a line of characters from the stream. If a full line is not
+ * available the return value is null. If no encoding is set for the
+ * stream an exception is thrown.
+ */
+ String readLine();
/**
* 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.
+ * specified the length of [buffer] is used. If an encoding is set
+ * for the stream an exception is thrown.
*/
int readInto(List<int> buffer, [int offset, int len]);
/**
- * Returns the number of bytes available for immediate reading.
- */
- int available();
-
- /**
- * Returns whether the stream is closed. There will be no more data
- * to read.
+ * Reads data from the stream until the pattern [pattern] is
+ * encountered.
*/
- bool get closed();
+ Object readUntil(Object pattern);
Mads Ager (google) 2011/11/30 10:44:07 Should pattern have type Pattern?
/**
- * Sets the handler that gets called when data is available.
+ * Pipe the data from this input stream directly to the
+ * [destination] [OutputStream]. After the input stream has been
+ * connected to an output stream data cannot be read from it
+ * anymore. When there is no more data in the input stream [close]
+ * will be called on the connected output stream.
*/
- void set dataHandler(void callback());
+ void pipe(OutputStream destination);
/**
- * Sets the handler that gets called when there will be no more data
- * available in the stream.
- */
- void set closeHandler(void callback());
-
- /**
- * Sets the handler that gets called when the underlying
- * communication channel gets into some kind of error situation.
+ * Returns the number of bytes available for immediate reading.
Mads Ager (google) 2011/11/30 10:44:07 Hmm, bytes or characters depending on the encoding
*/
- void set errorHandler(void callback());
-}
-
+ int available();
-interface StringInputStream factory _StringInputStream {
/**
- * Decodes a binary input stream into characters using the specified
- * encoding.
+ * Sets the encoding used by the stream for turning bytes into
+ * characters. If encoding is set then calling the [read] method
+ * will return a [String] instead of a [List] of bytes. Currently
+ * the encodings "UTF-8", "ISO-8859-1" and "ASCII" are supported.
Mads Ager (google) 2011/11/30 10:44:07 Maybe there should always be an encoding? A defaul
*/
- StringInputStream(InputStream input, [String encoding]);
+ void set encoding(String encoding);
+ String get encoding();
/**
- * Reads as many characters as is available from the stream. If no data is
- * available null will be returned.
+ * Sets the minimum number of bytes required to trigger a the
Mads Ager (google) 2011/11/30 10:44:07 Again, is this bytes or characters depending on th
+ * [dataHandler] ...
*/
- String read();
+ void set chunkSize(int chunkSize);
+ int get chunkSize();
/**
- * 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.
+ * Sets the data pattern to expect before triggering the
+ * [dataHandler] ...
*/
- String readLine();
+ void set dataPattern(Object pattern);
+ get dataPattern();
/**
- * Returns whether the stream has been closed. There might still be
- * more data to read.
+ * Returns whether the stream is closed. There will be no more data
+ * to read.
*/
bool get closed();
/**
- * Returns the encoding used to decode the binary data into characters.
- */
- String get encoding();
-
- /**
* Sets the handler that gets called when data is available.
*/
void set dataHandler(void callback());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698