Overview
Comment: | Add -[readDataArrayTillEndOfStream] to OFStream. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1813376c4ae6bc0d2168e1c8137589c5 |
User & Date: | js on 2010-04-04 16:41:27 |
Other Links: | manifest | tags |
Context
2010-04-04
| ||
16:50 | Rename -[splitWithDelimiter:] to -[componentsSeparatedByString:]. check-in: 7bc07fede9 user: js tags: trunk | |
16:41 | Add -[readDataArrayTillEndOfStream] to OFStream. check-in: 1813376c4a user: js tags: trunk | |
15:45 | Out of memory is way more likely for vasprintf. check-in: 43b963aba6 user: js tags: trunk | |
Changes
Modified src/OFStream.h from [6718a13472] to [ad729fbb54].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 | * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" @class OFString; /** * \brief A base class for different types of streams. */ @interface OFStream: OFObject { char *cache; | > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #import "OFObject.h" @class OFString; @class OFDataArray; /** * \brief A base class for different types of streams. */ @interface OFStream: OFObject { char *cache; |
︙ | ︙ | |||
69 70 71 72 73 74 75 76 77 78 79 80 81 82 | * \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; | > > > > > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | * \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; /** * \return An OFDataArray with an item size of 1 with all the data of the * stream until the end of the stream is reached. */ - (OFDataArray*)readDataArrayTillEndOfStream; /** * 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; |
︙ | ︙ |
Modified src/OFStream.m from [08f611f86c] to [0fee79697f].
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #include "config.h" #include <string.h> #include <assert.h> #import "OFStream.h" #import "OFString.h" #import "OFExceptions.h" #import "macros.h" @implementation OFStream - init { self = [super init]; | > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include "config.h" #include <string.h> #include <assert.h> #import "OFStream.h" #import "OFString.h" #import "OFDataArray.h" #import "OFExceptions.h" #import "macros.h" @implementation OFStream - init { self = [super init]; |
︙ | ︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 92 | - (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]; } - (OFString*)readLineWithEncoding: (enum of_string_encoding)encoding | > > > > > > > > > > > > > > > > > > > > > > > > | 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 107 108 109 110 111 112 113 114 115 116 117 | - (size_t)readNBytesWithoutCache: (size_t)size intoBuffer: (char*)buf { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } - (OFDataArray*)readDataArrayTillEndOfStream { OFDataArray *a; char *buf; a = [OFDataArray dataArrayWithItemSize: 1]; buf = [self allocMemoryWithSize: of_pagesize]; @try { while (![self atEndOfStream]) { size_t size; size = [self readNBytes: of_pagesize intoBuffer: buf]; [a addNItems: size fromCArray: buf]; } } @finally { [self freeMemory: buf]; } return a; } - (OFString*)readLine { return [self readLineWithEncoding: OF_STRING_ENCODING_UTF_8]; } - (OFString*)readLineWithEncoding: (enum of_string_encoding)encoding |
︙ | ︙ |