ObjFW  Diff

Differences From Artifact [de3d68907d]:

To Artifact [4687f4ccbd]:


25
26
27
28
29
30
31

32
33
34
35
36
37
38
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
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: @"object"] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS] ||
		if (![[element name] isEqual: [self className]] ||
		    ![[element namespace] isEqual: OF_SERIALIZATION_NS])
		    ![[[element attributeForName: @"class"] stringValue]
		    isEqual: [self className]])
			@throw [OFInvalidArgumentException newWithClass: isa
							       selector: _cmd];

		name = [[[element
		name = [[[element attributeForName: @"name"] stringValue] copy];
		    elementForName: @"name"
			 namespace: OF_SERIALIZATION_NS] stringValue] copy];
		ns = [[[element
		ns = [[[element attributeForName: @"namespace"] stringValue]
		    elementForName: @"namespace"
			namespace: OF_SERIALIZATION_NS] stringValue] copy];
		defaultNamespace = [[[element
		    elementForName: @"defaultNamespace"
		    copy];
		defaultNamespace = [[[element attributeForName:
		    @"defaultNamespace"] stringValue] copy];
			 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
		attributesElement = [[[element
		    elementForName: @"attributes"
			 namespace: OF_SERIALIZATION_NS];
		namespacesElement = [element
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:
		    OF_SERIALIZATION_NS] firstObject];
		namespacesElement = [[[element
		    elementForName: @"namespaces"
			 namespace: OF_SERIALIZATION_NS];
			 namespace: OF_SERIALIZATION_NS] elementsForNamespace:
		childrenElement = [element elementForName: @"children"
						namespace: OF_SERIALIZATION_NS];

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

		attributes = [[attributesElement objectByDeserializing] copy];
		namespaces = [[namespacesElement objectByDeserializing] copy];
		children = [[childrenElement objectByDeserializing] copy];
		    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];
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
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 *pool = [[OFAutoreleasePool alloc] init];
	OFXMLElement *element;

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

	pool = [[OFAutoreleasePool alloc] init];

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

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

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

	if (defaultNamespace != nil)
		[element addChild:
		    [OFXMLElement elementWithName: @"defaultNamespace"
		[element addAttributeWithName: @"defaultNamespace"
					namespace: OF_SERIALIZATION_NS
				      stringValue: 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
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)
		[element addChild:
	if (CDATA != nil) {
		OFXMLElement *CDATAElement =
		    [OFXMLElement elementWithName: @"CDATA"
					namespace: OF_SERIALIZATION_NS
				      stringValue: 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];
		[pool release];
	} @finally {
		[element autorelease];
	}

	return element;
}

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