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
|