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
|
return self;
}
- (BOOL)atEndOfStream
{
@throw [OFNotImplementedException newWithClass: isa
andSelector: _cmd];
}
- (size_t)readNBytes: (size_t)size
intoBuffer: (char*)buf
{
@throw [OFNotImplementedException newWithClass: isa
andSelector: _cmd];
}
- (OFString*)readLine
{
size_t i, len;
char *ret_c, *tmp, *tmp2;
OFString *ret;
/* Look if there's a line or \0 in our cache */
if (cache != NULL) {
for (i = 0; i < cache_len; i++) {
if (OF_UNLIKELY(cache[i] == '\n' ||
cache[i] == '\0')) {
ret = [OFString stringWithCString: cache
andLength: i];
tmp = [self allocMemoryWithSize: cache_len -
i - 1];
memcpy(tmp, cache + i + 1, cache_len - i - 1);
[self freeMemory: cache];
cache = tmp;
|
|
|
|
|
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
|
return self;
}
- (BOOL)atEndOfStream
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
- (size_t)readNBytes: (size_t)size
intoBuffer: (char*)buf
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
- (OFString*)readLine
{
size_t i, len;
char *ret_c, *tmp, *tmp2;
OFString *ret;
/* Look if there's a line or \0 in our cache */
if (cache != NULL) {
for (i = 0; i < cache_len; i++) {
if (OF_UNLIKELY(cache[i] == '\n' ||
cache[i] == '\0')) {
ret = [OFString stringWithCString: cache
length: i];
tmp = [self allocMemoryWithSize: cache_len -
i - 1];
memcpy(tmp, cache + i + 1, cache_len - i - 1);
[self freeMemory: cache];
cache = tmp;
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
if ([self atEndOfStream]) {
[self freeMemory: tmp];
if (cache == NULL)
return nil;
ret = [OFString stringWithCString: cache
andLength: cache_len];
[self freeMemory: cache];
cache = NULL;
cache_len = 0;
return ret;
}
|
|
|
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
if ([self atEndOfStream]) {
[self freeMemory: tmp];
if (cache == NULL)
return nil;
ret = [OFString stringWithCString: cache
length: cache_len];
[self freeMemory: cache];
cache = NULL;
cache_len = 0;
return ret;
}
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
}
}
- (size_t)writeNBytes: (size_t)size
fromBuffer: (const char*)buf
{
@throw [OFNotImplementedException newWithClass: isa
andSelector: _cmd];
}
- (size_t)writeString: (OFString*)str
{
return [self writeNBytes: [str length]
fromBuffer: [str cString]];
}
|
|
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
}
}
- (size_t)writeNBytes: (size_t)size
fromBuffer: (const char*)buf
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
- (size_t)writeString: (OFString*)str
{
return [self writeNBytes: [str length]
fromBuffer: [str cString]];
}
|
215
216
217
218
219
220
221
222
223
224
|
return self;
}
- close
{
@throw [OFNotImplementedException newWithClass: isa
andSelector: _cmd];
}
@end
|
|
|
215
216
217
218
219
220
221
222
223
224
|
return self;
}
- close
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
@end
|