-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTLGPXTracklog.m
79 lines (68 loc) · 2.12 KB
/
TLGPXTracklog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
//
// TLGPXTracklog.m
// Mercatalog
//
// Created by Nathan Vander Wilt on 3/17/08.
// Copyright 2008 Calf Trail Software, LLC. All rights reserved.
//
#import "TLGPXTracklog.h"
@implementation TLGPXTracklog
#pragma mark Initialization from XML
- (id)initWithParent:(TLGPXNode*)theParent
forElement:(NSString*)elementName
namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
attributes:(NSDictionary*)attributes
{
self = [super initWithParent:theParent
forElement:elementName
namespaceURI:namespaceURI
qualifiedName:qualifiedName
attributes:attributes];
if (self) {
segments = [[NSMutableArray array] retain];
}
return self;
}
- (void)dealloc {
[name release];
[segments release];
[super dealloc];
}
- (void)parser:(NSXMLParser*)parser didStartElement:(NSString*)elementName
namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
attributes:(NSDictionary*)attributeDict
{
(void)namespaceURI;
(void)qualifiedName;
if ([elementName isEqualToString:@"trkseg"]) {
TLGPXTrackSegment* newSegment = [[TLGPXTrackSegment alloc] initWithParent:self
forElement:elementName
namespaceURI:namespaceURI
qualifiedName:qualifiedName
attributes:attributeDict];
[parser setDelegate:newSegment];
[segments addObject:[newSegment autorelease]];
}
else if ([elementName isEqualToString:@"name"]) {
[self setGatheringCharacters:YES];
}
}
- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName
namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
{
if ([elementName isEqualToString:@"name"]) {
name = [[NSString stringWithString:[self gatheredCharacters]] retain];
[self setGatheringCharacters:NO];
}
else {
[super parser:parser didEndElement:elementName namespaceURI:namespaceURI qualifiedName:qualifiedName];
}
}
#pragma mark Accessors
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len {
return [segments countByEnumeratingWithState:state objects:stackbuf count:len];
}
@end