ObjFW  Check-in [756bb26c98]

Overview
Comment:Change serialization format to be way more readable and shorter.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 756bb26c988400410e2dc87db0c2b382da2dfaa879ab885a38a1f0c7997c3b31
User & Date: js on 2011-06-28 01:51:13
Other Links: manifest | tags
Context
2011-06-28
18:14
Use floats for of_point_t and of_dimension_t. check-in: 722f0808e8 user: js tags: trunk
01:51
Change serialization format to be way more readable and shorter. check-in: 756bb26c98 user: js tags: trunk
2011-06-27
23:44
Add -[elements] and -[elementsForNamespace:] to OFXMLElement. check-in: 9b1baaa39b user: js tags: trunk
Changes

Modified src/OFArray.m from [cdeeda612a] to [4847514de9].

233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250

251
252
253




254
255
256
257
258
259
260
	@try {
		OFAutoreleasePool *pool, *pool2;
		OFEnumerator *enumerator;
		OFXMLElement *child;

		pool = [[OFAutoreleasePool alloc] init];

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

		enumerator = [[element
		    elementsForName: @"object"
			  namespace: OF_SERIALIZATION_NS] objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {
			id object = [child objectByDeserializing];





			[array addItem: &object];
			[object retain];

			[pool2 releaseObjects];
		}

		[pool release];







|
|
<
<



|
<
<

>

|

>
>
>
>







233
234
235
236
237
238
239
240
241


242
243
244
245


246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
	@try {
		OFAutoreleasePool *pool, *pool2;
		OFEnumerator *enumerator;
		OFXMLElement *child;

		pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		enumerator = [[element children] objectEnumerator];


		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {
			id object;

			if (![[child namespace] isEqual: OF_SERIALIZATION_NS])
				continue;

			object = [child objectByDeserializing];
			[array addItem: &object];
			[object retain];

			[pool2 releaseObjects];
		}

		[pool release];
500
501
502
503
504
505
506

507
508
509
510
511
512
513
514
515
516
517
518
519
520

521
522
523


524



525
526
527
528
529
530
531
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{

	OFAutoreleasePool *pool;
	OFXMLElement *element;
	id <OFSerialization> *cArray = [array cArray];
	size_t i, count = [array count];

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

	for (i = 0; i < count; i++) {
		[element addChild: [cArray[i] XMLElementBySerializing]];

		[pool releaseObjects];
	}



	[pool release];




	return element;
}

- (void)makeObjectsPerformSelector: (SEL)selector
{
	id *cArray = [array cArray];







>
|




|
|

|
<
<



>
|


>
>
|
>
>
>







501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517


518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;
	OFXMLElement *element;
	id <OFSerialization> *cArray = [array cArray];
	size_t i, count = [array count];

	element = [[OFXMLElement alloc] initWithName: [self className]
					   namespace: OF_SERIALIZATION_NS];

	pool2 = [[OFAutoreleasePool alloc] init];



	for (i = 0; i < count; i++) {
		[element addChild: [cArray[i] XMLElementBySerializing]];

		[pool2 releaseObjects];
	}

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

	return element;
}

- (void)makeObjectsPerformSelector: (SEL)selector
{
	id *cArray = [array cArray];

Modified src/OFDate.m from [914a225e3e] to [884edb1d64].

246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280

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

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLElement *secondsElement, *microsecondsElement;

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

		secondsElement = [element elementForName: @"seconds"
					       namespace: OF_SERIALIZATION_NS];
		microsecondsElement = [element
		    elementForName: @"microseconds"
			 namespace: OF_SERIALIZATION_NS];

		if (secondsElement == nil || microsecondsElement == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		seconds = (int64_t)[secondsElement decimalValue];
		microseconds = (uint32_t)[microsecondsElement decimalValue];

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








|

|
|
<
<



|
<
|
|
<

|



|
|







246
247
248
249
250
251
252
253
254
255
256


257
258
259
260

261
262

263
264
265
266
267
268
269
270
271
272
273
274
275
276

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

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLAttribute *secondsAttribute, *microsecondsAttribute;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		secondsAttribute = [element attributeForName: @"seconds"];

		microsecondsAttribute =
		    [element attributeForName: @"microseconds"];


		if (secondsAttribute == nil || microsecondsAttribute == nil)
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		seconds = (int64_t)[secondsAttribute decimalValue];
		microseconds = (uint32_t)[microsecondsAttribute decimalValue];

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

342
343
344
345
346
347
348
349
350

351
352
353
354



355
356
357


358
359

360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
- (OFString*)description
{
	return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}

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


	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];




	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];



	[element addChild:

	    [OFXMLElement elementWithName: @"seconds"
				namespace: OF_SERIALIZATION_NS
			      stringValue: [OFString stringWithFormat:
					       @"%" @PRId64, seconds]]];
	[element addChild:
	    [OFXMLElement elementWithName: @"microseconds"
				namespace: OF_SERIALIZATION_NS
			      stringValue: [OFString stringWithFormat:
					       @"%" @PRIu32, microseconds]]];

	[pool release];

	return element;
}

- (uint32_t)microsecond
{
	return microseconds;







|

>

|


>
>
>
|
|
|
>
>

|
>
|
<
<
|
|
<
<
<
<
|
<







338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363


364
365




366

367
368
369
370
371
372
373
- (OFString*)description
{
	return [self dateStringWithFormat: @"%Y-%m-%dT%H:%M:%SZ"];
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;
	OFString *secondsString, *microsecondsString;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];

	secondsString = [OFString stringWithFormat: @"%" @PRId64, seconds];
	microsecondsString = [OFString stringWithFormat: @"%" @PRId64,
							 microseconds];

	[element addAttributeWithName: @"seconds"
			  stringValue: secondsString];
	[element addAttributeWithName: @"microseconds"
			  stringValue: microsecondsString];

	[element retain];
	@try {
		[pool release];


	} @finally {
		[element autorelease];




	}


	return element;
}

- (uint32_t)microsecond
{
	return microseconds;

Modified src/OFDictionary.m from [ec22393fcd] to [b73da14229].

23
24
25
26
27
28
29

30
31
32
33
34
35
36
#import "OFArray.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"

#import "OFOutOfRangeException.h"

#import "macros.h"

struct of_dictionary_bucket of_dictionary_deleted_bucket = {};

#define DELETED &of_dictionary_deleted_bucket







>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "OFArray.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFOutOfRangeException.h"

#import "macros.h"

struct of_dictionary_bucket of_dictionary_deleted_bucket = {};

#define DELETED &of_dictionary_deleted_bucket
474
475
476
477
478
479
480

481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496

497
498


499



500

501


502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {

		OFAutoreleasePool *pool, *pool2;
		OFMutableDictionary *dictionary;
		OFArray *pairs;
		OFEnumerator *enumerator;
		OFXMLElement *pair;

		pool = [[OFAutoreleasePool alloc] init];

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

		dictionary = [OFMutableDictionary dictionary];

		pairs = [element elementsForName: @"pair"
				       namespace: OF_SERIALIZATION_NS];






		enumerator = [pairs objectEnumerator];

		pool2 = [[OFAutoreleasePool alloc] init];


		while ((pair = [enumerator nextObject]) != nil) {
			OFXMLElement *keyElement, *valueElement;
			id <OFSerialization, OFCopying> key;
			id <OFSerialization> object;

			keyElement = [pair elementForName: @"key"
						namespace: OF_SERIALIZATION_NS];
			valueElement = [pair
			    elementForName: @"value"
				 namespace: OF_SERIALIZATION_NS];

			if (keyElement == nil || valueElement == nil)
				@throw [OFInvalidArgumentException
				    newWithClass: isa
					selector: _cmd];

			key = [[keyElement elementForName: @"object"
						namespace: OF_SERIALIZATION_NS]
			    objectByDeserializing];
			object = [[valueElement
			    elementForName: @"object"
				 namespace: OF_SERIALIZATION_NS]
			    objectByDeserializing];

			[dictionary setObject: object
				       forKey: key];

			[pool2 releaseObjects];
		}

		self = [self initWithDictionary: dictionary];

		[pool release];







>
|

|
|
|

<
<
|
|
<
<




>
|
|
>
>

>
>
>
|
>

>
>
|
|
<
<

|
|
|
<
|

|
|
|
<

<
<
|
<
<
<
|
<
<
<







475
476
477
478
479
480
481
482
483
484
485
486
487
488


489
490


491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510


511
512
513
514

515
516
517
518
519

520


521



522



523
524
525
526
527
528
529

	return self;
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFAutoreleasePool *pool2;
		OFMutableDictionary *dictionary;
		OFArray *keys, *objects;
		OFEnumerator *keyEnumerator, *objectEnumerator;
		OFXMLElement *keyElement, *objectElement;



		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		dictionary = [OFMutableDictionary dictionary];

		keys = [element elementsForName: @"key"
				      namespace: OF_SERIALIZATION_NS];
		objects = [element elementsForName: @"object"
					 namespace: OF_SERIALIZATION_NS];

		if ([keys count] != [objects count])
			@throw [OFInvalidFormatException newWithClass: isa];

		keyEnumerator = [keys objectEnumerator];
		objectEnumerator = [objects objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((keyElement = [keyEnumerator nextObject]) != nil &&
		    (objectElement = [objectEnumerator nextObject]) != nil) {
			OFXMLElement *key, *object;



			key = [[keyElement elementsForNamespace:
			    OF_SERIALIZATION_NS] firstObject];
			object = [[objectElement elementsForNamespace:

			    OF_SERIALIZATION_NS] firstObject];

			if (key == nil || object == nil)
				@throw [OFInvalidFormatException
				    newWithClass: isa];




			[dictionary setObject: [object objectByDeserializing]



				       forKey: [key objectByDeserializing]];




			[pool2 releaseObjects];
		}

		self = [self initWithDictionary: dictionary];

		[pool release];
822
823
824
825
826
827
828

829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844

845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864

865
866
867
868


869



870
871
872
873
874
875
876
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{

	OFAutoreleasePool *pool, *pool2;
	OFXMLElement *element;
	OFEnumerator *keyEnumerator, *objectEnumerator;
	id <OFSerialization> key, object;

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

	keyEnumerator = [self keyEnumerator];
	objectEnumerator = [self objectEnumerator];

	pool2 = [[OFAutoreleasePool alloc] init];

	while ((key = [keyEnumerator nextObject]) != nil &&
	       (object = [objectEnumerator nextObject]) != nil) {
		OFXMLElement *pair, *keyElement, *valueElement;

		pair = [OFXMLElement elementWithName: @"pair"
					   namespace: OF_SERIALIZATION_NS];

		keyElement = [OFXMLElement
		    elementWithName: @"key"
			  namespace: OF_SERIALIZATION_NS];
		[keyElement addChild: [key XMLElementBySerializing]];
		[pair addChild: keyElement];

		valueElement = [OFXMLElement
		    elementWithName: @"value"
			  namespace: OF_SERIALIZATION_NS];
		[valueElement addChild: [object XMLElementBySerializing]];
		[pair addChild: valueElement];

		[element addChild: pair];


		[pool2 releaseObjects];
	}



	[pool release];




	return element;
}
@end

@implementation OFDictionaryEnumerator
- initWithDictionary: (OFDictionary*)dictionary_







>
|




|


<
<
<
<


<

>


|
<
<
<





<

|
|

|
<

|
>




>
>
|
>
>
>







817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832




833
834

835
836
837
838
839



840
841
842
843
844

845
846
847
848
849

850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;
	OFXMLElement *element;
	OFEnumerator *keyEnumerator, *objectEnumerator;
	id <OFSerialization> key, object;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];





	keyEnumerator = [self keyEnumerator];
	objectEnumerator = [self objectEnumerator];

	pool2 = [[OFAutoreleasePool alloc] init];

	while ((key = [keyEnumerator nextObject]) != nil &&
	       (object = [objectEnumerator nextObject]) != nil) {
		OFXMLElement *keyElement, *objectElement;




		keyElement = [OFXMLElement
		    elementWithName: @"key"
			  namespace: OF_SERIALIZATION_NS];
		[keyElement addChild: [key XMLElementBySerializing]];


		objectElement = [OFXMLElement
		    elementWithName: @"object"
			  namespace: OF_SERIALIZATION_NS];
		[objectElement addChild: [object XMLElementBySerializing]];


		[element addChild: keyElement];
		[element addChild: objectElement];

		[pool2 releaseObjects];
	}

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

	return element;
}
@end

@implementation OFDictionaryEnumerator
- initWithDictionary: (OFDictionary*)dictionary_

Modified src/OFList.m from [8deaa7a6b1] to [037aaf69fa].

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
}

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

	@try {

		OFAutoreleasePool *pool, *pool2;
		OFEnumerator *enumerator;
		OFXMLElement *child;

		pool = [[OFAutoreleasePool alloc] init];

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

		enumerator = [[element
		    elementsForName: @"object"
			  namespace: OF_SERIALIZATION_NS] objectEnumerator];
		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {
			id object = [child objectByDeserializing];


			[self appendObject: object];

			[pool2 releaseObjects];
		}

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







>
|



<
<
|
|
<
<



|
<
<

>

|
>

|







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
}

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

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFAutoreleasePool *pool2;
		OFEnumerator *enumerator;
		OFXMLElement *child;



		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		enumerator = [[element children] objectEnumerator];


		pool2 = [[OFAutoreleasePool alloc] init];

		while ((child = [enumerator nextObject]) != nil) {
			if (![[child namespace] isEqual: OF_SERIALIZATION_NS])
				continue;

			[self appendObject: [child objectByDeserializing]];

			[pool2 releaseObjects];
		}

		[pool release];
	} @catch (id e) {
		[self release];
363
364
365
366
367
368
369

370
371
372
373
374
375
376
377
378
379
380
381
382

383
384
385


386



387
388
389
390
391
392
393
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{

	OFAutoreleasePool *pool;
	OFXMLElement *element;
	of_list_object_t *iter;

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	pool = [[OFAutoreleasePool alloc] init];
	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

	for (iter = firstListObject; iter != NULL; iter = iter->next) {
		[element addChild: [iter->object XMLElementBySerializing]];

		[pool releaseObjects];
	}



	[pool release];




	return element;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_







>
|



|


|
<
<



>
|


>
>
|
>
>
>







360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375


376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
	 */
	ret->isa = [OFString class];
	return ret;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFAutoreleasePool *pool2;
	OFXMLElement *element;
	of_list_object_t *iter;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];

	pool2 = [[OFAutoreleasePool alloc] init];



	for (iter = firstListObject; iter != NULL; iter = iter->next) {
		[element addChild: [iter->object XMLElementBySerializing]];

		[pool2 releaseObjects];
	}

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

	return element;
}

- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state
			   objects: (id*)objects
			     count: (int)count_

Modified src/OFNull.m from [28d217dbf3] to [5534adc13a].

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
{
	OFAutoreleasePool *pool;

	[self release];

	pool = [[OFAutoreleasePool alloc] init];

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

	[pool release];

	return [OFNull null];
}

- (OFString*)description
{
	return @"<null>";
}

- copy
{
	return self;
}

- (OFXMLElement*)XMLElementBySerializing
{

	OFXMLElement *element;

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	[element addAttributeWithName: @"class"
			  stringValue: [self className]];





	return element;
}

- autorelease
{
	return self;







|
|
<
<




















>


|

>
|
|
>
>
>
>







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
{
	OFAutoreleasePool *pool;

	[self release];

	pool = [[OFAutoreleasePool alloc] init];

	if (![[element name] isEqual: [self className]] ||
	    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	[pool release];

	return [OFNull null];
}

- (OFString*)description
{
	return @"<null>";
}

- copy
{
	return self;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];

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

	return element;
}

- autorelease
{
	return self;

Modified src/OFNumber.m from [a47eecf9ee] to [a3610e7d0e].

712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
{
	self = [super init];

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

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

		typeString = [[element attributeForName: @"type"] stringValue];

		if ([typeString isEqual: @"boolean"]) {
			type = OF_NUMBER_BOOL;







|
|
<
<







712
713
714
715
716
717
718
719
720


721
722
723
724
725
726
727
{
	self = [super init];

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

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		typeString = [[element attributeForName: @"type"] stringValue];

		if ([typeString isEqual: @"boolean"]) {
			type = OF_NUMBER_BOOL;
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
	default:
		@throw [OFInvalidFormatException newWithClass: isa];
	}
}

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

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	pool = [[OFAutoreleasePool alloc] init];

	[element addAttributeWithName: @"class"
			  stringValue: [self className]];
	[element setStringValue: [self description]];

	switch (type) {
	case OF_NUMBER_BOOL:
		[element addAttributeWithName: @"type"
				  stringValue: @"boolean"];
		break;
	case OF_NUMBER_UCHAR:







|


|
|
<
<
<
<
|
<







1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182




1183

1184
1185
1186
1187
1188
1189
1190
	default:
		@throw [OFInvalidFormatException newWithClass: isa];
	}
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS




				    stringValue: [self description]];


	switch (type) {
	case OF_NUMBER_BOOL:
		[element addAttributeWithName: @"type"
				  stringValue: @"boolean"];
		break;
	case OF_NUMBER_UCHAR:
1251
1252
1253
1254
1255
1256
1257


1258



1259
1260
1261
1262
		    [OFString stringWithFormat: @"%" PRIX64, d.i]];

		break;
	default:
		@throw [OFInvalidFormatException newWithClass: isa];
	}



	[pool release];




	return element;
}
@end







>
>
|
>
>
>




1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
		    [OFString stringWithFormat: @"%" PRIX64, d.i]];

		break;
	default:
		@throw [OFInvalidFormatException newWithClass: isa];
	}

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

	return element;
}
@end

