| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 string data. The | 5 // Interface for decoders decoding binary data into string data. The |
| 6 // decoder keeps track of line breaks during decoding. | 6 // decoder keeps track of line breaks during decoding. |
| 7 interface _StringDecoder { | 7 interface _StringDecoder { |
| 8 // Add more binary data to be decoded. The ownership of the buffer | 8 // Add more binary data to be decoded. The ownership of the buffer |
| 9 // is transfered to the decoder and the caller most not modify it any more. | 9 // is transfered to the decoder and the caller most not modify it any more. |
| 10 int write(List<int> buffer); | 10 int write(List<int> buffer); |
| 11 | 11 |
| 12 // Returns whether any decoded data is available. | 12 // Returns whether any decoded data is available. |
| 13 bool isEmpty(); | 13 bool isEmpty(); |
| 14 | 14 |
| 15 // Returns the number of available decoded characters. |
| 16 int available(); |
| 17 |
| 15 // Get the number of line breaks present in the current decoded | 18 // Get the number of line breaks present in the current decoded |
| 16 // data. | 19 // data. |
| 17 int lineBreaks(); | 20 int get lineBreaks; |
| 18 | 21 |
| 19 // Get the string data decoded since the last call to [decode] or | 22 // Get the string data decoded since the last call to [decode] or |
| 20 // [decodeLine]. Returns null if no decoded data is available. | 23 // [decodeLine]. Returns null if no decoded data is available. |
| 21 String get decoded; | 24 String get decoded; |
| 22 | 25 |
| 23 // Get the string data decoded since the last call to [decode] or | 26 // Get the string data decoded since the last call to [decode] or |
| 24 // [decodeLine] up to the next line break present. Returns null if | 27 // [decodeLine] up to the next line break present. Returns null if |
| 25 // no line break is present. The line break character sequence is | 28 // no line break is present. The line break character sequence is |
| 26 // discarded. | 29 // discarded. |
| 27 String get decodedLine; | 30 String get decodedLine; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 _bufferList.add(buffer); | 69 _bufferList.add(buffer); |
| 67 // Decode as many bytes into characters as possible. | 70 // Decode as many bytes into characters as possible. |
| 68 while (_bufferList.length > 0) { | 71 while (_bufferList.length > 0) { |
| 69 if (!_processNext()) { | 72 if (!_processNext()) { |
| 70 break; | 73 break; |
| 71 } | 74 } |
| 72 } | 75 } |
| 73 return buffer.length; | 76 return buffer.length; |
| 74 } | 77 } |
| 75 | 78 |
| 76 bool isEmpty() { | 79 bool isEmpty() => _result.isEmpty(); |
| 77 return _result.isEmpty(); | |
| 78 } | |
| 79 | 80 |
| 80 int get lineBreaks => _lineBreaks; | 81 int get lineBreaks => _lineBreaks; |
| 81 | 82 |
| 82 String get decoded { | 83 String get decoded { |
| 83 if (isEmpty()) return null; | 84 if (isEmpty()) return null; |
| 84 | 85 |
| 85 String result; | 86 String result; |
| 86 if (_resultOffset == 0) { | 87 if (_resultOffset == 0) { |
| 87 result = new String.fromCharCodes(_result); | 88 result = new String.fromCharCodes(_result); |
| 88 } else { | 89 } else { |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 bool _inputClosed = false; // Is the underlying input stream closed? | 515 bool _inputClosed = false; // Is the underlying input stream closed? |
| 515 bool _closed = false; // Is this stream closed. | 516 bool _closed = false; // Is this stream closed. |
| 516 bool _eof = false; // Has all data been read from the decoder? | 517 bool _eof = false; // Has all data been read from the decoder? |
| 517 Timer _scheduledDataCallback; | 518 Timer _scheduledDataCallback; |
| 518 Timer _scheduledLineCallback; | 519 Timer _scheduledLineCallback; |
| 519 Timer _scheduledCloseCallback; | 520 Timer _scheduledCloseCallback; |
| 520 Function _clientDataHandler; | 521 Function _clientDataHandler; |
| 521 Function _clientLineHandler; | 522 Function _clientLineHandler; |
| 522 Function _clientCloseHandler; | 523 Function _clientCloseHandler; |
| 523 } | 524 } |
| OLD | NEW |