@@ -27,10 +27,12 @@ #import "OFString.h" #ifdef OF_HAVE_SOCKETS # import "OFKernelEventObserver.h" #endif +OF_ASSUME_NONNULL_BEGIN + /*! @file */ @class OFStream; @class OFDataArray; @class OFException; @@ -44,22 +46,23 @@ * @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, OFException *exception); + size_t length, __nullable OFException *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 + * @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 *line, OFException *exception); + __nullable OFString *line, __nullable OFException *exception); #endif /*! * @class OFStream OFStream.h ObjFW/OFStream.h * @@ -200,14 +203,14 @@ * 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, * OFException *exception)`. */ - - (void)asyncReadIntoBuffer: (void*)buffer - exactLength: (size_t)length - target: (id)target - selector: (SEL)selector; +- (void)asyncReadIntoBuffer: (void*)buffer + exactLength: (size_t)length + target: (id)target + selector: (SEL)selector; # ifdef OF_HAVE_BLOCKS /*! * @brief Asyncronously reads *at most* ref size bytes from the stream into a * buffer. @@ -594,21 +597,21 @@ * @brief Reads until a newline, \\0 or end of stream occurs. * * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)readLine; +- (nullable OFString*)readLine; /*! * @brief Reads with the specified encoding until a newline, \\0 or end of * stream occurs. * * @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; +- (nullable OFString*)readLineWithEncoding: (of_string_encoding_t)encoding; #ifdef OF_HAVE_SOCKETS /*! * @brief Asyncronously reads until a newline, \\0, end of stream or an * exception occurs. @@ -689,11 +692,11 @@ * no complete line has been received yet. * * @return The line that was read, autoreleased, or nil if the line is not * complete yet */ -- (OFString*)tryReadLine; +- (nullable OFString*)tryReadLine; /*! * @brief Tries to read a line from the stream with the specified encoding (see * @ref readLineWithEncoding:) and returns nil if no complete line has * been received yet. @@ -700,21 +703,21 @@ * * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or nil if the line is not * complete yet */ -- (OFString*)tryReadLineWithEncoding: (of_string_encoding_t)encoding; +- (nullable OFString*)tryReadLineWithEncoding: (of_string_encoding_t)encoding; /*! * @brief Reads until the specified string or \\0 is found or the end of stream * occurs. * * @param delimiter The delimiter * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)readTillDelimiter: (OFString*)delimiter; +- (nullable OFString*)readTillDelimiter: (OFString*)delimiter; /*! * @brief Reads until the specified string or \\0 is found or the end of stream * occurs. * @@ -721,12 +724,12 @@ * @param delimiter The delimiter * @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*)readTillDelimiter: (OFString*)delimiter - encoding: (of_string_encoding_t)encoding; +- (nullable OFString*)readTillDelimiter: (OFString*)delimiter + encoding: (of_string_encoding_t)encoding; /*! * @brief Tries to reads until the specified string or \\0 is found or the end * of stream (see @ref readTillDelimiter:) and returns nil if not enough * data has been received yet. @@ -733,11 +736,11 @@ * * @param delimiter The delimiter * @return The line that was read, autoreleased, or nil if the end of the * stream has been reached. */ -- (OFString*)tryReadTillDelimiter: (OFString*)delimiter; +- (nullable OFString*)tryReadTillDelimiter: (OFString*)delimiter; /*! * @brief Tries to read until the specified string or \\0 is found or the end * of stream occurs (see @ref readTillDelimiter:encoding:) and * returns nil if not enough data has been received yet. @@ -745,12 +748,12 @@ * @param delimiter The delimiter * @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*)tryReadTillDelimiter: (OFString*)delimiter - encoding: (of_string_encoding_t)encoding; +- (nullable OFString*)tryReadTillDelimiter: (OFString*)delimiter + encoding: (of_string_encoding_t)encoding; /*! * @brief Returns a boolen whether writes are buffered. * * @return A boolean whether writes are buffered @@ -1162,5 +1165,7 @@ * * @return Whether the lowlevel is at the end of the stream */ - (bool)lowlevelIsAtEndOfStream; @end + +OF_ASSUME_NONNULL_END