Modified src/OFObject+Serialization.m from [3d621a2dfd] to [dc7ca94ebf].

41
42
43
44
45
46
47


48
49
50
51
52
53

54
55
56
57
58
59
60
61
62
			selector: @selector(stringBySerializing)];

	pool = [[OFAutoreleasePool alloc] init];
	element = [(id)self XMLElementBySerializing];

	root = [OFXMLElement elementWithName: @"serialization"
				   namespace: OF_SERIALIZATION_NS];


	[root addChild: element];

	ret = [@"<?xml version='1.0' encoding='UTF-8'?>\n"
	    stringByAppendingString: [root XMLStringWithIndentation: 2]];
	[ret retain];


	@try {
		[pool release];
	} @catch (id e) {
		[ret release];
	}

	return [ret autorelease];
}
@end







>
>




<

>


|
|


|


41
42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
62
63
64
			selector: @selector(stringBySerializing)];

	pool = [[OFAutoreleasePool alloc] init];
	element = [(id)self XMLElementBySerializing];

	root = [OFXMLElement elementWithName: @"serialization"
				   namespace: OF_SERIALIZATION_NS];
	[root addAttributeWithName: @"version"
		       stringValue: @"0"];
	[root addChild: element];

	ret = [@"<?xml version='1.0' encoding='UTF-8'?>\n"
	    stringByAppendingString: [root XMLStringWithIndentation: 2]];


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

	return ret;
}
@end

