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
|
#import "OFList.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFEnumerationMutationException.h"
#import "macros.h"
@implementation OFList
+ list
{
return [[[self alloc] init] autorelease];
}
- init
{
self = [super init];
firstListObject = NULL;
lastListObject = NULL;
return self;
}
- (void)dealloc
{
of_list_object_t *iter;
|
>
|
|
>
>
>
>
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
#import "OFList.h"
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
#import "macros.h"
@implementation OFList
+ list
{
return [[[self alloc] init] autorelease];
}
- 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: [isa 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 = [OFSerialization
objectByDeserializingXMLElement: child];
[self appendObject: object];
[pool2 releaseObjects];
}
[pool release];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)dealloc
{
of_list_object_t *iter;
|
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
|
[listObject->object release];
[self freeMemory: listObject];
}
- (id)firstObject
{
if (firstListObject != NULL)
return firstListObject->object;
return nil;
}
- (id)lastObject
{
if (lastListObject != NULL)
return lastListObject->object;
return nil;
}
- (size_t)count
{
return count;
}
|
|
<
<
<
|
<
<
<
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
[listObject->object release];
[self freeMemory: listObject];
}
- (id)firstObject
{
return (firstListObject != NULL ? firstListObject->object : nil);
}
- (id)lastObject
{
return (lastListObject != NULL ? lastListObject->object : nil);
}
- (size_t)count
{
return count;
}
|