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 /** | 5 /** |
6 * Output is written to a given output stream. Such an output stream can | 6 * Output is written to a given output stream. Such an output stream can |
7 * be an endpoint, e.g., a socket or a file, or another output stream. | 7 * be an endpoint, e.g., a socket or a file, or another output stream. |
8 * Multiple output streams can be chained together to operate collaboratively | 8 * Multiple output streams can be chained together to operate collaboratively |
9 * on a given output. | 9 * on a given output. |
10 * | 10 * |
11 * An output stream provides internal buffering of the data written | 11 * An output stream provides internal buffering of the data written |
12 * through all calls to [write] and [writeFrom] if data cannot be | 12 * through all calls to [write] and [writeFrom] if data cannot be |
13 * written immediately to the communication channel. The callback set | 13 * written immediately to the communication channel. The callback set |
14 * through [noPendingWriteHandler] can be used to to keep the rate of | 14 * through [noPendingWriteHandler] can be used to to keep the rate of |
15 * writing in sync with the rate the system can actually write data to | 15 * writing in sync with the rate the system can actually write data to |
16 * the underlying communication channel. | 16 * the underlying communication channel. |
17 */ | 17 */ |
18 interface OutputStream { | 18 interface OutputStream { |
19 /** | 19 /** |
20 * Writes the content of [buffer] to the stream. This will pass | 20 * Writes the content of [buffer] to the stream. If [copyBuffer] is |
21 * ownership of the specified buffer to the system and the caller | 21 * true ownership of the specified buffer is passed to the system |
Mads Ager (google)
2011/11/07 09:18:34
Really? I would have guessed that copyBuffer means
Søren Gjesse
2011/11/08 09:31:53
Of cause that was wrong. copyBuffer == true means
| |
22 * should not change it. Returns true if the data could be written | 22 * and the caller should not change it afterwards. The default value |
23 * to the underlying communication channel immediately. Otherwise | 23 * for [copyBuffer] is true. |
24 * the data is buffered by the output stream and will be sent as | 24 * |
25 * soon as possible. | 25 * Returns true if the data could be written to the underlying |
26 * communication channel immediately. Otherwise the data is buffered | |
27 * by the output stream and will be sent as soon as possible. | |
26 */ | 28 */ |
27 bool write(List<int> buffer); | 29 bool write(List<int> buffer, [bool copyBuffer]); |
28 | 30 |
29 /** | 31 /** |
30 * Writes [len] bytes from buffer [buffer] starting at offset | 32 * Writes [len] bytes from buffer [buffer] starting at offset |
31 * [offset] to the output stream. If [offset] is not specified the | 33 * [offset] to the output stream. If [offset] is not specified the |
32 * default is 0. If [len] is not specified the default is the length | 34 * default is 0. If [len] is not specified the default is the length |
33 * of the buffer passed. The system will copy the data to be written | 35 * of the buffer minus [offset] (i.e. writing from offset to the end |
34 * so the caller can safely change [buffer] afterwards. Returns true | 36 * of the buffer). The system will copy the data to be written so |
35 * if the data could be written to the underlying communication | 37 * the caller can safely change [buffer] afterwards. |
36 * channel immediately. Otherwise the data is buffered by the output | 38 * |
37 * stream and will be sent as soon as possible. | 39 * Returns true if the data could be written to the underlying |
40 * communication channel immediately. Otherwise the data is buffered | |
41 * by the output stream and will be sent as soon as possible. | |
38 */ | 42 */ |
39 bool writeFrom(List<int> buffer, [int offset, int len]); | 43 bool writeFrom(List<int> buffer, [int offset, int len]); |
40 | 44 |
41 /** | 45 /** |
42 * Indicate that all data has been written to the output | 46 * Indicate that all data has been written to the output |
43 * stream. When all data has been written to the communication | 47 * stream. When all data has been written to the communication |
44 * channel it will be closed. | 48 * channel it will be closed. |
45 */ | 49 */ |
46 void close(); | 50 void close(); |
47 | 51 |
(...skipping 17 matching lines...) Expand all Loading... | |
65 */ | 69 */ |
66 void set closeHandler(void callback()); | 70 void set closeHandler(void callback()); |
67 | 71 |
68 /** | 72 /** |
69 * The error handler gets called when the underlying communication | 73 * The error handler gets called when the underlying communication |
70 * channel gets into some kind of error situation. | 74 * channel gets into some kind of error situation. |
71 */ | 75 */ |
72 void set errorHandler(void callback()); | 76 void set errorHandler(void callback()); |
73 } | 77 } |
74 | 78 |
OLD | NEW |