@@ -32,10 +32,11 @@ #endif #import "OFStream.h" #import "OFString.h" #import "OFDataArray.h" +#import "OFRunLoop.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFNotImplementedException.h" #import "OFSetOptionFailedException.h" @@ -130,10 +131,20 @@ cacheLength -= length; return length; } } + +- (void)asyncReadWithBuffer: (void*)buffer + length: (size_t)length + block: (of_stream_async_read_block_t)block +{ + [OFRunLoop _addAsyncReadForStream: self + buffer: buffer + length: length + block: block]; +} - (void)readIntoBuffer: (void*)buffer exactLength: (size_t)length { size_t readLength = 0; @@ -670,10 +681,26 @@ if ([self isAtEndOfStream]) return nil; return line; } + +#ifdef OF_HAVE_BLOCKS +- (void)asyncReadLineWithBlock: (of_stream_async_read_line_block_t)block +{ + return [self asyncReadLineWithEncoding: OF_STRING_ENCODING_UTF_8 + block: block]; +} + +- (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding + block: (of_stream_async_read_line_block_t)block +{ + [OFRunLoop _addAsyncReadLineForStream: self + encoding: encoding + block: block]; +} +#endif - (OFString*)tryReadLine { return [self tryReadLineWithEncoding: OF_STRING_ENCODING_UTF_8]; }