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

Side by Side Diff: sdk/lib/convert/line_splitter.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/latin1.dart ('k') | sdk/lib/convert/string_conversion.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 /** 7 /**
8 * This class splits [String] values into individual lines. 8 * This class splits [String] values into individual lines.
9 */ 9 */
10 class LineSplitter extends Converter<String, List<String>> { 10 class LineSplitter extends Converter<String, List<String>> {
11 11
12 const LineSplitter(); 12 const LineSplitter();
13 13
14 List<String> convert(String data) { 14 List<String> convert(String data) {
15 var lines = new List<String>(); 15 var lines = new List<String>();
16 16
17 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add); 17 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add);
18 18
19 return lines; 19 return lines;
20 } 20 }
21 21
22 StringConversionSink startChunkedConversion( 22 StringConversionSink startChunkedConversion(Sink<String> sink) {
23 ChunkedConversionSink<String> sink) {
24
25 if (sink is! StringConversionSink) { 23 if (sink is! StringConversionSink) {
26 sink = new StringConversionSink.from(sink); 24 sink = new StringConversionSink.from(sink);
27 } 25 }
28 return new _LineSplitterSink(sink); 26 return new _LineSplitterSink(sink);
29 } 27 }
30 } 28 }
31 29
32 // TODO(floitsch): deal with utf8. 30 // TODO(floitsch): deal with utf8.
33 class _LineSplitterSink extends StringConversionSinkBase { 31 class _LineSplitterSink extends StringConversionSinkBase {
34 static const int _LF = 10; 32 static const int _LF = 10;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 if (isLast) { 84 if (isLast) {
87 // Add remaining 85 // Add remaining
88 adder(carry); 86 adder(carry);
89 } else { 87 } else {
90 return carry; 88 return carry;
91 } 89 }
92 } 90 }
93 return null; 91 return null;
94 } 92 }
95 } 93 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/latin1.dart ('k') | sdk/lib/convert/string_conversion.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698