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 abstract class _StringDecoder { | 7 abstract class _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); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 result = new String.fromCharCodes(_result); | 93 result = new String.fromCharCodes(_result); |
94 } else { | 94 } else { |
95 result = | 95 result = |
96 new String.fromCharCodes( | 96 new String.fromCharCodes( |
97 _result.getRange(_resultOffset, | 97 _result.getRange(_resultOffset, |
98 _result.length - _resultOffset)); | 98 _result.length - _resultOffset)); |
99 } | 99 } |
100 } | 100 } |
101 _resultOffset += result.length; | 101 _resultOffset += result.length; |
102 while (!_lineBreakEnds.isEmpty && | 102 while (!_lineBreakEnds.isEmpty && |
103 _lineBreakEnds.first() < _charOffset + _resultOffset) { | 103 _lineBreakEnds.first < _charOffset + _resultOffset) { |
104 _lineBreakEnds.removeFirst(); | 104 _lineBreakEnds.removeFirst(); |
105 _lineBreaks--; | 105 _lineBreaks--; |
106 } | 106 } |
107 if (_result.length == _resultOffset) _resetResult(); | 107 if (_result.length == _resultOffset) _resetResult(); |
108 return result; | 108 return result; |
109 } | 109 } |
110 | 110 |
111 String get decodedLine { | 111 String get decodedLine { |
112 if (_lineBreakEnds.isEmpty) return null; | 112 if (_lineBreakEnds.isEmpty) return null; |
113 int lineEnd = _lineBreakEnds.removeFirst(); | 113 int lineEnd = _lineBreakEnds.removeFirst(); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 bool _inputClosed = false; // Is the underlying input stream closed? | 523 bool _inputClosed = false; // Is the underlying input stream closed? |
524 bool _closed = false; // Is this stream closed. | 524 bool _closed = false; // Is this stream closed. |
525 bool _eof = false; // Has all data been read from the decoder? | 525 bool _eof = false; // Has all data been read from the decoder? |
526 Timer _scheduledDataCallback; | 526 Timer _scheduledDataCallback; |
527 Timer _scheduledLineCallback; | 527 Timer _scheduledLineCallback; |
528 Timer _scheduledCloseCallback; | 528 Timer _scheduledCloseCallback; |
529 Function _clientDataHandler; | 529 Function _clientDataHandler; |
530 Function _clientLineHandler; | 530 Function _clientLineHandler; |
531 Function _clientCloseHandler; | 531 Function _clientCloseHandler; |
532 } | 532 } |
OLD | NEW |