Differences From Artifact [8627416ee2]:
- File
src/OFStream.h
— part of check-in
[4d9a641d87]
at
2012-09-19 23:02:02
on branch trunk
— Make async I/O possible without blocks.
Async connecting is still missing. (user: js, size: 34418) [annotate] [blame] [check-ins using]
To Artifact [6c1eafc699]:
- File
src/OFStream.h
— part of check-in
[6343e04dcd]
at
2012-10-17 20:16:10
on branch trunk
— Pass exceptions on async I/O.
This makes it possible to handle exceptions that occurred during async
I/O in the specified handler. (user: js, size: 34683) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 | #include <stdarg.h> #import "OFObject.h" #import "OFString.h" @class OFStream; @class OFDataArray; #ifdef OF_HAVE_BLOCKS | > | > | > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #include <stdarg.h> #import "OFObject.h" #import "OFString.h" @class OFStream; @class OFDataArray; @class OFException; #ifdef OF_HAVE_BLOCKS typedef BOOL (^of_stream_async_read_block_t)(OFStream*, void*, size_t, OFException*); typedef BOOL (^of_stream_async_read_line_block_t)(OFStream*, OFString*, OFException*); #endif /** * \brief A base class for different types of streams. * * \warning Even though the OFCopying protocol is implemented, it does * <i>not</i> return an independent copy of the stream, but instead |
︙ | ︙ | |||
125 126 127 128 129 130 131 | * \param target The target on which the selector should be called when the * data has been received. If the method returns YES, it will be * called again with the same buffer and maximum 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 NO * from the method. * \param selector The selector to call on the target. The signature must be | | > | > | > | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | * \param target The target on which the selector should be called when the * data has been received. If the method returns YES, it will be * called again with the same buffer and maximum 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 NO * from the method. * \param selector The selector to call on the target. The signature must be * BOOL (OFStream *stream, void *buffer, size_t size, * OFException *exception). */ - (void)asyncReadIntoBuffer: (void*)buffer length: (size_t)length target: (id)target selector: (SEL)selector; /** * \brief Asyncronously reads exactly the specified length bytes from the * stream into a buffer. * * Unlike asyncReadIntoBuffer:length:block, this method does not call the * method when less than the specified length has been read - instead, it waits * until it got exactly the specified length, the stream has ended or an * exception occurred. * * \param buffer The buffer into which the data is read * \param length The length of the data that should be read. * The buffer <i>must</i> be <i>exactly</i> this big! * \param target The target on which the selector should be called when the * data has been received. If the method returns YES, 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 NO * from the method. * \param selector The selector to call on the target. The signature must be * BOOL (OFStream *stream, void *buffer, size_t size, * OFException *exception). */ - (void)asyncReadIntoBuffer: (void*)buffer exactLength: (size_t)length target: (id)target selector: (SEL)selector; #ifdef OF_HAVE_BLOCKS |
︙ | ︙ | |||
188 189 190 191 192 193 194 | /** * \brief Asyncronously reads exactly the specified length bytes from the * stream into a buffer. * * Unlike asyncReadIntoBuffer:length:block, this method does not invoke the * block when less than the specified length has been read - instead, it waits | | > | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | /** * \brief Asyncronously reads exactly the specified length bytes from the * stream into a buffer. * * Unlike asyncReadIntoBuffer:length:block, this method does not invoke the * block when less than the specified length has been read - instead, it waits * until it got exactly the specified length, the stream has ended or an * exception occurred. * * \param buffer The buffer into which the data is read * \param length The length of the data that should be read. * The buffer <i>must</i> be <i>exactly</i> this big! * \param block The block to call when the data has been received. * If the block returns YES, it will be called again with the same * buffer and exact length when more data has been received. If |
︙ | ︙ | |||
551 552 553 554 555 556 557 | * \param encoding The encoding used by the stream * \return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ - (OFString*)readLineWithEncoding: (of_string_encoding_t)encoding; /** | | | | > | | | > | > | | | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | * \param encoding The encoding used by the stream * \return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ - (OFString*)readLineWithEncoding: (of_string_encoding_t)encoding; /** * \brief Asyncronously reads until a newline, \\0, end of stream or an * exception occurs. * * \param target The target on which to call the selector when the data has * been received. If the method returns YES, it will be called * again when the next line has been received. If you want the * next method in the queue to handle the next line, you need to * return NO from the method * \param selector The selector to call on the target. The signature must be * BOOL (OFStream *stream, OFString *line, * OFException *exception). */ - (void)asyncReadLineWithTarget: (id)target selector: (SEL)selector; /** * \brief Asyncronously reads with the specified encoding until a newline, \\0, * end of stream or an exception occurs. * * \param encoding The encoding used by the stream * \param target The target on which to call the selector when the data has * been received. If the method returns YES, it will be called * again when the next line has been received. If you want the * next method in the queue to handle the next line, you need to * return NO from the method * \param selector The selector to call on the target. The signature must be * BOOL (OFStream *stream, OFString *line, * OFException *exception). */ - (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding target: (id)target selector: (SEL)selector; #ifdef OF_HAVE_BLOCKS /** * \brief Asyncronously reads until a newline, \\0, end of stream or an * exception occurs. * * \param block The block to call when the data has been received. * If the block returns YES, it will be called again when the next * line has been received. If you want the next block in the queue * to handle the next line, you need to return NO from the block. */ - (void)asyncReadLineWithBlock: (of_stream_async_read_line_block_t)block; /** * \brief Asyncronously reads with the specified encoding until a newline, \\0, * end of stream or an exception occurs. * * \param encoding The encoding used by the stream * \param block The block to call when the data has been received. * If the block returns YES, it will be called again when the next * line has been received. If you want the next block in the queue * to handle the next line, you need to return NO from the block. */ |
︙ | ︙ |