Modified src/OFString+Serialization.m from [4e08e43153] to [9bfc5b2d3f].

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
- (id)objectByDeserializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *root = [OFXMLElement elementWithXMLString: self];
	OFArray *elements;
	id object;

	elements = [root elementsForName: @"object"
			       namespace: OF_SERIALIZATION_NS];

	if ([elements count] != 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	object = [[[elements firstObject] objectByDeserializing] retain];








|
<







31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
- (id)objectByDeserializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *root = [OFXMLElement elementWithXMLString: self];
	OFArray *elements;
	id object;

	elements = [root elementsForNamespace: OF_SERIALIZATION_NS];


	if ([elements count] != 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	object = [[[elements firstObject] objectByDeserializing] retain];

Modified src/OFString.m from [e237ea2567] to [88ca1bcd74].

1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

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

		self = [self initWithString: [element stringValue]];

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







|
|
<
<







1077
1078
1079
1080
1081
1082
1083
1084
1085


1086
1087
1088
1089
1090
1091
1092
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		self = [self initWithString: [element stringValue]];

		[pool release];
	} @catch (id e) {
1269
1270
1271
1272
1273
1274
1275
1276
1277

1278





1279
1280
1281
1282
1283
1284
1285
1286
1287
1288

1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
- (OFString*)description
{
	return [[self copy] autorelease];
}

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







	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS
				    stringValue: self];

	pool = [[OFAutoreleasePool alloc] init];

	if ([self isKindOfClass: [OFConstantString class]])
		[element addAttributeWithName: @"class"
				  stringValue: @"OFString"];
	else

		[element addAttributeWithName: @"class"
				  stringValue: [self className]];

	[pool release];

	return element;
}

