ObjFW  Diff

Differences From Artifact [f0bc557550]:

To Artifact [15f483123e]:


18
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
47
48










49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
18
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

62
63


64
65
66



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86



87
88
89
90
91
92
93







+
+
+
+
+
+





+
+
+
+
+
+
+
+
+
+
+

+
+
+
+










-
+

-
-
+
+

-
-
-
+
+
+
+
+
+
+
+
+
+










-
-
-







@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
 * thus get broken results!
 *
 * \return A boolean whether the end of the stream has been reached
 */
- (BOOL)atEndOfStream;

/**
 * Returns a boolean whether the end of the stream has been reached without
 * looking at the cache.
 *
 * IMPORTANT: Do *NOT* use this! Use atEndOfCache instead, as this is *ONLY*
 * for being overriden in subclasses!
 *
 * \return A boolean whether the end of the stream has been reached
 */
- (BOOL)atEndOfStreamWithoutCache;

/**
 * Reads from the stream into a buffer.
 *
 * IMPORTANT: Do *NOT* override this in subclasses! Override
 * readNBytesWithoutCache:intoBuffer: instead, as otherwise, you *WILL* break
 * caching and thus get broken results!
 *
 * \param buf The buffer into which the data is read
 * \param size The size of the data that should be read.
 *	  The buffer MUST be at least size big!
 * \return The number of bytes read
 */
- (size_t)readNBytes: (size_t)size
	  intoBuffer: (char*)buf;

/**
 * Read until a newline, \\0 or end of stream occurs.
 * Reads from the stream into a buffer without looking at the cache.
 *
 * If you want to use readNBytes afterwards again, you have to clear the cache
 * before and optionally get the cache before clearing it!
 * IMPORTANT: Do *NOT* use this! Use readNBytes:intoBuffer: instead, as this is
 * *ONLY* for being overriden in subclasses!
 *
 * You also need to pay attention to the cache if you want to know if there is
 * still data left - atEndOfStream can return NO even if there is still data
 * in the cache!
 * \param buf The buffer into which the data is read
 * \param size The size of the data that should be read.
 *	  The buffer MUST be at least size big!
 * \return The number of bytes read
 */
- (size_t)readNBytesWithoutCache: (size_t)size
		      intoBuffer: (char*)buf;

/**
 * Read until a newline, \\0 or end of stream occurs.
 *
 * \return The line that was read, autoreleased, or nil if the end of the
 *	   stream has been reached.
 */
- (OFString*)readLine;

/**
 * Read with the specified encoding until a newline, \\0 or end of stream
 * occurs.
 *
 * If you want to use readNBytes afterwards again, you have to clear the cache
 * before and optionally get the cache before clearing it!
 *
 * \return The line that was read, autoreleased, or nil if the end of the
 *	   stream has been reached.
 */
- (OFString*)readLineWithEncoding: (enum of_string_encoding)encoding;

/**
 * Writes from a buffer into the stream.
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
103
104
105
106
107
108
109














110
111
112
113
114







-
-
-
-
-
-
-
-
-
-
-
-
-
-





 * Writes a string into the stream, without the trailing zero.
 *
 * \param str The string from which the data is written to the stream
 * \return The number of bytes written
 */
- (size_t)writeString: (OFString*)str;

/**
 * Sets a specified pointer to the cache and returns the length of the cache.
 *
 * \param ptr A pointer to a pointer. It will be set to the cache.
 *	      If it is NULL, only the number of bytes in the cache is returned.
 * \return The number of bytes in the cache.
 */
- (size_t)getCache: (char**)ptr;

/**
 * Clears the cache.
 */
- clearCache;

/**
 * Closes the stream.
 */
- close;
@end