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

Side by Side Diff: sdk/lib/io/input_stream.dart

Issue 12313057: Remove old InputStream and OutputStream classes from dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/io_patch.dart ('k') | sdk/lib/io/io.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of dart.io;
6
7 /**
8 * Basic input stream which supplies binary data.
9 *
10 * Input streams are used to read data sequentially from some data
11 * source. All input streams are non-blocking. They each have a number
12 * of read calls which will always return without any IO related
13 * blocking. If the requested data is not available a read call will
14 * return `null`. All input streams have one or more handlers which
15 * will trigger when data is available.
16 *
17 * The following example shows a data handler in an ordinary input
18 * stream which will be called when some data is available and a call
19 * to read will not return `null`.
20 *
21 * InputStream input = ...
22 * input.onData = () {
23 * var data = input.read();
24 * ...
25 * };
26 *
27 * If for some reason the data from an input stream cannot be handled
28 * by the application immediately setting the data handler to `null`
29 * will avoid further callbacks until it is set to a function
30 * again. While the data handler is not active system flow control
31 * will be used to avoid buffering more data than needed.
32 *
33 * Always set up appropriate handlers when using input streams.
34 *
35 */
36 abstract class InputStream {
37 /**
38 * Reads data from the stream. Returns a system allocated buffer
39 * with up to [len] bytes. If no value is passed for [len] all
40 * available data will be returned. If no data is available null will
41 * be returned.
42 */
43 List<int> read([int len]);
44
45 /**
46 * Reads up to [len] bytes into buffer [buffer] starting at offset
47 * [offset]. Returns the number of bytes actually read which might
48 * be zero. If [offset] is not specified 0 is used. If [len] is not
49 * specified the length of [buffer] is used.
50 */
51 int readInto(List<int> buffer, [int offset, int len]);
52
53 /**
54 * Returns the number of bytes available for immediate reading.
55 */
56 int available();
57
58 /**
59 * Pipe the content of this input stream directly to the output
60 * stream [output]. The default behavior is to close the output when
61 * all the data from the input stream have been written. Specifying
62 * `false` for the optional argument [close] keeps the output
63 * stream open after writing all data from the input stream.
64 */
65 void pipe(OutputStream output, {bool close: true});
66
67 /**
68 * Close the underlying communication channel to avoid getting any
69 * more data. In normal situations, where all data is read from the
70 * stream until the close handler is called, calling [close] is not
71 * required. When [close] is used the close handler will still be
72 * called.
73 */
74 void close();
75
76 /**
77 * Returns whether the stream is closed. There will be no more data
78 * to read.
79 */
80 bool get closed;
81
82 /**
83 * Sets the handler that gets called when data is available.
84 */
85 void set onData(void callback());
86
87 /**
88 * Sets the handler that gets called when there will be no more data
89 * available in the stream.
90 */
91 void set onClosed(void callback());
92
93 /**
94 * Sets the handler that gets called when the underlying
95 * communication channel gets into some kind of error situation.
96 */
97 void set onError(void callback(e));
98 }
99
100
101 /**
102 * String encodings.
103 */
104 class Encoding {
105 static const Encoding UTF_8 = const Encoding._internal("UTF-8");
106 static const Encoding ISO_8859_1 = const Encoding._internal("ISO-8859-1");
107 static const Encoding ASCII = const Encoding._internal("ASCII");
108 /**
109 * SYSTEM encoding is the current code page on Windows and UTF-8 on
110 * Linux and Mac.
111 */
112 static const Encoding SYSTEM = const Encoding._internal("SYSTEM");
113 const Encoding._internal(String this.name);
114 final String name;
115 }
116
117
118 class StreamException implements Exception {
119 const StreamException([String this.message = ""]);
120 const StreamException.streamClosed() : message = "Stream closed";
121 String toString() => "StreamException: $message";
122 final String message;
123 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/lib/io_patch.dart ('k') | sdk/lib/io/io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698