- (of_unichar_t)characterAtIndex: (size_t)index
{
	of_unichar_t c;







|

>

>
>
>
>
>
|



<
<
<
|
|
|
>
|
<
|
<







1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286



1287
1288
1289
1290
1291

1292

1293
1294
1295
1296
1297
1298
1299
- (OFString*)description
{
	return [[self copy] autorelease];
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;
	OFString *className;

	if ([self isKindOfClass: [OFConstantString class]])
		className = @"OFString";
	else
		className = [self className];

	element = [OFXMLElement elementWithName: className
				      namespace: OF_SERIALIZATION_NS
				    stringValue: self];




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

	}


	return element;
}

- (of_unichar_t)characterAtIndex: (size_t)index
{
	of_unichar_t c;

Modified src/OFURL.m from [83b3387d68] to [e46fcb96eb].

285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

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

		self = [self initWithString: [element stringValue]];

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







|
|
<
<







285
286
287
288
289
290
291
292
293


294
295
296
297
298
299
300
}

- initWithSerialization: (OFXMLElement*)element
{
	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		self = [self initWithString: [element stringValue]];

		[pool release];
	} @catch (id e) {
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562


563
564
565
566
567
568
569
- (OFString*)description
{
	return [self string];
}

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

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	pool = [[OFAutoreleasePool alloc] init];

	[element addAttributeWithName: @"class"
			  stringValue: [self className]];


	[element setStringValue: [self string]];

	[pool release];

	return element;
}
@end







