| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide | 8 * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide |
| 9 * utility functions for writing to the StreamConsumer directly. The | 9 * utility functions for writing to the StreamConsumer directly. The |
| 10 * [IOSink] buffers the input given by [write], [writeAll], [writeln], | 10 * [IOSink] buffers the input given by [write], [writeAll], [writeln], |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } else { | 87 } else { |
| 88 string = obj.toString(); | 88 string = obj.toString(); |
| 89 if (string is! String) { | 89 if (string is! String) { |
| 90 throw new ArgumentError('toString() did not return a string'); | 90 throw new ArgumentError('toString() did not return a string'); |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 if (string.isEmpty) return; | 93 if (string.isEmpty) return; |
| 94 writeBytes(_encodeString(string, _encoding)); | 94 writeBytes(_encodeString(string, _encoding)); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void writeAll(Iterable objects) { | 97 void writeAll(Iterable objects, [String separator = ""]) { |
| 98 for (Object obj in objects) write(obj); | 98 Iterator iterator = objects.iterator; |
| 99 if (!iterator.moveNext()) return; |
| 100 if (separator == "") { |
| 101 do { |
| 102 write(iterator.current); |
| 103 } while (iterator.moveNext()); |
| 104 } else { |
| 105 write(iterator.current); |
| 106 while (iterator.moveNext()) { |
| 107 write(separator); |
| 108 write(iterator.current); |
| 109 } |
| 110 } |
| 99 } | 111 } |
| 100 | 112 |
| 101 void writeln([Object obj = ""]) { | 113 void writeln([Object obj = ""]) { |
| 102 write(obj); | 114 write(obj); |
| 103 write("\n"); | 115 write("\n"); |
| 104 } | 116 } |
| 105 | 117 |
| 106 void writeCharCode(int charCode) { | 118 void writeCharCode(int charCode) { |
| 107 write(new String.fromCharCode(charCode)); | 119 write(new String.fromCharCode(charCode)); |
| 108 } | 120 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 }, | 237 }, |
| 226 onError: _controller.addError); | 238 onError: _controller.addError); |
| 227 if (_paused) _pause(); | 239 if (_paused) _pause(); |
| 228 if (unbind) { | 240 if (unbind) { |
| 229 return _writeStreamCompleter.future; | 241 return _writeStreamCompleter.future; |
| 230 } else { | 242 } else { |
| 231 return _pipeFuture; | 243 return _pipeFuture; |
| 232 } | 244 } |
| 233 } | 245 } |
| 234 } | 246 } |
| OLD | NEW |