ObjFW  Diff

Differences From Artifact [57d47bf4a5]:

To Artifact [3b5c7f98e9]:


21
22
23
24
25
26
27

28
29
30
31
32
33
34
#include <limits.h>

#import "OFDataArray.h"
#import "OFString.h"
#import "OFFile.h"
#import "OFURL.h"
#import "OFHTTPRequest.h"

#import "OFAutoreleasePool.h"

#import "OFHTTPRequestFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"







>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <limits.h>

#import "OFDataArray.h"
#import "OFString.h"
#import "OFFile.h"
#import "OFURL.h"
#import "OFHTTPRequest.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFHTTPRequestFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFNotImplementedException.h"
#import "OFOutOfMemoryException.h"
167
168
169
170
171
172
173






























174
175
176
177
178
179
180
	itemSize = 1;

	if (!of_base64_decode(self, [string cString], [string cStringLength])) {
		Class c = isa;
		[self release];
		@throw [OFInvalidEncodingException newWithClass: c];
	}































	return self;
}

- (size_t)count
{
	return count;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
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
	itemSize = 1;

	if (!of_base64_decode(self, [string cString], [string cStringLength])) {
		Class c = isa;
		[self release];
		@throw [OFInvalidEncodingException newWithClass: c];
	}

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

	itemSize = 1;

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFString *stringValue;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		stringValue = [element stringValue];

		if (!of_base64_decode(self, [stringValue cString],
		    [stringValue cStringLength]))
			@throw [OFInvalidEncodingException newWithClass: isa];

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (size_t)count
{
	return count;
411
412
413
414
415
416
417

























418
419
420
421
422
423
424
	@try {
		[file writeNBytes: count * itemSize
		       fromBuffer: data];
	} @finally {
		[file release];
	}
}

























@end

@implementation OFBigDataArray
- (void)addItem: (const void*)item
{
	size_t newSize, lastPageByte;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
474
475
476
477
478
479
480
	@try {
		[file writeNBytes: count * itemSize
		       fromBuffer: data];
	} @finally {
		[file release];
	}
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool;
	OFXMLElement *element;

	if (itemSize != 1)
		@throw [OFNotImplementedException newWithClass: isa
						      selector: _cmd];

	pool = [[OFAutoreleasePool alloc] init];
	element = [OFXMLElement
	    elementWithName: [self className]
		  namespace: OF_SERIALIZATION_NS
		stringValue: of_base64_encode(data, count * itemSize)];

	[element retain];
	@try {
		[pool release];
	} @finally {
		[element autorelease];
	}

	return element;
}
@end

@implementation OFBigDataArray
- (void)addItem: (const void*)item
{
	size_t newSize, lastPageByte;