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

Side by Side Diff: runtime/bin/input_stream.dart

Issue 9653026: Add writeString method to OutputStream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 years, 9 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 | « runtime/bin/http_impl.dart ('k') | runtime/bin/list_stream_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Basic input stream which supplies binary data. 6 * Basic input stream which supplies binary data.
7 * 7 *
8 * Input streams are used to read data sequentially from some data 8 * Input streams are used to read data sequentially from some data
9 * source. All input streams are non-blocking. They each have a number 9 * source. All input streams are non-blocking. They each have a number
10 * of read calls which will always return without any IO related 10 * of read calls which will always return without any IO related
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 93
94 /** 94 /**
95 * Sets the handler that gets called when the underlying 95 * Sets the handler that gets called when the underlying
96 * communication channel gets into some kind of error situation. 96 * communication channel gets into some kind of error situation.
97 */ 97 */
98 void set onError(void callback()); 98 void set onError(void callback());
99 } 99 }
100 100
101 101
102 /** 102 /**
103 * String encodings supported by [StringInputStream] and
104 * [StringOutputStream].
105 */
106 class Encoding {
107 static final Encoding UTF_8 = const Encoding("UTF-8");
108 static final Encoding ISO_8859_1 = const Encoding("ISO-8859-1");
109 static final Encoding ASCII = const Encoding("ASCII");
110 const Encoding(String this.name);
111 final String name;
112 }
113
114
115 /**
103 * A string input stream wraps a basic input stream and supplies 116 * A string input stream wraps a basic input stream and supplies
104 * string data. This data can be read either as string chunks or as 117 * string data. This data can be read either as string chunks or as
105 * lines separated by line termination character sequences. 118 * lines separated by line termination character sequences.
106 */ 119 */
107 interface StringInputStream default _StringInputStream { 120 interface StringInputStream default _StringInputStream {
108 /** 121 /**
109 * Decodes a binary input stream into characters using the specified 122 * Decodes a binary input stream into characters using the specified
110 * encoding. 123 * encoding. The default encoding is UTF-8 - [:Encoding.UTF_8:].
111 */ 124 */
112 StringInputStream(InputStream input, [String encoding]); 125 StringInputStream(InputStream input, [Encoding encoding]);
113 126
114 /** 127 /**
115 * Reads as many characters as is available from the stream. If no data is 128 * Reads as many characters as is available from the stream. If no data is
116 * available null will be returned. 129 * available null will be returned.
117 */ 130 */
118 String read(); 131 String read();
119 132
120 /** 133 /**
121 * Reads the next line from the stream. The line ending characters 134 * Reads the next line from the stream. The line ending characters
122 * will not be part of the returned string. If a full line is not 135 * will not be part of the returned string. If a full line is not
(...skipping 13 matching lines...) Expand all
136 149
137 /** 150 /**
138 * Returns whether the stream has been closed. There might still be 151 * Returns whether the stream has been closed. There might still be
139 * more data to read. 152 * more data to read.
140 */ 153 */
141 bool get closed(); 154 bool get closed();
142 155
143 /** 156 /**
144 * Returns the encoding used to decode the binary data into characters. 157 * Returns the encoding used to decode the binary data into characters.
145 */ 158 */
146 String get encoding(); 159 Encoding get encoding();
147 160
148 /** 161 /**
149 * Sets the handler that gets called when data is available. The two 162 * Sets the handler that gets called when data is available. The two
150 * handlers [onData] and [onLine] are mutually exclusive 163 * handlers [onData] and [onLine] are mutually exclusive
151 * and setting one will remove the other. 164 * and setting one will remove the other.
152 */ 165 */
153 void set onData(void callback()); 166 void set onData(void callback());
154 167
155 /** 168 /**
156 * Sets the handler that gets called when a line is available. The 169 * Sets the handler that gets called when a line is available. The
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 void set onError(void callback()); 240 void set onError(void callback());
228 } 241 }
229 242
230 243
231 class StreamException implements Exception { 244 class StreamException implements Exception {
232 const StreamException([String this.message = ""]); 245 const StreamException([String this.message = ""]);
233 const StreamException.streamClosed() : message = "Stream closed"; 246 const StreamException.streamClosed() : message = "Stream closed";
234 String toString() => "StreamException: $message"; 247 String toString() => "StreamException: $message";
235 final String message; 248 final String message;
236 } 249 }
OLDNEW
« no previous file with comments | « runtime/bin/http_impl.dart ('k') | runtime/bin/list_stream_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698