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

Side by Side Diff: sdk/lib/convert/converter.dart

Issue 19000006: First version of Codecs and Converters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert sdk/lib/json change. Created 7 years, 5 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of dart.convert;
6
7 /**
8 * A [Converter] converts data from one representation into another.
9 *
10 * *Converters are still experimental and are subject to change without notice.*
11 *
12 */
13 abstract class Converter<S, T> {
14 /**
15 * Converts [input] and returns the result of the conversion.
16 */
17 T convert(S input);
18
19 /**
20 * Fuses `this` with [other].
21 *
22 * Encoding with the resulting converter is equivalent to converting with
23 * `this` before converting with `other`.
24 */
25 Converter<S, dynamic> fuse(Converter<T, dynamic> other) {
26 return new _FusedConverter<S, T, dynamic>(this, other);
27 }
28 }
29
30
31 class _FusedConverter<S, M, T> extends Converter<S, T> {
Lasse Reichstein Nielsen 2013/07/12 11:50:47 Comment for class. I assume this is just the naïve
floitsch 2013/07/12 16:09:15 Done.
32 final Converter _first;
33 final Converter _second;
34
35 _FusedConverter(Converter<S, M> first, Converter<M, T> second)
Lasse Reichstein Nielsen 2013/07/12 11:50:47 this._first, this._second
floitsch 2013/07/12 16:09:15 Done.
36 : this._first = first,
37 this._second = second;
38
39 T convert(S input) => _second.convert(_first.convert(input));
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698