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

Side by Side Diff: sdk/lib/convert/utf.dart

Issue 203603008: Introduce class Sink<T>. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 6 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 | « sdk/lib/convert/string_conversion.dart ('k') | sdk/lib/core/core.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) 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.convert; 5 part of dart.convert;
6 6
7 /** The Unicode Replacement character `U+FFFD` (�). */ 7 /** The Unicode Replacement character `U+FFFD` (�). */
8 const int UNICODE_REPLACEMENT_CHARACTER_RUNE = 0xFFFD; 8 const int UNICODE_REPLACEMENT_CHARACTER_RUNE = 0xFFFD;
9 9
10 /** The Unicode Byte Order Marker (BOM) character `U+FEFF`. */ 10 /** The Unicode Byte Order Marker (BOM) character `U+FEFF`. */
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 return encoder._buffer.sublist(0, encoder._bufferIndex); 101 return encoder._buffer.sublist(0, encoder._bufferIndex);
102 } 102 }
103 103
104 /** 104 /**
105 * Starts a chunked conversion. 105 * Starts a chunked conversion.
106 * 106 *
107 * The converter works more efficiently if the given [sink] is a 107 * The converter works more efficiently if the given [sink] is a
108 * [ByteConversionSink]. 108 * [ByteConversionSink].
109 */ 109 */
110 StringConversionSink startChunkedConversion( 110 StringConversionSink startChunkedConversion(Sink<List<int>> sink) {
111 ChunkedConversionSink<List<int>> sink) {
112 if (sink is! ByteConversionSink) { 111 if (sink is! ByteConversionSink) {
113 sink = new ByteConversionSink.from(sink); 112 sink = new ByteConversionSink.from(sink);
114 } 113 }
115 return new _Utf8EncoderSink(sink); 114 return new _Utf8EncoderSink(sink);
116 } 115 }
117 116
118 // Override the base-classes bind, to provide a better type. 117 // Override the base-classes bind, to provide a better type.
119 Stream<List<int>> bind(Stream<String> stream) => super.bind(stream); 118 Stream<List<int>> bind(Stream<String> stream) => super.bind(stream);
120 } 119 }
121 120
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 decoder.close(); 324 decoder.close();
326 return buffer.toString(); 325 return buffer.toString();
327 } 326 }
328 327
329 /** 328 /**
330 * Starts a chunked conversion. 329 * Starts a chunked conversion.
331 * 330 *
332 * The converter works more efficiently if the given [sink] is a 331 * The converter works more efficiently if the given [sink] is a
333 * [StringConversionSink]. 332 * [StringConversionSink].
334 */ 333 */
335 ByteConversionSink startChunkedConversion( 334 ByteConversionSink startChunkedConversion(Sink<String> sink) {
336 ChunkedConversionSink<String> sink) {
337 StringConversionSink stringSink; 335 StringConversionSink stringSink;
338 if (sink is StringConversionSink) { 336 if (sink is StringConversionSink) {
339 stringSink = sink; 337 stringSink = sink;
340 } else { 338 } else {
341 stringSink = new StringConversionSink.from(sink); 339 stringSink = new StringConversionSink.from(sink);
342 } 340 }
343 return stringSink.asUtf8Sink(_allowMalformed); 341 return stringSink.asUtf8Sink(_allowMalformed);
344 } 342 }
345 343
346 // Override the base-classes bind, to provide a better type. 344 // Override the base-classes bind, to provide a better type.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 } 516 }
519 break loop; 517 break loop;
520 } 518 }
521 if (expectedUnits > 0) { 519 if (expectedUnits > 0) {
522 _value = value; 520 _value = value;
523 _expectedUnits = expectedUnits; 521 _expectedUnits = expectedUnits;
524 _extraUnits = extraUnits; 522 _extraUnits = extraUnits;
525 } 523 }
526 } 524 }
527 } 525 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/string_conversion.dart ('k') | sdk/lib/core/core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698