ObjFW  Check-in [05c094a39f]

Overview
Comment:Add -[isEqual:] to OFXMLElement and OFXMLAttribute.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 0.5
Files: files | file ages | folders
SHA3-256: 05c094a39f5bc3d934da1e134cbcbe82df1f1a584b758374cbc3f2f8693be28b
User & Date: js on 2011-06-30 18:27:34
Other Links: branch diff | manifest | tags
Context
2011-06-30
18:33
Add -[hash] to OFXMLElement and OFXMLAttribute. check-in: 0ae2dee38f user: js tags: 0.5
18:27
Add -[isEqual:] to OFXMLElement and OFXMLAttribute. check-in: 05c094a39f user: js tags: 0.5
2011-06-29
21:16
objfw-compile: Pass -f flags to the compiler. check-in: fd3625cbba user: js tags: 0.5
Changes

Modified src/OFXMLAttribute.m from [1771d20c62] to [ea5e3160de].

67
68
69
70
71
72
73



















74
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

	return [[ns copy] autorelease];
}

- (OFString*)stringValue
{
	return [[stringValue copy] autorelease];
}

- (BOOL)isEqual: (id)object
{
	OFXMLAttribute *other;

	if (![object isKindOfClass: [OFXMLAttribute class]])
		return NO;

	other = object;

	if (![other->name isEqual: name])
		return NO;
	if (other->ns != ns && ![other->ns isEqual: ns])
		return NO;
	if (![other->stringValue isEqual: stringValue])
		return NO;

	return YES;
}
@end

Modified src/OFXMLElement.m from [2e27de79cd] to [b89fa67593].

754
755
756
757
758
759
760



































761
762
763
764
765
766
767
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







			if (children_c[i]->ns == nil &&
			    [children_c[i]->name isEqual: elemname])
				[ret addObject: children_c[i]];
	}

	return ret;
}

- (BOOL)isEqual: (id)object
{
	OFXMLElement *other;

	if (![object isKindOfClass: [OFXMLElement class]])
		return NO;

	other = object;

	if (other->name != name && ![other->name isEqual: name])
		return NO;
	if (other->ns != ns && ![other->ns isEqual: ns])
		return NO;
	if (other->defaultNamespace != defaultNamespace &&
	    ![other->defaultNamespace isEqual: defaultNamespace])
		return NO;
	if (other->attributes != attributes &&
	    ![other->attributes isEqual: attributes])
		return NO;
	if (other->namespaces != namespaces &&
	    ![other->namespaces isEqual: namespaces])
		return NO;
	if (other->children != children && ![other->children isEqual: children])
		return NO;
	if (other->characters != characters &&
	    ![other->characters isEqual: characters])
		return NO;
	if (other->cdata != cdata && ![other->cdata isEqual: cdata])
		return NO;
	if (other->comment != comment && ![other->comment isEqual: comment])
		return NO;

	return YES;
}

- (void)dealloc
{
	[name release];
	[ns release];
	[defaultNamespace release];
	[attributes release];

Modified tests/OFXMLElementTests.m from [fe66efda43] to [9cc1013df2].

125
126
127
128
129
130
131






132
133
134
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140







+
+
+
+
+
+




	TEST(@"-[elementsForName:namespace:]",
	    (a = [elem[2] elementsForName: @"bar"
				namespace: @"urn:objfw:test"]) &&
	    [a count] == 1 && [[[a firstObject] XMLString] isEqual:
	    @"<bar xmlns='urn:objfw:test'/>"])

	TEST(@"-[isEqual:]",
	    [[OFXMLElement elementWithXMLString: @"<foo bar='asd'/>"] isEqual:
	    [OFXMLElement elementWithXMLString: @"<foo bar='asd'></foo>"]] &&
	    [[OFXMLElement elementWithXMLString: @"<x><y/></x>"] isEqual:
	    [OFXMLElement elementWithXMLString: @"<x><y></y></x>"]])

	[pool drain];
}
@end