| OLD | NEW |
| 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 // Interface for decoders decoding binary data into objects of type T. | 5 // Interface for decoders decoding binary data into objects of type T. |
| 6 interface _Decoder<T> { | 6 interface _Decoder<T> { |
| 7 // Add more binary data to be decoded. The ownership of the buffer | 7 // Add more binary data to be decoded. The ownership of the buffer |
| 8 // is transfered to the decoder and the caller most not modify it any more. | 8 // is transfered to the decoder and the caller most not modify it any more. |
| 9 int write(List<int> buffer); | 9 int write(List<int> buffer); |
| 10 | 10 |
| 11 // Returns whether any decoded data is available. | 11 // Returns whether any decoded data is available. |
| 12 bool isEmpty(); | 12 bool isEmpty(); |
| 13 | 13 |
| 14 // Get the data decoded since the last call to decode. | 14 // Get the data decoded since the last call to decode. |
| 15 T get decoded(); | 15 T get decoded(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 | 18 |
| 19 class DecoderException implements Exception { | 19 class DecoderException implements Exception { |
| 20 const DecoderException([String msg]) : message = msg; | 20 const DecoderException([String this.message]); |
| 21 String toString() => "DecoderException: $message"; | 21 String toString() => "DecoderException: $message"; |
| 22 final String message; | 22 final String message; |
| 23 } | 23 } |
| 24 | 24 |
| 25 | 25 |
| 26 // Utility class for decoding UTF-8 from data delivered as a stream of | 26 // Utility class for decoding UTF-8 from data delivered as a stream of |
| 27 // bytes. | 27 // bytes. |
| 28 class _StringDecoderBase implements _Decoder<String> { | 28 class _StringDecoderBase implements _Decoder<String> { |
| 29 _StringDecoderBase() | 29 _StringDecoderBase() |
| 30 : _bufferList = new _BufferList(), | 30 : _bufferList = new _BufferList(), |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 String _encoding; | 314 String _encoding; |
| 315 _Decoder _decoder; | 315 _Decoder _decoder; |
| 316 String _buffer; // String can be buffered here if readLine is used. | 316 String _buffer; // String can be buffered here if readLine is used. |
| 317 int _bufferLineStart; // Current offset into _buffer if any. | 317 int _bufferLineStart; // Current offset into _buffer if any. |
| 318 bool _inputClosed = false; // Is the underlying input stream closed? | 318 bool _inputClosed = false; // Is the underlying input stream closed? |
| 319 bool _closed = false; // Is this stream closed. | 319 bool _closed = false; // Is this stream closed. |
| 320 bool _eof = false; // Has all data been read from the decoder? | 320 bool _eof = false; // Has all data been read from the decoder? |
| 321 var _clientDataHandler; | 321 var _clientDataHandler; |
| 322 var _clientCloseHandler; | 322 var _clientCloseHandler; |
| 323 } | 323 } |
| OLD | NEW |