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

Side by Side Diff: sdk/lib/core/string_buffer.dart

Issue 12217115: Revert "Add StringSink and update StringBuffer." (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/core/corelib_sources.gypi ('k') | sdk/lib/core/string_sink.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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.core; 5 part of dart.core;
6 6
7 /** 7 /**
8 * The StringBuffer class is useful for concatenating strings 8 * The StringBuffer class is useful for concatenating strings
9 * efficiently. Only on a call to [toString] are the strings 9 * efficiently. Only on a call to [toString] are the strings
10 * concatenated to a single String. 10 * concatenated to a single String.
11 */ 11 */
12 class StringBuffer implements StringSink { 12 abstract class StringBuffer {
13 13
14 /// Creates the string buffer with an initial content. 14 /// Creates the string buffer with an initial content.
15 external StringBuffer([Object content = ""]); 15 external factory StringBuffer([Object content = ""]);
16 16
17 /// Returns the length of the buffer. 17 /// Returns the length of the buffer.
18 external int get length; 18 int get length;
19 19
20 /// Returns whether the buffer is empty. 20 // Returns whether the buffer is empty.
21 bool get isEmpty => length == 0; 21 bool get isEmpty;
22 22
23 /** 23 /// Converts [obj] to a string and adds it to the buffer.
24 * Converts [obj] to a string and adds it to the buffer. 24 void add(Object obj);
25 *
26 * *Deprecated*. Use [write] instead.
27 */
28 @deprecated
29 void add(Object obj) => write(obj);
30
31 void write(Object obj) {
32 // TODO(srdjan): The following four lines could be replaced by
33 // '$obj', but apparently this is too slow on the Dart VM.
34 String str = obj.toString();
35 if (str is! String) {
36 throw new ArgumentError('toString() did not return a string');
37 }
38 if (str.isEmpty) return;
39 _write(str);
40 }
41
42
43 void print(Object obj) {
44 write(obj);
45 _write("\n");
46 }
47
48 /**
49 * Adds the string representation of [charCode] to the buffer.
50 *
51 * *Deprecated* Use [writeCharCode] instead.
52 */
53 @deprecated
54 void addCharCode(int charCode) {
55 writeCharCode(charCode);
56 }
57 25
58 /// Adds the string representation of [charCode] to the buffer. 26 /// Adds the string representation of [charCode] to the buffer.
59 void writeCharCode(int charCode) { 27 void addCharCode(int charCode);
60 _write(new String.fromCharCode(charCode));
61 }
62 28
63 /** 29 /// Adds all items in [objects] to the buffer.
64 * Adds all items in [objects] to the buffer. 30 void addAll(Iterable objects);
65 *
66 * *Deprecated*. Use [:objects.forEach(buffer.write):] instead.
67 */
68 @deprecated
69 void addAll(Iterable objects) {
70 for (Object obj in objects) write(obj);
71 }
72 31
73 /** 32 /// Clears the string buffer.
74 * Clears the string buffer. 33 void clear();
75 *
76 * *Deprecated*.
77 */
78 @deprecated
79 external void clear();
80 34
81 /// Returns the contents of buffer as a concatenated string. 35 /// Returns the contents of buffer as a concatenated string.
82 external String toString(); 36 String toString();
83
84 external void _write(String str);
85 } 37 }
OLDNEW
« no previous file with comments | « sdk/lib/core/corelib_sources.gypi ('k') | sdk/lib/core/string_sink.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698