Overview
Comment: | Make OFStream caching invisible to the programmer. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fc0b2500b9bd2aba1fb4a623f6af9e5e |
User & Date: | js on 2009-12-03 18:50:41 |
Other Links: | manifest | tags |
Context
2009-12-05
| ||
10:45 | Move LDFLAGS for rpath in objfw-config to a separate --rpath flag. check-in: d4a60cdef5 user: js tags: trunk | |
2009-12-03
| ||
18:50 | Make OFStream caching invisible to the programmer. check-in: fc0b2500b9 user: js tags: trunk | |
11:51 | Add -[componentsJoinedByString:] to OFArray. check-in: fb651428aa user: js tags: trunk | |
Changes
Modified TODO from [dbceb3bf95] to [83c7dabc44].
1 2 3 | 1 2 3 4 5 6 7 8 9 10 | - | Test if autorelease pool releases everything correctly when thread is ended Make strings \0-safe |
︙ |
Modified src/OFExceptions.h from [d069b97d96] to [1cdedb1af1].
︙ | |||
275 276 277 278 279 280 281 | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | /** * An OFException indicating a read or write to the file failed. */ @interface OFReadOrWriteFailedException: OFException { size_t req_size; |
︙ |
Modified src/OFExceptions.m from [58c24c0199] to [528afc5c1f].
︙ | |||
402 403 404 405 406 407 408 | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | return mode; } @end @implementation OFReadOrWriteFailedException + newWithClass: (Class)class__ size: (size_t)size |
︙ |
Modified src/OFFile.h from [9d72f8d05d] to [87163d3271].
︙ | |||
122 123 124 125 126 127 128 | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - - - - - - - - - - - - - - - - - - - - - - - - - - | /** * Initializes an already allocated OFFile. * * \param fp A file pointer, returned from for example fopen(). * It is not closed when the OFFile object is deallocated! */ - initWithFilePointer: (FILE*)fp; |
Modified src/OFFile.m from [9c9c1d09c4] to [ea32f092c7].
︙ | |||
186 187 188 189 190 191 192 | 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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | - + - - - - - - - - - - - - - - - - - + - - - - - - - - - - + - - - - + + + - - - + - - - - - - + + + + + + + - - | { if (close && fp != NULL) fclose(fp); [super dealloc]; } |
︙ |
Modified src/OFSocket.m from [d65c17ca33] to [866349c818].
︙ | |||
46 47 48 49 50 51 52 | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | - + - + | sock = INVALID_SOCKET; saddr = NULL; return self; } |
︙ |
Modified src/OFStream.h from [f0bc557550] to [15f483123e].
︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 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; /** |
︙ | |||
78 79 80 81 82 83 84 | 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; |
Modified src/OFStream.m from [2c5ce7298e] to [dff3658c98].
︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | 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 94 95 96 97 98 99 100 101 102 103 104 105 106 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | #endif return self; } - (BOOL)atEndOfStream { if (cache != NULL) return NO; return [self atEndOfStreamWithoutCache]; } - (BOOL)atEndOfStreamWithoutCache { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - (size_t)readNBytes: (size_t)size intoBuffer: (char*)buf { if (cache == NULL) return [self readNBytesWithoutCache: size intoBuffer: buf]; if (size >= cache_len) { size_t ret = cache_len; memcpy(buf, cache, cache_len); [self freeMemory: cache]; cache = NULL; cache_len = 0; return ret; } else { char *tmp = [self allocMemoryWithSize: cache_len - size]; memcpy(tmp, cache + size, cache_len - size); memcpy(buf, cache, size); [self freeMemory: cache]; cache = tmp; cache_len -= size; return size; } } - (size_t)readNBytesWithoutCache: (size_t)size intoBuffer: (char*)buf { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - (OFString*)readLine { return [self readLineWithEncoding: OF_STRING_ENCODING_UTF_8]; |
︙ | |||
96 97 98 99 100 101 102 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | - + - + | } } /* Read until we get a newline or \0 */ tmp = [self allocMemoryWithSize: pagesize]; for (;;) { |
︙ | |||
203 204 205 206 207 208 209 | 241 242 243 244 245 246 247 248 249 250 251 252 253 | - - - - - - - - - - - - - - - - - - | - (size_t)writeString: (OFString*)str { return [self writeNBytes: [str cStringLength] fromBuffer: [str cString]]; } |