|


|
|
|
<

|
|
>
>
|
|
<




544
545
546
547
548
549
550
551
552
553
554
555
556

557
558
559
560
561
562
563

564
565
566
567
- (OFString*)description
{
	return [self string];
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS
				    stringValue: [self string]];


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


	return element;
}
@end

Modified src/OFXMLAttribute.m from [6b3b878926] to [836db12fdb].

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
- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

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

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

		name = [[[element
		    elementForName: @"name"
			 namespace: OF_SERIALIZATION_NS] stringValue] retain];
		ns = [[[element
		    elementForName: @"namespace"
			 namespace: OF_SERIALIZATION_NS] stringValue] retain];

		stringValue = [[[element
		    elementForName: @"stringValue"
			 namespace: OF_SERIALIZATION_NS] stringValue] retain];

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








|
|
<
<



|
|
<
|
<
<
>
|
|
<







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
- initWithSerialization: (OFXMLElement*)element
{
	self = [super init];

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

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		name = [[[element attributeForName: @"name"] stringValue]
		    copy];

		ns = [[[element attributeForName: @"namespace"] stringValue]


		    copy];
		stringValue = [[[element attributeForName: @"stringValue"]
		    stringValue] copy];


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

163
164
165
166
167
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
	OF_HASH_FINALIZE(hash);

	return hash;
}

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

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	pool = [[OFAutoreleasePool alloc] init];

	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

	[element addChild:
	    [OFXMLElement elementWithName: @"name"
				namespace: OF_SERIALIZATION_NS
			      stringValue: name]];
	if (ns != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"namespace"
					namespace: OF_SERIALIZATION_NS
				      stringValue: ns]];
	[element addChild:
	    [OFXMLElement elementWithName: @"stringValue"
				namespace: OF_SERIALIZATION_NS
			      stringValue: stringValue]];



	[pool release];




	return element;
}
@end







|


|


<
<
|
|

<
<
<
<

|
<
<
|
|
|
<
|

>
>
|
>
>
>




158
159
160
161
162
163
164
165
166
167
168
169
170


171
172
173




174
175


176
177
178

179
180
181
182
183
184
185
186
187
188
189
190
	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];



	[element addAttributeWithName: @"name"
			  stringValue: name];





	if (ns != nil)
		[element addAttributeWithName: @"namespace"


				  stringValue: ns];

	[element addAttributeWithName: @"stringValue"

			  stringValue: stringValue];

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

	return element;
}
@end

Modified src/OFXMLElement+Serialization.m from [7fc442d7ba] to [7e2dfe5b27].

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

int _OFXMLElement_Serialization_reference;

