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

Side by Side Diff: lib/protobuf/plugin/Writer.dart

Issue 10595002: Protocol Buffer runtime library and 'protoc' plugin (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Work around http://code.google.com/p/dart/issues/detail?id=3806 Created 8 years, 6 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 | « lib/protobuf/plugin/README ('k') | lib/protobuf/plugin/descriptor.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 interface Writer {
6 void print(String out);
7 void println([String out]);
8 }
9
10 class AbstractWriter {
11 static String NEWLINE = "\n";
12 static List<int> NEWLINE_CHARS;
13 AbstractWriter() {
14 if(null === NEWLINE_CHARS) NEWLINE_CHARS = NEWLINE.charCodes();
15 }
16 }
17
18 class MemoryWriter extends AbstractWriter implements Writer {
19 MemoryWriter(): super(), _buffer = new StringBuffer();
20
21 void print(String out) {
22 _buffer.add(out);
23 }
24
25 void println([String out = null]) {
26 _buffer.add(out);
27 _buffer.add(AbstractWriter.NEWLINE);
28 }
29
30 String toString() {
31 return _buffer.toString();
32 }
33
34 StringBuffer _buffer;
35 }
36
37 class OutputStreamWriter extends AbstractWriter implements Writer {
38 OutputStreamWriter(OutputStream this._outStream) : super();
39 void print(String str) {
40 _outStream.write(str.charCodes());
41 }
42 void println([String out = null]) {
43 if(null !== out) print(out);
44 _outStream.write(AbstractWriter.NEWLINE_CHARS);
45 }
46 OutputStream _outStream;
47 }
OLDNEW
« no previous file with comments | « lib/protobuf/plugin/README ('k') | lib/protobuf/plugin/descriptor.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698