ObjFW  Check-in [9aa9d6d075]

Overview
Comment:Make it possible to use an OFStream as a key for a dictionary.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9aa9d6d075c1a30ba18d2bd3e662a51edff23e6841302f83af32af9797ee4424
User & Date: js on 2011-09-19 19:12:55
Other Links: manifest | tags
Context
2011-09-20
18:40
OFStreamObserver improvements. check-in: 47caef4f8a user: js tags: trunk
2011-09-19
19:12
Make it possible to use an OFStream as a key for a dictionary. check-in: 9aa9d6d075 user: js tags: trunk
16:40
Add a few private methods to the headers to have type checking. check-in: 6a25d1d677 user: js tags: trunk
Changes

Modified src/OFStream.h from [d01ccdc23f] to [10e2127f1f].

19
20
21
22
23
24
25






26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#import "OFObject.h"
#import "OFString.h"

@class OFDataArray;

/**
 * \brief A base class for different types of streams.






 *
 * IMPORTANT: If you want to subclass this, override _readNBytes:intoBuffer:,
 * _writeNBytes:fromBuffer: and _isAtEndOfStream, but nothing else. Those are
 * not defined in the headers, but do the actual work. OFStream uses those and
 * does all the caching and other stuff. If you override these methods without
 * the _ prefix, you *WILL* break caching and get broken results!
 */
@interface OFStream: OFObject
{
	char   *cache;
	char   *writeBuffer;
	size_t cacheLength, writeBufferLength;
	BOOL   buffersWrites;
	BOOL   blocking;
	BOOL   waitingForDelimiter;







>
>
>
>
>
>







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#import "OFObject.h"
#import "OFString.h"

@class OFDataArray;

/**
 * \brief A base class for different types of streams.
 *
 * WARNING: Even though the OFCopying protocol is implemented, it does
 * <i>not</i> return an independant 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!
 *
 * IMPORTANT: If you want to subclass this, override _readNBytes:intoBuffer:,
 * _writeNBytes:fromBuffer: and _isAtEndOfStream, but nothing else. Those are
 * not defined in the headers, but do the actual work. OFStream uses those and
 * does all the caching and other stuff. If you override these methods without
 * the _ prefix, you *WILL* break caching and get broken results!
 */
@interface OFStream: OFObject <OFCopying>
{
	char   *cache;
	char   *writeBuffer;
	size_t cacheLength, writeBufferLength;
	BOOL   buffersWrites;
	BOOL   blocking;
	BOOL   waitingForDelimiter;

Modified src/OFStream.m from [b36f920107] to [0cc0418399].

85
86
87
88
89
90
91





92
93
94
95
96
97
98

- (void)_writeNBytes: (size_t)length
	  fromBuffer: (const void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}






- (BOOL)isAtEndOfStream
{
	if (cache != NULL)
		return NO;

	return [self _isAtEndOfStream];







>
>
>
>
>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103

- (void)_writeNBytes: (size_t)length
	  fromBuffer: (const void*)buffer
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- copy
{
	return [self retain];
}

- (BOOL)isAtEndOfStream
{
	if (cache != NULL)
		return NO;

	return [self _isAtEndOfStream];