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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/protobuf/plugin/README ('k') | lib/protobuf/plugin/descriptor.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/protobuf/plugin/Writer.dart
diff --git a/lib/protobuf/plugin/Writer.dart b/lib/protobuf/plugin/Writer.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7970183ea22ad431e115eec3b05023c8a67fc6e6
--- /dev/null
+++ b/lib/protobuf/plugin/Writer.dart
@@ -0,0 +1,47 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+interface Writer {
+ void print(String out);
+ void println([String out]);
+}
+
+class AbstractWriter {
+ static String NEWLINE = "\n";
+ static List<int> NEWLINE_CHARS;
+ AbstractWriter() {
+ if(null === NEWLINE_CHARS) NEWLINE_CHARS = NEWLINE.charCodes();
+ }
+}
+
+class MemoryWriter extends AbstractWriter implements Writer {
+ MemoryWriter(): super(), _buffer = new StringBuffer();
+
+ void print(String out) {
+ _buffer.add(out);
+ }
+
+ void println([String out = null]) {
+ _buffer.add(out);
+ _buffer.add(AbstractWriter.NEWLINE);
+ }
+
+ String toString() {
+ return _buffer.toString();
+ }
+
+ StringBuffer _buffer;
+}
+
+class OutputStreamWriter extends AbstractWriter implements Writer {
+ OutputStreamWriter(OutputStream this._outStream) : super();
+ void print(String str) {
+ _outStream.write(str.charCodes());
+ }
+ void println([String out = null]) {
+ if(null !== out) print(out);
+ _outStream.write(AbstractWriter.NEWLINE_CHARS);
+ }
+ OutputStream _outStream;
+}
« 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