ObjFW  Diff

Differences From Artifact [1a309ecdea]:

To Artifact [67eb3e5d0e]:


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 * \warning Even though the OFCopying protocol is implemented, it does
 *	    <i>not</i> return an independent copy of the stream, but instead
 *	    retains it. This is so that the stream can be used as a key for a
 *	    dictionary, so context can be associated with a stream. Using a
 *	    stream in more than one thread at the same time is not thread-safe,
 *	    even if copy was called to create one "instance" for every thread!
 *
 * \warning If you want to subclass this, override _readIntoBuffer:length:,
 *	    _writeBuffer:length: and _isAtEndOfStream, but nothing else, as
 *	    those are are the methods that do the actual work. OFStream uses
 *	    those for all other methods and does all the caching and other
 *	    stuff for you. If you override these methods without the _ prefix,
 *	    you <i>will</i> break caching and get broken results!
 */
@interface OFStream: OFObject <OFCopying>
{
	char   *cache;
	char   *writeBuffer;
	size_t cacheLength, writeBufferLength;
	BOOL   writeBufferEnabled;







|
|
|
|
|
|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 * \warning Even though the OFCopying protocol is implemented, it does
 *	    <i>not</i> return an independent copy of the stream, but instead
 *	    retains it. This is so that the stream can be used as a key for a
 *	    dictionary, so context can be associated with a stream. Using a
 *	    stream in more than one thread at the same time is not thread-safe,
 *	    even if copy was called to create one "instance" for every thread!
 *
 * \note If you want to subclass this, override lowlevelReadIntoBuffer:length:,
 *	 lowlevelWriteBuffer:length: and lowlevelIsAtEndOfStream, but nothing
 *	 else, as those are are the methods that do the actual work. OFStream
 *	 uses those for all other methods and does all the caching and other
 *	 stuff for you. If you override these methods without the lowlevel
 *	 prefix, you <i>will</i> break caching and get broken results!
 */
@interface OFStream: OFObject <OFCopying>
{
	char   *cache;
	char   *writeBuffer;
	size_t cacheLength, writeBufferLength;
	BOOL   writeBufferEnabled;
879
880
881
882
883
884
885











886
887












888
889











890
891
892
893
- (int)fileDescriptorForWriting;

/**
 * \brief Closes the stream.
 */
- (void)close;












- (size_t)_readIntoBuffer: (void*)buffer
		   length: (size_t)length;












- (void)_writeBuffer: (const void*)buffer
	      length: (size_t)length;











- (BOOL)_isAtEndOfStream;

- (BOOL)OF_isWaitingForDelimiter;
@end







>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
|



879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
- (int)fileDescriptorForWriting;

/**
 * \brief Closes the stream.
 */
- (void)close;

/**
 * \brief Performs a lowlevel read.
 *
 * \warning Do not call this directly!
 *
 * Override this method with your actual read implementation when subclassing!
 *
 * \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;


/**
 * \brief Performs a lowlevel write.
 *
 * \warning Do not call this directly!
 *
 * Override this method with your actual write implementation when subclassing!
 *
 * \param buffer The buffer with the data to write
 * \param length The length of the data to write
 */
- (void)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!
 *
 * Override this method with your actual end of stream checking implementation
 * when subclassing!
 *
 * \return Whether the lowlevel is at the end of the stream
 */
- (BOOL)lowlevelIsAtEndOfStream;

- (BOOL)OF_isWaitingForDelimiter;
@end