ObjFW  Diff

Differences From Artifact [c88d590591]:

To Artifact [f77e6ede23]:


15
16
17
18
19
20
21
22
23

24
25
26
27
28
29
30
@class OFDataArray;

/**
 * \brief A base class for different types of streams.
 */
@interface OFStream: OFObject
{
	char   *cache;
	size_t cache_len;

}

/**
 * Returns a boolean whether the end of the stream has been reached.
 *
 * IMPORTANT: Do *NOT* override this in subclasses! Override
 * atEndOfStreamWithoutCache instead, as otherwise, you *WILL* break caching and







|
|
>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@class OFDataArray;

/**
 * \brief A base class for different types of streams.
 */
@interface OFStream: OFObject
{
	char   *cache, *wcache;
	size_t cache_len, wcache_len;
	BOOL   use_wcache;
}

/**
 * Returns a boolean whether the end of the stream has been reached.
 *
 * IMPORTANT: Do *NOT* override this in subclasses! Override
 * atEndOfStreamWithoutCache instead, as otherwise, you *WILL* break caching and
166
167
168
169
170
171
172
173










174




175
176
177
178
179
180
181
182













183
184
185
186
187
188
189
 * \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
		  withEncoding: (enum of_string_encoding)encoding;

/**










 * Writes from a buffer into the stream.




 *
 * \param buf The buffer from which the data is written to the stream
 * \param size The size of the data that should be written
 * \return The number of bytes written
 */
- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf;














/**
 * Writes an uint8_t into the stream.
 *
 * \param int8 An uint8_t
 */
- (void)writeInt8: (uint8_t)int8;









>
>
>
>
>
>
>
>
>
>

>
>
>
>








>
>
>
>
>
>
>
>
>
>
>
>
>







167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
 * \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
		  withEncoding: (enum of_string_encoding)encoding;

/**
 * Caches all writes until flushWriteCache is called.
 */
- cacheWrites;

/**
 * Writes everything in the write cache to the stream.
 */
- flushWriteCache;

/**
 * Writes from a buffer into the stream.
 *
 * IMPORTANT: Do *NOT* override this in subclasses! Override
 * writeNBytesWithoutCache:fromBuffer: instead, as otherwise, you *WILL* break
 * caching and thus get broken results!
 *
 * \param buf The buffer from which the data is written to the stream
 * \param size The size of the data that should be written
 * \return The number of bytes written
 */
- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf;

/**
 * Directly writes from a buffer into the stream without caching the data first.
 *
 * IMPORTANT: Do *NOT* use this! Use writeNBytes:fromBuffer: instead, as this is
 * *ONLY* for being overriden in subclasses!
 *
 * \param buf The buffer from which the data is written to the stream
 * \param size The size of the data that should be written
 * \return The number of bytes written
 */
- (size_t)writeNBytesWithoutCache: (size_t)size
		       fromBuffer: (const char*)buf;

/**
 * Writes an uint8_t into the stream.
 *
 * \param int8 An uint8_t
 */
- (void)writeInt8: (uint8_t)int8;