UNICORN - iOS
SBJsonStreamParser.h
1 /*
2  Copyright (c) 2010, Stig Brautaset.
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16  Neither the name of the the author nor the names of its contributors
17  may be used to endorse or promote products derived from this software
18  without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #import <Foundation/Foundation.h>
34 
35 @class SBJsonTokeniser;
36 @class SBJsonStreamParser;
38 
39 typedef enum {
40  SBJsonStreamParserComplete,
41  SBJsonStreamParserWaitingForData,
42  SBJsonStreamParserError,
43 } SBJsonStreamParserStatus;
44 
45 
53 
55 - (void)parserFoundObjectStart:(SBJsonStreamParser*)parser;
56 
58 - (void)parser:(SBJsonStreamParser*)parser foundObjectKey:(NSString*)key;
59 
61 - (void)parserFoundObjectEnd:(SBJsonStreamParser*)parser;
62 
64 - (void)parserFoundArrayStart:(SBJsonStreamParser*)parser;
65 
67 - (void)parserFoundArrayEnd:(SBJsonStreamParser*)parser;
68 
70 - (void)parser:(SBJsonStreamParser*)parser foundBoolean:(BOOL)x;
71 
73 - (void)parserFoundNull:(SBJsonStreamParser*)parser;
74 
76 - (void)parser:(SBJsonStreamParser*)parser foundNumber:(NSNumber*)num;
77 
79 - (void)parser:(SBJsonStreamParser*)parser foundString:(NSString*)string;
80 
81 @end
82 
83 
100 @interface SBJsonStreamParser : NSObject {
101 @private
102  SBJsonTokeniser *tokeniser;
103 }
104 
105 @property (nonatomic, unsafe_unretained) SBJsonStreamParserState *state; // Private
106 @property (nonatomic, readonly, strong) NSMutableArray *stateStack; // Private
107 
121 
132 @property (unsafe_unretained) id<SBJsonStreamParserDelegate> delegate;
133 
141 @property NSUInteger maxDepth;
142 
144 @property (copy) NSString *error;
145 
159 - (SBJsonStreamParserStatus)parse:(NSData*)data;
160 
161 @end
BOOL supportMultipleDocuments
Expect multiple documents separated by whitespace.
Definition: SBJsonStreamParser.h:120
Parse a stream of JSON data.
Definition: SBJsonStreamParser.h:100
Definition: SBJsonTokeniser.h:58
Definition: SBJsonStreamParserState.h:38
NSUInteger maxDepth
The max parse depth.
Definition: SBJsonStreamParser.h:141
Delegate for interacting directly with the stream parser.
Definition: SBJsonStreamParser.h:52