@@ -44,12 +44,11 @@ * @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)(size_t length, - id _Nullable exception); +typedef bool (^OFStreamAsyncReadBlock)(size_t length, id _Nullable exception); /** * @brief A block which is called when a line was read asynchronously from a * stream. * @@ -57,11 +56,11 @@ * 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)(OFString *_Nullable line, +typedef bool (^OFStreamAsyncReadLineBlock)(OFString *_Nullable line, id _Nullable exception); /** * @brief A block which is called when data was written asynchronously to a * stream. @@ -72,12 +71,12 @@ * asynchronous write if no exception was encountered. * @param exception An exception which occurred while writing or `nil` on * success * @return The data to repeat the write with or nil if it should not repeat */ -typedef OFData *_Nullable (^of_stream_async_write_data_block_t)( - OFData *_Nonnull data, size_t bytesWritten, id _Nullable exception); +typedef OFData *_Nullable (^OFStreamAsyncWriteDataBlock)(OFData *_Nonnull data, + size_t bytesWritten, id _Nullable exception); /** * @brief A block which is called when a string was written asynchronously to a * stream. * @@ -87,11 +86,11 @@ * asynchronous write if no exception was encountered. * @param exception An exception which occurred while writing or `nil` on * success * @return The string to repeat the write with or nil if it should not repeat */ -typedef OFString *_Nullable (^of_stream_async_write_string_block_t)( +typedef OFString *_Nullable (^OFStreamAsyncWriteStringBlock)( OFString *_Nonnull string, size_t bytesWritten, id _Nullable exception); #endif /** * @protocol OFStreamDelegate OFStream.h ObjFW/OFStream.h @@ -159,11 +158,11 @@ * @param exception An exception that occurred while writing, or nil on success * @return The string to repeat the write with or nil if it should not repeat */ - (nullable OFString *)stream: (OFStream *)stream didWriteString: (OFString *)string - encoding: (of_string_encoding_t)encoding + encoding: (OFStringEncoding)encoding bytesWritten: (size_t)bytesWritten exception: (nullable id)exception; @end /** @@ -246,12 +245,11 @@ * @param buffer The buffer into which the data is read * @param length The length of the data that should be read at most. * The buffer *must* be *at least* this big! * @return The number of bytes read */ -- (size_t)readIntoBuffer: (void *)buffer - length: (size_t)length; +- (size_t)readIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Reads exactly the specified length bytes from the stream into a * buffer. * @@ -264,12 +262,11 @@ * * @param buffer The buffer into which the data is read * @param length The length of the data that should be read. * The buffer *must* be *at least* this big! */ - - (void)readIntoBuffer: (void *)buffer - exactLength: (size_t)length; + - (void)readIntoBuffer: (void *)buffer exactLength: (size_t)length; #ifdef OF_HAVE_SOCKETS /** * @brief Asynchronously reads *at most* size bytes from the stream into a * buffer. @@ -288,12 +285,11 @@ * @param buffer The buffer into which the data is read. * The buffer must not be freed before the async read completed! * @param length The length of the data that should be read at most. * The buffer *must* be *at least* this big! */ -- (void)asyncReadIntoBuffer: (void *)buffer - length: (size_t)length; +- (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Asynchronously reads *at most* size bytes from the stream into a * buffer. * @@ -314,11 +310,11 @@ * The buffer *must* be *at least* this big! * @param runLoopMode The run loop mode in which to perform the async read */ - (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length - runLoopMode: (of_run_loop_mode_t)runLoopMode; + runLoopMode: (OFRunLoopMode)runLoopMode; /** * @brief Asynchronously reads exactly the specified length bytes from the * stream into a buffer. * @@ -332,12 +328,11 @@ * * @param buffer The buffer into which the data is read * @param length The length of the data that should be read. * The buffer *must* be *at least* this big! */ -- (void)asyncReadIntoBuffer: (void *)buffer - exactLength: (size_t)length; +- (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length; /** * @brief Asynchronously reads exactly the specified length bytes from the * stream into a buffer. * @@ -354,11 +349,11 @@ * The buffer *must* be *at least* this big! * @param runLoopMode The run loop mode in which to perform the async read */ - (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length - runLoopMode: (of_run_loop_mode_t)runLoopMode; + runLoopMode: (OFRunLoopMode)runLoopMode; # ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously reads *at most* ref size bytes from the stream into a * buffer. @@ -384,11 +379,11 @@ * you want the next block in the queue to handle the data * received next, you need to return false from the block. */ - (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length - block: (of_stream_async_read_block_t)block; + block: (OFStreamAsyncReadBlock)block; /** * @brief Asynchronously reads *at most* ref size bytes from the stream into a * buffer. * @@ -414,12 +409,12 @@ * you want the next block in the queue to handle the data * received next, you need to return false from the block. */ - (void)asyncReadIntoBuffer: (void *)buffer length: (size_t)length - runLoopMode: (of_run_loop_mode_t)runLoopMode - block: (of_stream_async_read_block_t)block; + runLoopMode: (OFRunLoopMode)runLoopMode + block: (OFStreamAsyncReadBlock)block; /** * @brief Asynchronously reads exactly the specified length bytes from the * stream into a buffer. * @@ -440,11 +435,11 @@ * you want the next block in the queue to handle the data * received next, you need to return false from the block. */ - (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length - block: (of_stream_async_read_block_t)block; + block: (OFStreamAsyncReadBlock)block; /** * @brief Asynchronously reads exactly the specified length bytes from the * stream into a buffer. * @@ -466,12 +461,12 @@ * you want the next block in the queue to handle the data * received next, you need to return false from the block. */ - (void)asyncReadIntoBuffer: (void *)buffer exactLength: (size_t)length - runLoopMode: (of_run_loop_mode_t)runLoopMode - block: (of_stream_async_read_block_t)block; + runLoopMode: (OFRunLoopMode)runLoopMode + block: (OFStreamAsyncReadBlock)block; # endif #endif /** * @brief Reads a uint8_t from the stream. @@ -588,12 +583,11 @@ * @param buffer A buffer of sufficient size to store the specified number of * floats * @param count The number of floats to read * @return The number of bytes read */ -- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer - count: (size_t)count; +- (size_t)readBigEndianFloatsIntoBuffer: (float *)buffer count: (size_t)count; /** * @brief Reads the specified number of doubles from the stream which are * encoded in big endian. * @@ -603,12 +597,11 @@ * @param buffer A buffer of sufficient size to store the specified number of * doubles * @param count The number of doubles to read * @return The number of bytes read */ -- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer - count: (size_t)count; +- (size_t)readBigEndianDoublesIntoBuffer: (double *)buffer count: (size_t)count; /** * @brief Reads a uint16_t from the stream which is encoded in little endian. * * @warning Only call this when you know that enough data is available! @@ -754,12 +747,11 @@ * * @param itemSize The size of each item * @param count The number of items to read * @return OFData with count items. */ -- (OFData *)readDataWithItemSize: (size_t)itemSize - count: (size_t)count; +- (OFData *)readDataWithItemSize: (size_t)itemSize count: (size_t)count; /** * @brief Returns OFData with all the remaining data of the stream. * * @return OFData with an item size of 1 with all the data of the stream until @@ -797,11 +789,11 @@ * @param encoding The encoding of the string to read from the stream * @param length The length (in bytes) of the string to read from the stream * @return A string with the specified length */ - (OFString *)readStringWithLength: (size_t)length - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @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 @@ -815,11 +807,11 @@ * * @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. */ -- (nullable OFString *)readLineWithEncoding: (of_string_encoding_t)encoding; +- (nullable OFString *)readLineWithEncoding: (OFStringEncoding)encoding; #ifdef OF_HAVE_SOCKETS /** * @brief Asynchronously reads until a newline, `\0`, end of stream or an * exception occurs. @@ -836,11 +828,11 @@ * @note The stream must conform to @ref OFReadyForReadingObserving in order * for this to work! * * @param encoding The encoding used by the stream */ -- (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding; +- (void)asyncReadLineWithEncoding: (OFStringEncoding)encoding; /** * @brief Asynchronously reads with the specified encoding until a newline, * `\0`, end of stream or an exception occurs. * @@ -848,12 +840,12 @@ * for this to work! * * @param encoding The encoding used by the stream * @param runLoopMode The run loop mode in which to perform the async read */ -- (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding - runLoopMode: (of_run_loop_mode_t)runLoopMode; +- (void)asyncReadLineWithEncoding: (OFStringEncoding)encoding + runLoopMode: (OFRunLoopMode)runLoopMode; # ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously reads until a newline, `\0`, end of stream or an * exception occurs. @@ -865,11 +857,11 @@ * If the block returns true, 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 false from the * block. */ -- (void)asyncReadLineWithBlock: (of_stream_async_read_line_block_t)block; +- (void)asyncReadLineWithBlock: (OFStreamAsyncReadLineBlock)block; /** * @brief Asynchronously reads with the specified encoding until a newline, * `\0`, end of stream or an exception occurs. * @@ -881,12 +873,12 @@ * If the block returns true, 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 false from the * block. */ -- (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding - block: (of_stream_async_read_line_block_t)block; +- (void)asyncReadLineWithEncoding: (OFStringEncoding)encoding + block: (OFStreamAsyncReadLineBlock)block; /** * @brief Asynchronously reads with the specified encoding until a newline, * `\0`, end of stream or an exception occurs. * @@ -899,13 +891,13 @@ * If the block returns true, 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 false from the * block. */ -- (void)asyncReadLineWithEncoding: (of_string_encoding_t)encoding - runLoopMode: (of_run_loop_mode_t)runLoopMode - block: (of_stream_async_read_line_block_t)block; +- (void)asyncReadLineWithEncoding: (OFStringEncoding)encoding + runLoopMode: (OFRunLoopMode)runLoopMode + block: (OFStreamAsyncReadLineBlock)block; # endif #endif /** * @brief Tries to read a line from the stream (see @ref readLine) and returns @@ -923,11 +915,11 @@ * * @param encoding The encoding used by the stream * @return The line that was read, autoreleased, or `nil` if the line is not * complete yet */ -- (nullable OFString *)tryReadLineWithEncoding: (of_string_encoding_t)encoding; +- (nullable OFString *)tryReadLineWithEncoding: (OFStringEncoding)encoding; /** * @brief Reads until the specified string or `\0` is found or the end of * stream occurs. * @@ -945,11 +937,11 @@ * @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. */ - (nullable OFString *)readTillDelimiter: (OFString *)delimiter - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)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. @@ -969,11 +961,11 @@ * @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. */ - (nullable OFString *)tryReadTillDelimiter: (OFString *)delimiter - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Writes everything in the write buffer to the stream. */ - (void)flushWriteBuffer; @@ -984,12 +976,11 @@ * @param buffer The buffer from which the data is written into the stream * @param length The length of the data that should be written * @return The number of bytes written. This can only differ from the specified * length in non-blocking mode. */ -- (size_t)writeBuffer: (const void *)buffer - length: (size_t)length; +- (size_t)writeBuffer: (const void *)buffer length: (size_t)length; #ifdef OF_HAVE_SOCKETS /** * @brief Asynchronously writes data into the stream. * @@ -1008,11 +999,11 @@ * * @param data The data which is written into the stream * @param runLoopMode The run loop mode in which to perform the async write */ - (void)asyncWriteData: (OFData *)data - runLoopMode: (of_run_loop_mode_t)runLoopMode; + runLoopMode: (OFRunLoopMode)runLoopMode; /** * @brief Asynchronously writes a string in UTF-8 encoding into the stream. * * @note The stream must conform to @ref OFReadyForWritingObserving in order @@ -1032,11 +1023,11 @@ * @param string The string which is written into the stream * @param encoding The encoding in which the string should be written to the * stream */ - (void)asyncWriteString: (OFString *)string - encoding: (of_string_encoding_t)encoding; + encoding: (OFStringEncoding)encoding; /** * @brief Asynchronously writes a string in the specified encoding into the * stream. * @@ -1047,12 +1038,12 @@ * @param encoding The encoding in which the string should be written to the * stream * @param runLoopMode The run loop mode in which to perform the async write */ - (void)asyncWriteString: (OFString *)string - encoding: (of_string_encoding_t)encoding - runLoopMode: (of_run_loop_mode_t)runLoopMode; + encoding: (OFStringEncoding)encoding + runLoopMode: (OFRunLoopMode)runLoopMode; # ifdef OF_HAVE_BLOCKS /** * @brief Asynchronously writes data into the stream. * @@ -1063,11 +1054,11 @@ * @param block The block to call when the data has been written. It should * return the data for the next write with the same callback or * nil if it should not repeat. */ - (void)asyncWriteData: (OFData *)data - block: (of_stream_async_write_data_block_t)block; + block: (OFStreamAsyncWriteDataBlock)block; /** * @brief Asynchronously writes data into the stream. * * @note The stream must conform to @ref OFReadyForWritingObserving in order @@ -1078,12 +1069,12 @@ * @param block The block to call when the data has been written. It should * return the data for the next write with the same callback or * nil if it should not repeat. */ - (void)asyncWriteData: (OFData *)data - runLoopMode: (of_run_loop_mode_t)runLoopMode - block: (of_stream_async_write_data_block_t)block; + runLoopMode: (OFRunLoopMode)runLoopMode + block: (OFStreamAsyncWriteDataBlock)block; /** * @brief Asynchronously writes a string into the stream. * * @note The stream must conform to @ref OFReadyForWritingObserving in order @@ -1093,11 +1084,11 @@ * @param block The block to call when the string has been written. It should * return the string for the next write with the same callback or * nil if it should not repeat. */ - (void)asyncWriteString: (OFString *)string - block: (of_stream_async_write_string_block_t)block; + block: (OFStreamAsyncWriteStringBlock)block; /** * @brief Asynchronously writes a string in the specified encoding into the * stream. * @@ -1110,12 +1101,12 @@ * @param block The block to call when the string has been written. It should * return the string for the next write with the same callback or * nil if it should not repeat. */ - (void)asyncWriteString: (OFString *)string - encoding: (of_string_encoding_t)encoding - block: (of_stream_async_write_string_block_t)block; + encoding: (OFStringEncoding)encoding + block: (OFStreamAsyncWriteStringBlock)block; /** * @brief Asynchronously writes a string in the specified encoding into the * stream. * @@ -1129,13 +1120,13 @@ * @param block The block to call when the string has been written. It should * return the string for the next write with the same callback or * nil if it should not repeat. */ - (void)asyncWriteString: (OFString *)string - encoding: (of_string_encoding_t)encoding - runLoopMode: (of_run_loop_mode_t)runLoopMode - block: (of_stream_async_write_string_block_t)block; + encoding: (OFStringEncoding)encoding + runLoopMode: (OFRunLoopMode)runLoopMode + block: (OFStreamAsyncWriteStringBlock)block; # endif #endif /** * @brief Writes a uint8_t into the stream. @@ -1186,12 +1177,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of uint16_ts to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer - count: (size_t)count; +- (size_t)writeBigEndianInt16s: (const uint16_t *)buffer count: (size_t)count; /** * @brief Writes the specified number of uint32_ts into the stream, encoded in * big endian. * @@ -1198,12 +1188,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of uint32_ts to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer - count: (size_t)count; +- (size_t)writeBigEndianInt32s: (const uint32_t *)buffer count: (size_t)count; /** * @brief Writes the specified number of uint64_ts into the stream, encoded in * big endian. * @@ -1210,12 +1199,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of uint64_ts to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer - count: (size_t)count; +- (size_t)writeBigEndianInt64s: (const uint64_t *)buffer count: (size_t)count; /** * @brief Writes the specified number of floats into the stream, encoded in big * endian. * @@ -1222,12 +1210,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of floats to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianFloats: (const float *)buffer - count: (size_t)count; +- (size_t)writeBigEndianFloats: (const float *)buffer count: (size_t)count; /** * @brief Writes the specified number of doubles into the stream, encoded in * big endian. * @@ -1234,12 +1221,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of doubles to write * @return The number of bytes written to the stream */ -- (size_t)writeBigEndianDoubles: (const double *)buffer - count: (size_t)count; +- (size_t)writeBigEndianDoubles: (const double *)buffer count: (size_t)count; /** * @brief Writes a uint16_t into the stream, encoded in little endian. * * @param int16 A uint16_t @@ -1317,12 +1303,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of floats to write * @return The number of bytes written to the stream */ -- (size_t)writeLittleEndianFloats: (const float *)buffer - count: (size_t)count; +- (size_t)writeLittleEndianFloats: (const float *)buffer count: (size_t)count; /** * @brief Writes the specified number of doubles into the stream, encoded in * little endian. * @@ -1329,12 +1314,11 @@ * @param buffer The buffer from which the data is written to the stream after * it has been byte swapped if necessary * @param count The number of doubles to write * @return The number of bytes written to the stream */ -- (size_t)writeLittleEndianDoubles: (const double *)buffer - count: (size_t)count; +- (size_t)writeLittleEndianDoubles: (const double *)buffer count: (size_t)count; /** * @brief Writes OFData into the stream. * * @param data The OFData to write into the stream @@ -1356,12 +1340,11 @@ * * @param string The string from which the data is written to the stream * @param encoding The encoding in which to write the string to the stream * @return The number of bytes written */ -- (size_t)writeString: (OFString *)string - encoding: (of_string_encoding_t)encoding; +- (size_t)writeString: (OFString *)string encoding: (OFStringEncoding)encoding; /** * @brief Writes a string into the stream with a trailing newline. * * @param string The string from which the data is written to the stream @@ -1375,19 +1358,18 @@ * * @param string The string from which the data is written to the stream * @param encoding The encoding in which to write the string to the stream * @return The number of bytes written */ -- (size_t)writeLine: (OFString *)string - encoding: (of_string_encoding_t)encoding; +- (size_t)writeLine: (OFString *)string encoding: (OFStringEncoding)encoding; /** * @brief Writes a formatted string into the stream. * * See printf for the format syntax. As an addition, `%@` is available as - * format specifier for objects, `%C` for `of_unichar_t` and `%S` for - * `const of_unichar_t *`. + * format specifier for objects, `%C` for `OFUnichar` and `%S` for + * `const OFUnichar *`. * * @param format A string used as format * @return The number of bytes written */ - (size_t)writeFormat: (OFConstantString *)format, ...; @@ -1394,19 +1376,18 @@ /** * @brief Writes a formatted string into the stream. * * See printf for the format syntax. As an addition, `%@` is available as - * format specifier for objects, `%C` for `of_unichar_t` and `%S` for - * `const of_unichar_t *`. + * format specifier for objects, `%C` for `OFUnichar` and `%S` for + * `const OFUnichar *`. * * @param format A string used as format * @param arguments The arguments used in the format string * @return The number of bytes written */ -- (size_t)writeFormat: (OFConstantString *)format - arguments: (va_list)arguments; +- (size_t)writeFormat: (OFConstantString *)format arguments: (va_list)arguments; #ifdef OF_HAVE_SOCKETS /** * @brief Cancels all pending asynchronous requests on the stream. */ @@ -1432,12 +1413,11 @@ * unread. * * @param buffer The buffer to unread * @param length The length of the buffer to unread */ -- (void)unreadFromBuffer: (const void *)buffer - length: (size_t)length; +- (void)unreadFromBuffer: (const void *)buffer length: (size_t)length; /** * @brief Closes the stream. * * @note If you override this, make sure to call `[super close]`! @@ -1454,12 +1434,11 @@ * * @param buffer The buffer for the data to read * @param length The length of the buffer * @return The number of bytes read */ -- (size_t)lowlevelReadIntoBuffer: (void *)buffer - length: (size_t)length; +- (size_t)lowlevelReadIntoBuffer: (void *)buffer length: (size_t)length; /** * @brief Performs a lowlevel write. * * @warning Do not call this directly! @@ -1469,12 +1448,11 @@ * * @param buffer The buffer with the data to write * @param length The length of the data to write * @return The number of bytes written */ -- (size_t)lowlevelWriteBuffer: (const void *)buffer - length: (size_t)length; +- (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length; /** * @brief Returns whether the lowlevel is at the end of the stream. * * @warning Do not call this directly!