-
Notifications
You must be signed in to change notification settings - Fork 0
/
TLGPXNode.m
75 lines (65 loc) · 1.61 KB
/
TLGPXNode.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
//
// TLGPXNode.m
// Mercatalog
//
// Created by Nathan Vander Wilt on 3/17/08.
// Copyright 2008 Calf Trail Software, LLC. All rights reserved.
//
#import "TLGPXNode.h"
@implementation TLGPXNode
- (id)initWithParent:(TLGPXNode*)theParent
forElement:(NSString*)elementName
namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
attributes:(NSDictionary*)attributes
{
(void)namespaceURI;
(void)qualifiedName;
(void)attributes;
self = [super init];
if (self) {
parent = theParent;
hostElement = [elementName retain];
}
return self;
}
- (void)parser:(NSXMLParser*)parser didEndElement:(NSString*)elementName
namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
{
(void)namespaceURI;
(void)qualifiedName;
if ([elementName isEqualToString:hostElement]) {
[hostElement release];
hostElement = nil;
[currentCharacters release];
currentCharacters = nil;
[parser setDelegate:parent];
}
}
- (void)setGatheringCharacters:(BOOL)gather {
gatheringCharacters = gather;
if (!gather) {
[currentCharacters release];
currentCharacters = nil;
}
}
- (BOOL)isGatheringCharacters {
return gatheringCharacters;
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
(void)parser;
if (!gatheringCharacters) return;
if (currentCharacters) {
NSString* oldString = currentCharacters;
currentCharacters = [[currentCharacters stringByAppendingString:string] retain];
[oldString release];
}
else {
currentCharacters = [[NSString stringWithString:string] retain];
}
}
- (NSString*)gatheredCharacters {
return currentCharacters;
}
@end