@implementation OFXMLElement (Serialization)
- (id)objectByDeserializing
{
	OFAutoreleasePool *pool;
	OFString *className;
	Class class;
	id <OFSerialization> object;

	pool = [[OFAutoreleasePool alloc] init];
	className = [[self attributeForName: @"class"] stringValue];
	if (className == nil)
		@throw [OFNotImplementedException
		    newWithClass: nil
			selector: @selector(initWithSerialization:)];

	class = objc_lookUpClass([className cString]);
	if (class == Nil)
		@throw [OFNotImplementedException newWithClass: Nil];

	if (![class conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFNotImplementedException
		    newWithClass: class
			selector: @selector(initWithSerialization:)];

	object = [[class alloc] initWithSerialization: self];

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

	return [object autorelease];
}
@end







<




<
<
<
<
<

|
<











|
|
<


|


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

int _OFXMLElement_Serialization_reference;

@implementation OFXMLElement (Serialization)
- (id)objectByDeserializing
{
	OFAutoreleasePool *pool;

	Class class;
	id <OFSerialization> object;

	pool = [[OFAutoreleasePool alloc] init];






	if ((class = objc_lookUpClass([name cString])) == Nil)

		@throw [OFNotImplementedException newWithClass: Nil];

	if (![class conformsToProtocol: @protocol(OFSerialization)])
		@throw [OFNotImplementedException
		    newWithClass: class
			selector: @selector(initWithSerialization:)];

	object = [[class alloc] initWithSerialization: self];

	@try {
		[pool release];
	} @finally {
		[object autorelease];

	}

	return object;
}
@end

Modified src/OFXMLElement.m from [de3d68907d] to [4687f4ccbd].

25
26
27
28
29
30
31

32
33
34
35
36
37
38
#import "OFDictionary.h"
#import "OFXMLAttribute.h"
#import "OFXMLParser.h"
#import "OFXMLElementBuilder.h"
#import "OFAutoreleasePool.h"

#import "OFInvalidArgumentException.h"

#import "OFMalformedXMLException.h"
#import "OFNotImplementedException.h"
#import "OFUnboundNamespaceException.h"

#import "macros.h"

/* References for static linking */







>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#import "OFDictionary.h"
#import "OFXMLAttribute.h"
#import "OFXMLParser.h"
#import "OFXMLElementBuilder.h"
#import "OFAutoreleasePool.h"

#import "OFInvalidArgumentException.h"
#import "OFInvalidFormatException.h"
#import "OFMalformedXMLException.h"
#import "OFNotImplementedException.h"
#import "OFUnboundNamespaceException.h"

#import "macros.h"

/* References for static linking */
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
319
320
321
322
323

324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLElement *attributesElement, *namespacesElement;
		OFXMLElement *childrenElement;

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

		name = [[[element
		    elementForName: @"name"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];
		ns = [[[element
		    elementForName: @"namespace"
			namespace: OF_SERIALIZATION_NS] stringValue] copy];
		defaultNamespace = [[[element
		    elementForName: @"defaultNamespace"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];
		characters = [[[element
		    elementForName: @"characters"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];
		CDATA = [[[element
		    elementForName: @"CDATA"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];
		comment = [[[element
		    elementForName: @"comment"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];

		attributesElement = [element
		    elementForName: @"attributes"
			 namespace: OF_SERIALIZATION_NS];

		namespacesElement = [element
		    elementForName: @"namespaces"
			 namespace: OF_SERIALIZATION_NS];
		childrenElement = [element elementForName: @"children"
						namespace: OF_SERIALIZATION_NS];

		attributes = [[[attributesElement
		    elementForName: @"object"
			 namespace: OF_SERIALIZATION_NS] objectByDeserializing]
		    retain];
		namespaces = [[[namespacesElement
		    elementForName: @"object"
			 namespace: OF_SERIALIZATION_NS] objectByDeserializing]
		    retain];
		children = [[[childrenElement
		    elementForName: @"object"
			 namespace: OF_SERIALIZATION_NS] objectByDeserializing]
		    retain];

		if (!((name != nil || ns != nil || defaultNamespace != nil ||
		    [attributes count] > 0 || [namespaces count] > 0 ||
		    [children count] > 0) ^ (characters != nil) ^
		    (CDATA != nil) ^ (comment != nil)))
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];







|
|
<
<



|
<
<
|
<
|
|
|
<










|

|
>
|

|
<
|
|
<
|
|
<
<
<
|
|
|
|
|
<







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
319
320
321
322

323
324

325
326



327
328
329
330
331

332
333
334
335
336
337
338
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
		OFXMLElement *attributesElement, *namespacesElement;
		OFXMLElement *childrenElement;

		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])


			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		name = [[[element attributeForName: @"name"] stringValue] copy];


		ns = [[[element attributeForName: @"namespace"] stringValue]

		    copy];
		defaultNamespace = [[[element attributeForName:
		    @"defaultNamespace"] stringValue] copy];

		characters = [[[element
		    elementForName: @"characters"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];
		CDATA = [[[element
		    elementForName: @"CDATA"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];
		comment = [[[element
		    elementForName: @"comment"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];

		attributesElement = [[[element
		    elementForName: @"attributes"
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:
		    OF_SERIALIZATION_NS] firstObject];
		namespacesElement = [[[element
		    elementForName: @"namespaces"
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:

		    OF_SERIALIZATION_NS] firstObject];
		childrenElement = [[[element

		    elementForName: @"children"
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:



		    OF_SERIALIZATION_NS] firstObject];

		attributes = [[attributesElement objectByDeserializing] copy];
		namespaces = [[namespacesElement objectByDeserializing] copy];
		children = [[childrenElement objectByDeserializing] copy];


		if (!((name != nil || ns != nil || defaultNamespace != nil ||
		    [attributes count] > 0 || [namespaces count] > 0 ||
		    [children count] > 0) ^ (characters != nil) ^
		    (CDATA != nil) ^ (comment != nil)))
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
- (OFString*)description
{
	return [self XMLStringWithIndentation: 2];
}

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

	element = [OFXMLElement elementWithName: @"object"
				      namespace: OF_SERIALIZATION_NS];

	pool = [[OFAutoreleasePool alloc] init];

	[element addAttributeWithName: @"class"
			  stringValue: [self className]];

	if (name != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"name"
					namespace: OF_SERIALIZATION_NS
				      stringValue: name]];

	if (ns != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"namespace"
					namespace: OF_SERIALIZATION_NS
				      stringValue: ns]];

	if (defaultNamespace != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"defaultNamespace"
					namespace: OF_SERIALIZATION_NS
				      stringValue: defaultNamespace]];

	if (attributes != nil) {
		OFXMLElement *attributesElement;

		attributesElement =
		    [OFXMLElement elementWithName: @"attributes"
					namespace: OF_SERIALIZATION_NS];







|


|


<
<
<
<
<

|
<
<
|


|
<
<
|


<
|
<
|







724
725
726
727
728
729
730
731
732
733
734
735
736





737
738


739
740
741
742


743
744
745

746

747
748
749
750
751
752
753
754
- (OFString*)description
{
	return [self XMLStringWithIndentation: 2];
}

- (OFXMLElement*)XMLElementBySerializing
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;

	element = [OFXMLElement elementWithName: [self className]
				      namespace: OF_SERIALIZATION_NS];






	if (name != nil)
		[element addAttributeWithName: @"name"


				  stringValue: name];

	if (ns != nil)
		[element addAttributeWithName: @"namespace"


				  stringValue: ns];

	if (defaultNamespace != nil)

		[element addAttributeWithName: @"defaultNamespace"

				  stringValue: defaultNamespace];

	if (attributes != nil) {
		OFXMLElement *attributesElement;

		attributesElement =
		    [OFXMLElement elementWithName: @"attributes"
					namespace: OF_SERIALIZATION_NS];
801
802
803
804
805
806
807
808
809
810
811

812

813
814
815
816
817
818
819


820



821
822
823
824
825
826
827

	if (characters != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"characters"
					namespace: OF_SERIALIZATION_NS
				      stringValue: characters]];

	if (CDATA != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"CDATA"
					namespace: OF_SERIALIZATION_NS

				      stringValue: CDATA]];


	if (comment != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"comment"
					namespace: OF_SERIALIZATION_NS
				      stringValue: comment]];



	[pool release];




	return element;
}

- (void)addAttribute: (OFXMLAttribute*)attribute
{
	if (name == nil)







|
|

|
>
|
>







>
>
|
>
>
>







780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813

	if (characters != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"characters"
					namespace: OF_SERIALIZATION_NS
				      stringValue: characters]];

	if (CDATA != nil) {
		OFXMLElement *CDATAElement =
		    [OFXMLElement elementWithName: @"CDATA"
					namespace: OF_SERIALIZATION_NS];
		[CDATAElement addChild: [OFXMLElement elementWithCDATA: CDATA]];
		[element addChild: CDATAElement];
	}

	if (comment != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"comment"
					namespace: OF_SERIALIZATION_NS
				      stringValue: comment]];

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

	return element;
}

- (void)addAttribute: (OFXMLAttribute*)attribute
{
	if (name == nil)

Modified tests/OFSerializationTests.m from [527ae62e46] to [eec9b3e1a8].

50
51
52
53
54
55
56

57
58
59
60
61
62
63
64
	      forKey: a];
	[d setObject: @"B\"la"
	      forKey: @"Blub"];

	[l appendObject: @"Hello"];
	[l appendObject: @"Wo\rld!\nHow are you?"];
	[l appendObject: [OFURL URLWithString: @"https://webkeks.org/"]];

	[l appendObject: [OFXMLElement elementWithXMLString: @"<x><y/></x>"]];

	[d setObject: @"list"
	      forKey: l];

	TEST(@"-[stringBySerializing]",
	    (s = [d stringBySerializing]) && [s isEqual:
	    [OFString stringWithContentsOfFile: @"serialization.xml"]])







>
|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
	      forKey: a];
	[d setObject: @"B\"la"
	      forKey: @"Blub"];

	[l appendObject: @"Hello"];
	[l appendObject: @"Wo\rld!\nHow are you?"];
	[l appendObject: [OFURL URLWithString: @"https://webkeks.org/"]];
	[l appendObject:
	    [OFXMLElement elementWithXMLString: @"<x><y/><![CDATA[<]]></x>"]];

	[d setObject: @"list"
	      forKey: l];

	TEST(@"-[stringBySerializing]",
	    (s = [d stringBySerializing]) && [s isEqual:
	    [OFString stringWithContentsOfFile: @"serialization.xml"]])

Modified tests/serialization.xml from [df9f9a2c48] to [7e037e6365].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
<?xml version='1.0' encoding='UTF-8'?>
<serialization xmlns='https://webkeks.org/objfw/serialization'>
  <object class='OFMutableDictionary'>
    <pair>
      <key>
        <object class='OFArray'>
          <object class='OFString'>Qu&quot;xbar
test</object>
          <object class='OFNumber' type='signed'>1234</object>
          <object class='OFMutableString'>asd</object>
          <object class='OFDate'>
            <seconds>1234</seconds>
            <microseconds>5678</microseconds>
          </object>
        </object>
      </key>
      <value>
        <object class='OFString'>Hello</object>
      </value>
    </pair>
    <pair>
      <key>
        <object class='OFString'>Blub</object>
      </key>
      <value>
        <object class='OFString'>B&quot;la</object>
      </value>
    </pair>
    <pair>
      <key>
        <object class='OFList'>
          <object class='OFString'>Hello</object>
          <object class='OFString'>Wo&#xD;ld!
How are you?</object>
          <object class='OFURL'>https://webkeks.org/</object>
          <object class='OFXMLElement'>
            <name>x</name>
            <namespaces>
              <object class='OFMutableDictionary'>
                <pair>
                  <key>
                    <object class='OFString'>http://www.w3.org/2000/xmlns/</object>
                  </key>
                  <value>
                    <object class='OFString'>xmlns</object>

                  </value>


                </pair>
                <pair>
                  <key>
                    <object class='OFString'>http://www.w3.org/XML/1998/namespace</object>
                  </key>
                  <value>
                    <object class='OFString'>xml</object>
                  </value>
                </pair>
              </object>

            </namespaces>
            <children>
              <object class='OFMutableArray'>
                <object class='OFXMLElement'>
                  <name>y</name>
                  <namespaces>
                    <object class='OFMutableDictionary'>
                      <pair>
                        <key>
                          <object class='OFString'>http://www.w3.org/2000/xmlns/</object>
                        </key>



                        <value>


                          <object class='OFString'>xmlns</object>

                        </value>
                      </pair>
                      <pair>
                        <key>
                          <object class='OFString'>http://www.w3.org/XML/1998/namespace</object>
                        </key>
                        <value>
                          <object class='OFString'>xml</object>
                        </value>
                      </pair>
                    </object>

                  </namespaces>
                </object>


              </object>

            </children>



          </object>

        </object>


      </key>
      <value>
        <object class='OFString'>list</object>
      </value>
    </pair>
  </object>

</serialization>

|
|
<
|
|
|
|
|
|
<
<
|
<
<
|
<
<
<
<
<
<
<
|
<
|
|
|
<
|
|
|
|
|
|
|
<
|
|
<
|
|
|
<
|
>
|
>
>
<
<
<
<
|
<
|
<
|

>
|
|
|
|
<
|
|
<
|
|
|
>
>
>
|
>
>
|
>
<
<
<
<
<
<
<
<
<
<

>
|
|
>
>
|
>
|
>
>
>
|
>
|
>
>
|
<
|
<
|
|
>

1
2
3

4
5
6
7
8
9


10


11







12

13
14
15

16
17
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
<?xml version='1.0' encoding='UTF-8'?>
<serialization xmlns='https://webkeks.org/objfw/serialization' version='0'>
  <OFMutableDictionary>

    <key>
      <OFArray>
        <OFString>Qu&quot;xbar
test</OFString>
        <OFNumber type='signed'>1234</OFNumber>
        <OFMutableString>asd</OFMutableString>


        <OFDate seconds='1234' microseconds='5678'/>


      </OFArray>







    </key>

    <object>
      <OFString>Hello</OFString>
    </object>

    <key>
      <OFList>
        <OFString>Hello</OFString>
        <OFString>Wo&#xD;ld!
How are you?</OFString>
        <OFURL>https://webkeks.org/</OFURL>
        <OFXMLElement name='x'>

          <namespaces>
            <OFMutableDictionary>

              <key>
                <OFString>http://www.w3.org/2000/xmlns/</OFString>
              </key>

              <object>
                <OFString>xmlns</OFString>
              </object>
              <key>
                <OFString>http://www.w3.org/XML/1998/namespace</OFString>




              </key>

              <object>

                <OFString>xml</OFString>
              </object>
            </OFMutableDictionary>
          </namespaces>
          <children>
            <OFMutableArray>
              <OFXMLElement name='y'>

                <namespaces>
                  <OFMutableDictionary>

                    <key>
                      <OFString>http://www.w3.org/2000/xmlns/</OFString>
                    </key>
                    <object>
                      <OFString>xmlns</OFString>
                    </object>
                    <key>
                      <OFString>http://www.w3.org/XML/1998/namespace</OFString>
                    </key>
                    <object>
                      <OFString>xml</OFString>










                    </object>
                  </OFMutableDictionary>
                </namespaces>
              </OFXMLElement>
              <OFXMLElement>
                <CDATA><![CDATA[<]]></CDATA>
              </OFXMLElement>
            </OFMutableArray>
          </children>
        </OFXMLElement>
      </OFList>
    </key>
    <object>
      <OFString>list</OFString>
    </object>
    <key>
      <OFString>Blub</OFString>
    </key>

    <object>

      <OFString>B&quot;la</OFString>
    </object>
  </OFMutableDictionary>
</serialization>