Differences From Artifact [ea19b2f833]:
- File src/OFStream.h — part of check-in [2b6a12065e] at 2018-12-08 16:53:30 on branch trunk — Separate error methods for async method delegates (user: js, size: 48228) [annotate] [blame] [check-ins using]
To Artifact [ba57cd6e80]:
- File
src/OFStream.h
— part of check-in
[064dbe5127]
at
2018-12-11 22:57:46
on branch trunk
— Include an exception in delegate methods
Otherwise, there would be two methods for every operation: One for
success and one for failure. It also makes it easy to forget about
handling failure, so it's better to always pass an optional exception. (user: js, size: 47916) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
99 100 101 102 103 104 105 106 107 108 109 | /*! * @brief This method is called when data was read asynchronously from a * stream. * * @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 * @return A bool whether the read should be repeated */ - (bool)stream: (OF_KINDOF(OFStream *))stream didReadIntoBuffer: (void *)buffer | > | > > | > > | | < < < < < < < < < < < < < < < < < < < | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 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 | /*! * @brief This method is called when data was read asynchronously from a * stream. * * @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 that occurred while reading, or nil on success * @return A bool whether the read should be repeated */ - (bool)stream: (OF_KINDOF(OFStream *))stream didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (nullable id)exception; /*! * @brief This method is called when a line was read asynchronously from a * 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 that occurred while reading, or nil on success * @return A bool whether the read should be repeated */ - (bool)stream: (OF_KINDOF(OFStream *))stream didReadLine: (nullable OFString *)line exception: (nullable id)exception; /*! * @brief This method is called when data was written asynchronously to a * 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 length The length of the buffer that has been written * @param exception An exception that 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 */ - (size_t)stream: (OF_KINDOF(OFStream *))stream didWriteBuffer: (const void *_Nonnull *_Nonnull)buffer length: (size_t)length exception: (nullable id)exception; @end /*! * @class OFStream OFStream.h ObjFW/OFStream.h * * @brief A base class for different types of streams. * |
︙ | ︙ |