44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
* @param stream The stream on which data was read
* @param buffer A buffer with the data that has been read
* @param length The length of the data that has been read
* @param exception An exception which occurred while reading or `nil` on
* success
* @return A bool whether the same block should be used for the next read
*/
typedef bool (^of_stream_async_read_block_t)(OFStream *stream, void *buffer,
size_t length, id _Nullable exception);
/*!
* @brief A block which is called when a line was read from the stream.
*
* @param stream The stream on which a line was read
* @param line The line which has been read or `nil` when the end of stream
* occurred
* @param exception An exception which occurred while reading or `nil` on
* success
* @return A bool whether the same block should be used for the next read
*/
typedef bool (^of_stream_async_read_line_block_t)(OFStream *stream,
OFString *_Nullable line, id _Nullable exception);
/*!
* @brief A block which is called when data was written to the stream.
*
* @param stream The stream to which data was written
* @param buffer A pointer to the buffer which was written to the stream. This
* can be changed to point to a different buffer to be used on the
* next write.
* @param bytesWritten The number of bytes which have been written. This
* matches the length specified on the asynchronous write
* if no exception was encountered.
* @param exception An exception which occurred while writing or `nil` on
* success
* @return The length to repeat the write with or 0 if it should not repeat.
* The buffer may be changed, so that every time a new buffer and length
* can be specified while the callback stays the same.
*/
typedef size_t (^of_stream_async_write_block_t)(OFStream *stream,
const void *_Nonnull *_Nonnull buffer, size_t bytesWritten,
id _Nullable exception);
#endif
/*!
* @class OFStream OFStream.h ObjFW/OFStream.h
*
|
|
|
|
|
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
* @param stream The stream on which data was read
* @param buffer A buffer with the data that has been read
* @param length The length of the data that has been read
* @param exception An exception which occurred while reading or `nil` on
* success
* @return A bool whether the same block should be used for the next read
*/
typedef bool (^of_stream_async_read_block_t)(OF_KINDOF(OFStream *) stream,
void *buffer, size_t length, id _Nullable exception);
/*!
* @brief A block which is called when a line was read from the stream.
*
* @param stream The stream on which a line was read
* @param line The line which has been read or `nil` when the end of stream
* occurred
* @param exception An exception which occurred while reading or `nil` on
* success
* @return A bool whether the same block should be used for the next read
*/
typedef bool (^of_stream_async_read_line_block_t)(OF_KINDOF(OFStream *) stream,
OFString *_Nullable line, id _Nullable exception);
/*!
* @brief A block which is called when data was written to the stream.
*
* @param stream The stream to which data was written
* @param buffer A pointer to the buffer which was written to the stream. This
* can be changed to point to a different buffer to be used on the
* next write.
* @param bytesWritten The number of bytes which have been written. This
* matches the length specified on the asynchronous write
* if no exception was encountered.
* @param exception An exception which occurred while writing or `nil` on
* success
* @return The length to repeat the write with or 0 if it should not repeat.
* The buffer may be changed, so that every time a new buffer and length
* can be specified while the callback stays the same.
*/
typedef size_t (^of_stream_async_write_block_t)(OF_KINDOF(OFStream *) stream,
const void *_Nonnull *_Nonnull buffer, size_t bytesWritten,
id _Nullable exception);
#endif
/*!
* @class OFStream OFStream.h ObjFW/OFStream.h
*
|
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
* @param target The target on which the selector should be called when the
* data has been received. If the method returns true, it will be
* called again with the same buffer and exact length when more
* data has been received. If you want the next method in the
* queue to handle the data received next, you need to return
* false from the method.
* @param selector The selector to call on the target. The signature must be
* `bool (OFStream *stream, void *buffer, size_t size,
* id context, id exception)`.
* @param context A context object to pass along to the target
*/
- (void)asyncReadIntoBuffer: (void *)buffer
exactLength: (size_t)length
target: (id)target
selector: (SEL)selector
|
|
|
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
* @param target The target on which the selector should be called when the
* data has been received. If the method returns true, it will be
* called again with the same buffer and exact length when more
* data has been received. If you want the next method in the
* queue to handle the data received next, you need to return
* false from the method.
* @param selector The selector to call on the target. The signature must be
* `bool (OFStream *stream, void *buffer, size_t length,
* id context, id exception)`.
* @param context A context object to pass along to the target
*/
- (void)asyncReadIntoBuffer: (void *)buffer
exactLength: (size_t)length
target: (id)target
selector: (SEL)selector
|