forked from mattgemmell/MGTwitterEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MGTwitterMessagesYAJLParser.m
116 lines (101 loc) · 2.07 KB
/
MGTwitterMessagesYAJLParser.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//
// MGTwitterMessagesYAJLParser.m
// MGTwitterEngine
//
// Created by Matt Gemmell on 11/02/2008.
// Copyright 2008 Instinctive Code.
//
#import "MGTwitterMessagesYAJLParser.h"
#define DEBUG_PARSING 0
@implementation MGTwitterMessagesYAJLParser
- (void)addValue:(id)value forKey:(NSString *)key
{
if (_sender)
{
[_sender setObject:value forKey:key];
#if DEBUG_PARSING
NSLog(@"messages: sender: %@ = %@ (%@)", key, value, NSStringFromClass([value class]));
#endif
}
else if (_recipient)
{
[_recipient setObject:value forKey:key];
#if DEBUG_PARSING
NSLog(@"messages: recipient: %@ = %@ (%@)", key, value, NSStringFromClass([value class]));
#endif
}
else if (_status)
{
[_status setObject:value forKey:key];
#if DEBUG_PARSING
NSLog(@"messages: status: %@ = %@ (%@)", key, value, NSStringFromClass([value class]));
#endif
}
}
- (void)startDictionaryWithKey:(NSString *)key
{
#if DEBUG_PARSING
NSLog(@"messages: dictionary start = %@", key);
#endif
if (! _status)
{
_status = [[NSMutableDictionary alloc] initWithCapacity:0];
}
else
{
if ([key isEqualToString:@"sender"])
{
_sender = [[NSMutableDictionary alloc] initWithCapacity:0];
}
else
{
_recipient = [[NSMutableDictionary alloc] initWithCapacity:0];
}
}
}
- (void)endDictionary
{
if (_sender)
{
[_status setObject:_sender forKey:@"sender"];
[_sender release];
_sender = nil;
}
else if (_recipient)
{
[_status setObject:_recipient forKey:@"recipient"];
[_recipient release];
_recipient = nil;
}
else
{
[_status setObject:[NSNumber numberWithInt:requestType] forKey:TWITTER_SOURCE_REQUEST_TYPE];
[self _parsedObject:_status];
[parsedObjects addObject:_status];
[_status release];
_status = nil;
}
#if DEBUG_PARSING
NSLog(@"messages: dictionary end");
#endif
}
- (void)startArrayWithKey:(NSString *)key
{
#if DEBUG_PARSING
NSLog(@"messages: array start = %@", key);
#endif
}
- (void)endArray
{
#if DEBUG_PARSING
NSLog(@"messages: array end");
#endif
}
- (void)dealloc
{
[_status release];
[_sender release];
[_recipient release];
[super dealloc];
}
@end