ObjFW  Diff

Differences From Artifact [de3d68907d]:

To Artifact [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)