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

Side by Side Diff: client/samples/swarm/Decoder.dart

Issue 9314024: Final CL to kill off client/samples . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « client/samples/swarm/DataSource.dart ('k') | client/samples/swarm/HelpDialog.dart » ('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 // TODO(jimhug): Fill out methods, add encoder, move to shared lib.
6 class Decoder {
7 int index;
8 String data;
9
10 Decoder(this.data) {
11 this.index = 0;
12 }
13
14 // Reads numbers in variable-length 7-bit encoding. This matches the
15 // varint encoding used by protobufs except that it only uses 7
16 // bits per byte so it can be efficiently passed as UTF8.
17 // For more info, see appengine/encoder.py.
18 int readInt() {
19 var r = 0;
20 for (var i=0; ; i++) {
21 var v = data.charCodeAt(index++);
22 r |= (v & 0x3F) << (6 * i);
23 if ((v & 0x40) == 0) break;
24 }
25 return r.toInt();
26 }
27
28 bool readBool() {
29 final ch = data[index++];
30 assert (ch == 'T' || ch == 'F');
31 return ch == 'T';
32 }
33
34 String readString() {
35 int len = readInt();
36 String s = data.substring(index, index+len);
37 index += len;
38 return s;
39 }
40 }
41
OLDNEW
« no previous file with comments | « client/samples/swarm/DataSource.dart ('k') | client/samples/swarm/HelpDialog.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698