Index: runtime/bin/input_stream.dart |
diff --git a/runtime/bin/input_stream.dart b/runtime/bin/input_stream.dart |
index 48320138d136e70f4d746a33113404c3bbb1ee70..1ea961bf918182d84231ba5c53284bcce034a87c 100644 |
--- a/runtime/bin/input_stream.dart |
+++ b/runtime/bin/input_stream.dart |
@@ -22,3 +22,66 @@ interface InputStream { |
*/ |
void readUntil(List<int> pattern, void callback(List<int> buffer)); |
} |
+ |
+ |
+interface InputStream2 { |
+ /** |
+ * Reads as much data as is available from the stream. If no data is |
+ * available null will be returned. |
+ */ |
+ List<int> read(); |
+ |
+ /** |
+ * 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(int error)); |
+} |
+ |
+ |
+interface StringInputStream factory _StringInputStream { |
+ /** |
+ * Decodes a binary input stream into characters using the specified |
+ * encoding. |
+ */ |
+ StringInputStream(InputStream2 input, [String encoding]); |
+ |
+ /** |
+ * Reads as many characters as is available from the stream. If no data is |
+ * available null will be returned. |
+ */ |
+ String read(); |
+ |
+ /** |
+ * 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()); |
+} |
+ |
+ |
+class StreamException implements Exception { |
+ const StreamException([String this.message = ""]); |
+ String toString() => "StreamException: $message"; |
+ |
+ /* |
+ * Contains the exception message. |
+ */ |
+ final String message; |
+} |