ObjFW  Diff

Differences From Artifact [9f7e711096]:

To Artifact [3e96efbf3c]:


16
17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33

#include "config.h"

#import "OFXMLAttribute.h"
#import "OFString.h"
#import "OFDictionary.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"

#import "OFInvalidArgumentException.h"


#import "macros.h"

@implementation OFXMLAttribute
+ attributeWithName: (OFString*)name
	  namespace: (OFString*)ns
	stringValue: (OFString*)value
{







<



>







16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33

#include "config.h"

#import "OFXMLAttribute.h"
#import "OFString.h"
#import "OFDictionary.h"
#import "OFXMLElement.h"


#import "OFInvalidArgumentException.h"

#import "autorelease.h"
#import "macros.h"

@implementation OFXMLAttribute
+ attributeWithName: (OFString*)name
	  namespace: (OFString*)ns
	stringValue: (OFString*)value
{
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
}

- 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
			    exceptionWithClass: [self class]
				      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;
	}

	return self;
}







|














|







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
}

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

	@try {
		void *pool = objc_autoreleasePoolPush();

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

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

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

	return self;
}
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	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];
	[pool release];
	[element autorelease];

	return element;
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"<OFXMLAttribute, name=%@, "
					   @"namespace=%@, stringValue=%@>",
					   name, ns, stringValue];
}
@end







|
















|
|

|









139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFXMLElement*)XMLElementBySerializing
{
	void *pool = objc_autoreleasePoolPush();
	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];

	objc_autoreleasePoolPop(pool);

	return [element autorelease];
}

- (OFString*)description
{
	return [OFString stringWithFormat: @"<OFXMLAttribute, name=%@, "
					   @"namespace=%@, stringValue=%@>",
					   name, ns, stringValue];
}
@end