You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2016/10/24 13:06:29 UTC
[44/83] [abbrv] usergrid git commit: Moving older SDKs to a
difference location and updating main README to link to new SDK locations.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamParser.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamParser.m b/sdks/ios/UGAPI/SBJson/SBJsonStreamParser.m
deleted file mode 100755
index 134e34a..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamParser.m
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamParser.h"
-#import "SBJsonTokeniser.h"
-#import "SBJsonStreamParserState.h"
-#import <limits.h>
-
-@implementation SBJsonStreamParser
-
-@synthesize supportMultipleDocuments;
-@synthesize error;
-@synthesize delegate;
-@synthesize maxDepth;
-@synthesize state;
-@synthesize stateStack;
-
-#pragma mark Housekeeping
-
-- (id)init {
- self = [super init];
- if (self) {
- maxDepth = 32u;
- stateStack = [[NSMutableArray alloc] initWithCapacity:maxDepth];
- state = [SBJsonStreamParserStateStart sharedInstance];
- tokeniser = [[SBJsonTokeniser alloc] init];
- }
- return self;
-}
-
-- (void)dealloc {
- self.state = nil;
-}
-
-#pragma mark Methods
-
-- (NSString*)tokenName:(sbjson_token_t)token {
- switch (token) {
- case sbjson_token_array_start:
- return @"start of array";
- break;
-
- case sbjson_token_array_end:
- return @"end of array";
- break;
-
- case sbjson_token_number:
- return @"number";
- break;
-
- case sbjson_token_string:
- return @"string";
- break;
-
- case sbjson_token_true:
- case sbjson_token_false:
- return @"boolean";
- break;
-
- case sbjson_token_null:
- return @"null";
- break;
-
- case sbjson_token_keyval_separator:
- return @"key-value separator";
- break;
-
- case sbjson_token_separator:
- return @"value separator";
- break;
-
- case sbjson_token_object_start:
- return @"start of object";
- break;
-
- case sbjson_token_object_end:
- return @"end of object";
- break;
-
- case sbjson_token_eof:
- case sbjson_token_error:
- break;
- }
- NSAssert(NO, @"Should not get here");
- return @"<aaiiie!>";
-}
-
-- (void)maxDepthError {
- self.error = [NSString stringWithFormat:@"Input depth exceeds max depth of %lu", maxDepth];
- self.state = [SBJsonStreamParserStateError sharedInstance];
-}
-
-- (void)handleObjectStart {
- if (stateStack.count >= maxDepth) {
- [self maxDepthError];
- return;
- }
-
- [delegate parserFoundObjectStart:self];
- [stateStack addObject:state];
- self.state = [SBJsonStreamParserStateObjectStart sharedInstance];
-}
-
-- (void)handleObjectEnd: (sbjson_token_t) tok {
- self.state = [stateStack lastObject];
- [stateStack removeLastObject];
- [state parser:self shouldTransitionTo:tok];
- [delegate parserFoundObjectEnd:self];
-}
-
-- (void)handleArrayStart {
- if (stateStack.count >= maxDepth) {
- [self maxDepthError];
- return;
- }
-
- [delegate parserFoundArrayStart:self];
- [stateStack addObject:state];
- self.state = [SBJsonStreamParserStateArrayStart sharedInstance];
-}
-
-- (void)handleArrayEnd: (sbjson_token_t) tok {
- self.state = [stateStack lastObject];
- [stateStack removeLastObject];
- [state parser:self shouldTransitionTo:tok];
- [delegate parserFoundArrayEnd:self];
-}
-
-- (void) handleTokenNotExpectedHere: (sbjson_token_t) tok {
- NSString *tokenName = [self tokenName:tok];
- NSString *stateName = [state name];
-
- self.error = [NSString stringWithFormat:@"Token '%@' not expected %@", tokenName, stateName];
- self.state = [SBJsonStreamParserStateError sharedInstance];
-}
-
-- (SBJsonStreamParserStatus)parse:(NSData *)data_ {
- @autoreleasepool {
- [tokeniser appendData:data_];
-
- for (;;) {
-
- if ([state isError])
- return SBJsonStreamParserError;
-
- NSObject *token;
- sbjson_token_t tok = [tokeniser getToken:&token];
- switch (tok) {
- case sbjson_token_eof:
- return [state parserShouldReturn:self];
- break;
-
- case sbjson_token_error:
- self.state = [SBJsonStreamParserStateError sharedInstance];
- self.error = tokeniser.error;
- return SBJsonStreamParserError;
- break;
-
- default:
-
- if (![state parser:self shouldAcceptToken:tok]) {
- [self handleTokenNotExpectedHere: tok];
- return SBJsonStreamParserError;
- }
-
- switch (tok) {
- case sbjson_token_object_start:
- [self handleObjectStart];
- break;
-
- case sbjson_token_object_end:
- [self handleObjectEnd: tok];
- break;
-
- case sbjson_token_array_start:
- [self handleArrayStart];
- break;
-
- case sbjson_token_array_end:
- [self handleArrayEnd: tok];
- break;
-
- case sbjson_token_separator:
- case sbjson_token_keyval_separator:
- [state parser:self shouldTransitionTo:tok];
- break;
-
- case sbjson_token_true:
- [delegate parser:self foundBoolean:YES];
- [state parser:self shouldTransitionTo:tok];
- break;
-
- case sbjson_token_false:
- [delegate parser:self foundBoolean:NO];
- [state parser:self shouldTransitionTo:tok];
- break;
-
- case sbjson_token_null:
- [delegate parserFoundNull:self];
- [state parser:self shouldTransitionTo:tok];
- break;
-
- case sbjson_token_number:
- [delegate parser:self foundNumber:(NSNumber*)token];
- [state parser:self shouldTransitionTo:tok];
- break;
-
- case sbjson_token_string:
- if ([state needKey])
- [delegate parser:self foundObjectKey:(NSString*)token];
- else
- [delegate parser:self foundString:(NSString*)token];
- [state parser:self shouldTransitionTo:tok];
- break;
-
- default:
- break;
- }
- break;
- }
- }
- return SBJsonStreamParserComplete;
- }
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.h b/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.h
deleted file mode 100755
index 141d6ee..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- Copyright (C) 2011 Stig Brautaset. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of the author nor the names of its contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-#import "SBJsonStreamParserAdapter.h"
-
-@interface SBJsonStreamParserAccumulator : NSObject <SBJsonStreamParserAdapterDelegate>
-
-@property (copy) id value;
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.m b/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.m
deleted file mode 100755
index 1d39ceb..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAccumulator.m
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (C) 2011 Stig Brautaset. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of the author nor the names of its contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamParserAccumulator.h"
-
-@implementation SBJsonStreamParserAccumulator
-
-@synthesize value;
-
-
-#pragma mark SBJsonStreamParserAdapterDelegate
-
-- (void)parser:(SBJsonStreamParser*)parser foundArray:(NSArray *)array {
- value = array;
-}
-
-- (void)parser:(SBJsonStreamParser*)parser foundObject:(NSDictionary *)dict {
- value = dict;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.h b/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.h
deleted file mode 100755
index 942bc01..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-#import "SBJsonStreamParser.h"
-
-typedef enum {
- SBJsonStreamParserAdapterNone,
- SBJsonStreamParserAdapterArray,
- SBJsonStreamParserAdapterObject,
-} SBJsonStreamParserAdapterType;
-
-/**
- @brief Delegate for getting objects & arrays from the stream parser adapter
-
- @see The TweetStream example project.
- */
-@protocol SBJsonStreamParserAdapterDelegate
-
-/**
- @brief Called if a JSON array is found
-
- This method is called if a JSON array is found.
-
- */
-- (void)parser:(SBJsonStreamParser*)parser foundArray:(NSArray*)array;
-
-/**
- @brief Called when a JSON object is found
-
- This method is called if a JSON object is found.
- */
-- (void)parser:(SBJsonStreamParser*)parser foundObject:(NSDictionary*)dict;
-
-@end
-
-/**
- @brief SBJsonStreamParserDelegate protocol adapter
-
- Rather than implementing the SBJsonStreamParserDelegate protocol yourself you will
- most likely find it much more convenient to use an instance of this class and
- implement the SBJsonStreamParserAdapterDelegate protocol instead.
-
- The default behaviour is that the delegate only receives one call from
- either the -parser:foundArray: or -parser:foundObject: method when the
- document is fully parsed. However, if your inputs contains multiple JSON
- documents and you set the parser's -supportMultipleDocuments property to YES
- you will get one call for each full method.
-
- @code
- SBJsonStreamParserAdapter *adapter = [[[SBJsonStreamParserAdapter alloc] init] autorelease];
- adapter.delegate = self;
-
- SBJsonStreamParser *parser = [[[SBJsonStreamParser alloc] init] autorelease];
- parser.delegate = adapter;
- parser.supportMultipleDocuments = YES;
-
- // Note that this input contains multiple top-level JSON documents
- NSData *json = [@"[]{}[]{}" dataWithEncoding:NSUTF8StringEncoding];
- [parser parse:data];
- @endcode
-
- In the above example @p self will have the following sequence of methods called on it:
-
- @li -parser:foundArray:
- @li -parser:foundObject:
- @li -parser:foundArray:
- @li -parser:foundObject:
-
- Often you won't have control over the input you're parsing, so can't make use of
- this feature. But, all is not lost: this class will let you get the same effect by
- allowing you to skip one or more of the outer enclosing objects. Thus, the next
- example results in the same sequence of -parser:foundArray: / -parser:foundObject:
- being called on your delegate.
-
- @code
- SBJsonStreamParserAdapter *adapter = [[[SBJsonStreamParserAdapter alloc] init] autorelease];
- adapter.delegate = self;
- adapter.levelsToSkip = 1;
-
- SBJsonStreamParser *parser = [[[SBJsonStreamParser alloc] init] autorelease];
- parser.delegate = adapter;
-
- // Note that this input contains A SINGLE top-level document
- NSData *json = [@"[[],{},[],{}]" dataWithEncoding:NSUTF8StringEncoding];
- [parser parse:data];
- @endcode
-
-*/
-@interface SBJsonStreamParserAdapter : NSObject <SBJsonStreamParserDelegate> {
-@private
- NSUInteger depth;
- NSMutableArray *array;
- NSMutableDictionary *dict;
- NSMutableArray *keyStack;
- NSMutableArray *stack;
-
- SBJsonStreamParserAdapterType currentType;
-}
-
-/**
- @brief How many levels to skip
-
- This is useful for parsing huge JSON documents, or documents coming in over a very slow link.
-
- If you set this to N it will skip the outer N levels and call the -parser:foundArray:
- or -parser:foundObject: methods for each of the inner objects, as appropriate.
-
- @see The StreamParserIntegrationTest.m file for examples
-*/
-@property NSUInteger levelsToSkip;
-
-/**
- @brief Your delegate object
- Set this to the object you want to receive the SBJsonStreamParserAdapterDelegate messages.
- */
-@property (unsafe_unretained) id<SBJsonStreamParserAdapterDelegate> delegate;
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.m b/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.m
deleted file mode 100755
index e77b534..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserAdapter.m
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamParserAdapter.h"
-
-@interface SBJsonStreamParserAdapter ()
-
-- (void)pop;
-- (void)parser:(SBJsonStreamParser*)parser found:(id)obj;
-
-@end
-
-
-
-@implementation SBJsonStreamParserAdapter
-
-@synthesize delegate;
-@synthesize levelsToSkip;
-
-#pragma mark Housekeeping
-
-- (id)init {
- self = [super init];
- if (self) {
- keyStack = [[NSMutableArray alloc] initWithCapacity:32];
- stack = [[NSMutableArray alloc] initWithCapacity:32];
-
- currentType = SBJsonStreamParserAdapterNone;
- }
- return self;
-}
-
-
-#pragma mark Private methods
-
-- (void)pop {
- [stack removeLastObject];
- array = nil;
- dict = nil;
- currentType = SBJsonStreamParserAdapterNone;
-
- id value = [stack lastObject];
-
- if ([value isKindOfClass:[NSArray class]]) {
- array = value;
- currentType = SBJsonStreamParserAdapterArray;
- } else if ([value isKindOfClass:[NSDictionary class]]) {
- dict = value;
- currentType = SBJsonStreamParserAdapterObject;
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser found:(id)obj {
- NSParameterAssert(obj);
-
- switch (currentType) {
- case SBJsonStreamParserAdapterArray:
- [array addObject:obj];
- break;
-
- case SBJsonStreamParserAdapterObject:
- NSParameterAssert(keyStack.count);
- [dict setObject:obj forKey:[keyStack lastObject]];
- [keyStack removeLastObject];
- break;
-
- case SBJsonStreamParserAdapterNone:
- if ([obj isKindOfClass:[NSArray class]]) {
- [delegate parser:parser foundArray:obj];
- } else {
- [delegate parser:parser foundObject:obj];
- }
- break;
-
- default:
- break;
- }
-}
-
-
-#pragma mark Delegate methods
-
-- (void)parserFoundObjectStart:(SBJsonStreamParser*)parser {
- if (++depth > self.levelsToSkip) {
- dict = [NSMutableDictionary new];
- [stack addObject:dict];
- currentType = SBJsonStreamParserAdapterObject;
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser foundObjectKey:(NSString*)key_ {
- [keyStack addObject:key_];
-}
-
-- (void)parserFoundObjectEnd:(SBJsonStreamParser*)parser {
- if (depth-- > self.levelsToSkip) {
- id value = dict;
- [self pop];
- [self parser:parser found:value];
- }
-}
-
-- (void)parserFoundArrayStart:(SBJsonStreamParser*)parser {
- if (++depth > self.levelsToSkip) {
- array = [NSMutableArray new];
- [stack addObject:array];
- currentType = SBJsonStreamParserAdapterArray;
- }
-}
-
-- (void)parserFoundArrayEnd:(SBJsonStreamParser*)parser {
- if (depth-- > self.levelsToSkip) {
- id value = array;
- [self pop];
- [self parser:parser found:value];
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser foundBoolean:(BOOL)x {
- [self parser:parser found:[NSNumber numberWithBool:x]];
-}
-
-- (void)parserFoundNull:(SBJsonStreamParser*)parser {
- [self parser:parser found:[NSNull null]];
-}
-
-- (void)parser:(SBJsonStreamParser*)parser foundNumber:(NSNumber*)num {
- [self parser:parser found:num];
-}
-
-- (void)parser:(SBJsonStreamParser*)parser foundString:(NSString*)string {
- [self parser:parser found:string];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.h b/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.h
deleted file mode 100755
index ea893cb..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-#import "SBJsonTokeniser.h"
-#import "SBJsonStreamParser.h"
-
-@interface SBJsonStreamParserState : NSObject
-+ (id)sharedInstance;
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token;
-- (SBJsonStreamParserStatus)parserShouldReturn:(SBJsonStreamParser*)parser;
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok;
-- (BOOL)needKey;
-- (BOOL)isError;
-
-- (NSString*)name;
-
-@end
-
-@interface SBJsonStreamParserStateStart : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateComplete : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateError : SBJsonStreamParserState
-@end
-
-
-@interface SBJsonStreamParserStateObjectStart : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateObjectGotKey : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateObjectSeparator : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateObjectGotValue : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateObjectNeedKey : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateArrayStart : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateArrayGotValue : SBJsonStreamParserState
-@end
-
-@interface SBJsonStreamParserStateArrayNeedValue : SBJsonStreamParserState
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.m b/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.m
deleted file mode 100755
index a24c6f6..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamParserState.m
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamParserState.h"
-#import "SBJsonStreamParser.h"
-
-#define SINGLETON \
-+ (id)sharedInstance { \
- static id state; \
- if (!state) state = [[self alloc] init]; \
- return state; \
-}
-
-@implementation SBJsonStreamParserState
-
-+ (id)sharedInstance { return nil; }
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- return NO;
-}
-
-- (SBJsonStreamParserStatus)parserShouldReturn:(SBJsonStreamParser*)parser {
- return SBJsonStreamParserWaitingForData;
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {}
-
-- (BOOL)needKey {
- return NO;
-}
-
-- (NSString*)name {
- return @"<aaiie!>";
-}
-
-- (BOOL)isError {
- return NO;
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateStart
-
-SINGLETON
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- return token == sbjson_token_array_start || token == sbjson_token_object_start;
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
-
- SBJsonStreamParserState *state = nil;
- switch (tok) {
- case sbjson_token_array_start:
- state = [SBJsonStreamParserStateArrayStart sharedInstance];
- break;
-
- case sbjson_token_object_start:
- state = [SBJsonStreamParserStateObjectStart sharedInstance];
- break;
-
- case sbjson_token_array_end:
- case sbjson_token_object_end:
- if (parser.supportMultipleDocuments)
- state = parser.state;
- else
- state = [SBJsonStreamParserStateComplete sharedInstance];
- break;
-
- case sbjson_token_eof:
- return;
-
- default:
- state = [SBJsonStreamParserStateError sharedInstance];
- break;
- }
-
-
- parser.state = state;
-}
-
-- (NSString*)name { return @"before outer-most array or object"; }
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateComplete
-
-SINGLETON
-
-- (NSString*)name { return @"after outer-most array or object"; }
-
-- (SBJsonStreamParserStatus)parserShouldReturn:(SBJsonStreamParser*)parser {
- return SBJsonStreamParserComplete;
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateError
-
-SINGLETON
-
-- (NSString*)name { return @"in error"; }
-
-- (SBJsonStreamParserStatus)parserShouldReturn:(SBJsonStreamParser*)parser {
- return SBJsonStreamParserError;
-}
-
-- (BOOL)isError {
- return YES;
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateObjectStart
-
-SINGLETON
-
-- (NSString*)name { return @"at beginning of object"; }
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- switch (token) {
- case sbjson_token_object_end:
- case sbjson_token_string:
- return YES;
- break;
- default:
- return NO;
- break;
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- parser.state = [SBJsonStreamParserStateObjectGotKey sharedInstance];
-}
-
-- (BOOL)needKey {
- return YES;
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateObjectGotKey
-
-SINGLETON
-
-- (NSString*)name { return @"after object key"; }
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- return token == sbjson_token_keyval_separator;
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- parser.state = [SBJsonStreamParserStateObjectSeparator sharedInstance];
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateObjectSeparator
-
-SINGLETON
-
-- (NSString*)name { return @"as object value"; }
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- switch (token) {
- case sbjson_token_object_start:
- case sbjson_token_array_start:
- case sbjson_token_true:
- case sbjson_token_false:
- case sbjson_token_null:
- case sbjson_token_number:
- case sbjson_token_string:
- return YES;
- break;
-
- default:
- return NO;
- break;
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- parser.state = [SBJsonStreamParserStateObjectGotValue sharedInstance];
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateObjectGotValue
-
-SINGLETON
-
-- (NSString*)name { return @"after object value"; }
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- switch (token) {
- case sbjson_token_object_end:
- case sbjson_token_separator:
- return YES;
- break;
- default:
- return NO;
- break;
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- parser.state = [SBJsonStreamParserStateObjectNeedKey sharedInstance];
-}
-
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateObjectNeedKey
-
-SINGLETON
-
-- (NSString*)name { return @"in place of object key"; }
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- return sbjson_token_string == token;
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- parser.state = [SBJsonStreamParserStateObjectGotKey sharedInstance];
-}
-
-- (BOOL)needKey {
- return YES;
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateArrayStart
-
-SINGLETON
-
-- (NSString*)name { return @"at array start"; }
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- switch (token) {
- case sbjson_token_object_end:
- case sbjson_token_keyval_separator:
- case sbjson_token_separator:
- return NO;
- break;
-
- default:
- return YES;
- break;
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- parser.state = [SBJsonStreamParserStateArrayGotValue sharedInstance];
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateArrayGotValue
-
-SINGLETON
-
-- (NSString*)name { return @"after array value"; }
-
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- return token == sbjson_token_array_end || token == sbjson_token_separator;
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- if (tok == sbjson_token_separator)
- parser.state = [SBJsonStreamParserStateArrayNeedValue sharedInstance];
-}
-
-@end
-
-#pragma mark -
-
-@implementation SBJsonStreamParserStateArrayNeedValue
-
-SINGLETON
-
-- (NSString*)name { return @"as array value"; }
-
-
-- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token {
- switch (token) {
- case sbjson_token_array_end:
- case sbjson_token_keyval_separator:
- case sbjson_token_object_end:
- case sbjson_token_separator:
- return NO;
- break;
-
- default:
- return YES;
- break;
- }
-}
-
-- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok {
- parser.state = [SBJsonStreamParserStateArrayGotValue sharedInstance];
-}
-
-@end
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.h b/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.h
deleted file mode 100755
index a46b7a1..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-/// Enable JSON writing for non-native objects
-@interface NSObject (SBProxyForJson)
-
-/**
- @brief Allows generation of JSON for otherwise unsupported classes.
-
- If you have a custom class that you want to create a JSON representation
- for you can implement this method in your class. It should return a
- representation of your object defined in terms of objects that can be
- translated into JSON. For example, a Person object might implement it like this:
-
- @code
- - (id)proxyForJson {
- return [NSDictionary dictionaryWithObjectsAndKeys:
- name, @"name",
- phone, @"phone",
- email, @"email",
- nil];
- }
- @endcode
-
- */
-- (id)proxyForJson;
-
-@end
-
-@class SBJsonStreamWriter;
-
-@protocol SBJsonStreamWriterDelegate
-
-- (void)writer:(SBJsonStreamWriter*)writer appendBytes:(const void *)bytes length:(NSUInteger)length;
-
-@end
-
-@class SBJsonStreamWriterState;
-
-/**
- @brief The Stream Writer class.
-
- Accepts a stream of messages and writes JSON of these to its delegate object.
-
- This class provides a range of high-, mid- and low-level methods. You can mix
- and match calls to these. For example, you may want to call -writeArrayOpen
- to start an array and then repeatedly call -writeObject: with various objects
- before finishing off with a -writeArrayClose call.
-
- @see @ref json2objc
-
- */
-
-@interface SBJsonStreamWriter : NSObject {
- NSMutableDictionary *cache;
-}
-
-@property (nonatomic, unsafe_unretained) SBJsonStreamWriterState *state; // Internal
-@property (nonatomic, readonly, strong) NSMutableArray *stateStack; // Internal
-
-/**
- @brief delegate to receive JSON output
- Delegate that will receive messages with output.
- */
-@property (unsafe_unretained) id<SBJsonStreamWriterDelegate> delegate;
-
-/**
- @brief The maximum recursing depth.
-
- Defaults to 512. If the input is nested deeper than this the input will be deemed to be
- malicious and the parser returns nil, signalling an error. ("Nested too deep".) You can
- turn off this security feature by setting the maxDepth value to 0.
- */
-@property NSUInteger maxDepth;
-
-/**
- @brief Whether we are generating human-readable (multiline) JSON.
-
- Set whether or not to generate human-readable JSON. The default is NO, which produces
- JSON without any whitespace between tokens. If set to YES, generates human-readable
- JSON with linebreaks after each array value and dictionary key/value pair, indented two
- spaces per nesting level.
- */
-@property BOOL humanReadable;
-
-/**
- @brief Whether or not to sort the dictionary keys in the output.
-
- If this is set to YES, the dictionary keys in the JSON output will be in sorted order.
- (This is useful if you need to compare two structures, for example.) The default is NO.
- */
-@property BOOL sortKeys;
-
-/**
- @brief An optional comparator to be used if sortKeys is YES.
-
- If this is nil, sorting will be done via @selector(compare:).
- */
-@property (copy) NSComparator sortKeysComparator;
-
-/// Contains the error description after an error has occured.
-@property (copy) NSString *error;
-
-/**
- Write an NSDictionary to the JSON stream.
- @return YES if successful, or NO on failure
- */
-- (BOOL)writeObject:(NSDictionary*)dict;
-
-/**
- Write an NSArray to the JSON stream.
- @return YES if successful, or NO on failure
- */
-- (BOOL)writeArray:(NSArray *)array;
-
-/**
- Start writing an Object to the stream
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeObjectOpen;
-
-/**
- Close the current object being written
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeObjectClose;
-
-/** Start writing an Array to the stream
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeArrayOpen;
-
-/** Close the current Array being written
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeArrayClose;
-
-/** Write a null to the stream
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeNull;
-
-/** Write a boolean to the stream
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeBool:(BOOL)x;
-
-/** Write a Number to the stream
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeNumber:(NSNumber*)n;
-
-/** Write a String to the stream
- @return YES if successful, or NO on failure
-*/
-- (BOOL)writeString:(NSString*)s;
-
-@end
-
-@interface SBJsonStreamWriter (Private)
-- (BOOL)writeValue:(id)v;
-- (void)appendBytes:(const void *)bytes length:(NSUInteger)length;
-@end
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.m b/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.m
deleted file mode 100755
index 1cdd26d..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriter.m
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamWriter.h"
-#import "SBJsonStreamWriterState.h"
-
-static NSNumber *kNotANumber;
-static NSNumber *kTrue;
-static NSNumber *kFalse;
-static NSNumber *kPositiveInfinity;
-static NSNumber *kNegativeInfinity;
-
-
-@implementation SBJsonStreamWriter
-
-@synthesize error;
-@synthesize maxDepth;
-@synthesize state;
-@synthesize stateStack;
-@synthesize humanReadable;
-@synthesize sortKeys;
-@synthesize sortKeysComparator;
-
-+ (void)initialize {
- kNotANumber = [NSDecimalNumber notANumber];
- kPositiveInfinity = [NSNumber numberWithDouble:+INFINITY];
- kNegativeInfinity = [NSNumber numberWithDouble:-INFINITY];
- kTrue = [NSNumber numberWithBool:YES];
- kFalse = [NSNumber numberWithBool:NO];
-}
-
-#pragma mark Housekeeping
-
-@synthesize delegate;
-
-- (id)init {
- self = [super init];
- if (self) {
- maxDepth = 32u;
- stateStack = [[NSMutableArray alloc] initWithCapacity:maxDepth];
- state = [SBJsonStreamWriterStateStart sharedInstance];
- cache = [[NSMutableDictionary alloc] initWithCapacity:32];
- }
- return self;
-}
-
-- (void)dealloc {
- self.state = nil;
-}
-
-#pragma mark Methods
-
-- (void)appendBytes:(const void *)bytes length:(NSUInteger)length {
- [delegate writer:self appendBytes:bytes length:length];
-}
-
-- (BOOL)writeObject:(NSDictionary *)dict {
- if (![self writeObjectOpen])
- return NO;
-
- NSArray *keys = [dict allKeys];
-
- if (sortKeys) {
- if (sortKeysComparator) {
- keys = [keys sortedArrayWithOptions:NSSortStable usingComparator:sortKeysComparator];
- }
- else{
- keys = [keys sortedArrayUsingSelector:@selector(compare:)];
- }
- }
-
- for (id k in keys) {
- if (![k isKindOfClass:[NSString class]]) {
- self.error = [NSString stringWithFormat:@"JSON object key must be string: %@", k];
- return NO;
- }
-
- if (![self writeString:k])
- return NO;
- if (![self writeValue:[dict objectForKey:k]])
- return NO;
- }
-
- return [self writeObjectClose];
-}
-
-- (BOOL)writeArray:(NSArray*)array {
- if (![self writeArrayOpen])
- return NO;
- for (id v in array)
- if (![self writeValue:v])
- return NO;
- return [self writeArrayClose];
-}
-
-
-- (BOOL)writeObjectOpen {
- if ([state isInvalidState:self]) return NO;
- if ([state expectingKey:self]) return NO;
- [state appendSeparator:self];
- if (humanReadable && stateStack.count) [state appendWhitespace:self];
-
- [stateStack addObject:state];
- self.state = [SBJsonStreamWriterStateObjectStart sharedInstance];
-
- if (maxDepth && stateStack.count > maxDepth) {
- self.error = @"Nested too deep";
- return NO;
- }
-
- [delegate writer:self appendBytes:"{" length:1];
- return YES;
-}
-
-- (BOOL)writeObjectClose {
- if ([state isInvalidState:self]) return NO;
-
- SBJsonStreamWriterState *prev = state;
-
- self.state = [stateStack lastObject];
- [stateStack removeLastObject];
-
- if (humanReadable) [prev appendWhitespace:self];
- [delegate writer:self appendBytes:"}" length:1];
-
- [state transitionState:self];
- return YES;
-}
-
-- (BOOL)writeArrayOpen {
- if ([state isInvalidState:self]) return NO;
- if ([state expectingKey:self]) return NO;
- [state appendSeparator:self];
- if (humanReadable && stateStack.count) [state appendWhitespace:self];
-
- [stateStack addObject:state];
- self.state = [SBJsonStreamWriterStateArrayStart sharedInstance];
-
- if (maxDepth && stateStack.count > maxDepth) {
- self.error = @"Nested too deep";
- return NO;
- }
-
- [delegate writer:self appendBytes:"[" length:1];
- return YES;
-}
-
-- (BOOL)writeArrayClose {
- if ([state isInvalidState:self]) return NO;
- if ([state expectingKey:self]) return NO;
-
- SBJsonStreamWriterState *prev = state;
-
- self.state = [stateStack lastObject];
- [stateStack removeLastObject];
-
- if (humanReadable) [prev appendWhitespace:self];
- [delegate writer:self appendBytes:"]" length:1];
-
- [state transitionState:self];
- return YES;
-}
-
-- (BOOL)writeNull {
- if ([state isInvalidState:self]) return NO;
- if ([state expectingKey:self]) return NO;
- [state appendSeparator:self];
- if (humanReadable) [state appendWhitespace:self];
-
- [delegate writer:self appendBytes:"null" length:4];
- [state transitionState:self];
- return YES;
-}
-
-- (BOOL)writeBool:(BOOL)x {
- if ([state isInvalidState:self]) return NO;
- if ([state expectingKey:self]) return NO;
- [state appendSeparator:self];
- if (humanReadable) [state appendWhitespace:self];
-
- if (x)
- [delegate writer:self appendBytes:"true" length:4];
- else
- [delegate writer:self appendBytes:"false" length:5];
- [state transitionState:self];
- return YES;
-}
-
-
-- (BOOL)writeValue:(id)o {
- if ([o isKindOfClass:[NSDictionary class]]) {
- return [self writeObject:o];
-
- } else if ([o isKindOfClass:[NSArray class]]) {
- return [self writeArray:o];
-
- } else if ([o isKindOfClass:[NSString class]]) {
- [self writeString:o];
- return YES;
-
- } else if ([o isKindOfClass:[NSNumber class]]) {
- return [self writeNumber:o];
-
- } else if ([o isKindOfClass:[NSNull class]]) {
- return [self writeNull];
-
- } else if ([o respondsToSelector:@selector(proxyForJson)]) {
- return [self writeValue:[o proxyForJson]];
-
- }
-
- self.error = [NSString stringWithFormat:@"JSON serialisation not supported for %@", [o class]];
- return NO;
-}
-
-static const char *strForChar(int c) {
- switch (c) {
- case 0: return "\\u0000"; break;
- case 1: return "\\u0001"; break;
- case 2: return "\\u0002"; break;
- case 3: return "\\u0003"; break;
- case 4: return "\\u0004"; break;
- case 5: return "\\u0005"; break;
- case 6: return "\\u0006"; break;
- case 7: return "\\u0007"; break;
- case 8: return "\\b"; break;
- case 9: return "\\t"; break;
- case 10: return "\\n"; break;
- case 11: return "\\u000b"; break;
- case 12: return "\\f"; break;
- case 13: return "\\r"; break;
- case 14: return "\\u000e"; break;
- case 15: return "\\u000f"; break;
- case 16: return "\\u0010"; break;
- case 17: return "\\u0011"; break;
- case 18: return "\\u0012"; break;
- case 19: return "\\u0013"; break;
- case 20: return "\\u0014"; break;
- case 21: return "\\u0015"; break;
- case 22: return "\\u0016"; break;
- case 23: return "\\u0017"; break;
- case 24: return "\\u0018"; break;
- case 25: return "\\u0019"; break;
- case 26: return "\\u001a"; break;
- case 27: return "\\u001b"; break;
- case 28: return "\\u001c"; break;
- case 29: return "\\u001d"; break;
- case 30: return "\\u001e"; break;
- case 31: return "\\u001f"; break;
- case 34: return "\\\""; break;
- case 92: return "\\\\"; break;
- }
- NSLog(@"FUTFUTFUT: -->'%c'<---", c);
- return "FUTFUTFUT";
-}
-
-- (BOOL)writeString:(NSString*)string {
- if ([state isInvalidState:self]) return NO;
- [state appendSeparator:self];
- if (humanReadable) [state appendWhitespace:self];
-
- NSMutableData *buf = [cache objectForKey:string];
- if (!buf) {
-
- NSUInteger len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
- const char *utf8 = [string UTF8String];
- NSUInteger written = 0, i = 0;
-
- buf = [NSMutableData dataWithCapacity:(NSUInteger)(len * 1.1f)];
- [buf appendBytes:"\"" length:1];
-
- for (i = 0; i < len; i++) {
- int c = utf8[i];
- BOOL isControlChar = c >= 0 && c < 32;
- if (isControlChar || c == '"' || c == '\\') {
- if (i - written)
- [buf appendBytes:utf8 + written length:i - written];
- written = i + 1;
-
- const char *t = strForChar(c);
- [buf appendBytes:t length:strlen(t)];
- }
- }
-
- if (i - written)
- [buf appendBytes:utf8 + written length:i - written];
-
- [buf appendBytes:"\"" length:1];
- [cache setObject:buf forKey:string];
- }
-
- [delegate writer:self appendBytes:[buf bytes] length:[buf length]];
- [state transitionState:self];
- return YES;
-}
-
-- (BOOL)writeNumber:(NSNumber*)number {
- if (number == kTrue || number == kFalse)
- return [self writeBool:[number boolValue]];
-
- if ([state isInvalidState:self]) return NO;
- if ([state expectingKey:self]) return NO;
- [state appendSeparator:self];
- if (humanReadable) [state appendWhitespace:self];
-
- if ([kPositiveInfinity isEqualToNumber:number]) {
- self.error = @"+Infinity is not a valid number in JSON";
- return NO;
-
- } else if ([kNegativeInfinity isEqualToNumber:number]) {
- self.error = @"-Infinity is not a valid number in JSON";
- return NO;
-
- } else if ([kNotANumber isEqualToNumber:number]) {
- self.error = @"NaN is not a valid number in JSON";
- return NO;
- }
-
- const char *objcType = [number objCType];
- char num[128];
- size_t len;
-
- switch (objcType[0]) {
- case 'c': case 'i': case 's': case 'l': case 'q':
- len = snprintf(num, sizeof num, "%lld", [number longLongValue]);
- break;
- case 'C': case 'I': case 'S': case 'L': case 'Q':
- len = snprintf(num, sizeof num, "%llu", [number unsignedLongLongValue]);
- break;
- case 'f': case 'd': default:
- if ([number isKindOfClass:[NSDecimalNumber class]]) {
- char const *utf8 = [[number stringValue] UTF8String];
- [delegate writer:self appendBytes:utf8 length: strlen(utf8)];
- [state transitionState:self];
- return YES;
- }
- len = snprintf(num, sizeof num, "%.17g", [number doubleValue]);
- break;
- }
- [delegate writer:self appendBytes:num length: len];
- [state transitionState:self];
- return YES;
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.h b/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.h
deleted file mode 100755
index b12d0d5..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- Copyright (C) 2011 Stig Brautaset. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of the author nor the names of its contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamWriter.h"
-
-@interface SBJsonStreamWriterAccumulator : NSObject <SBJsonStreamWriterDelegate>
-
-@property (readonly, copy) NSMutableData* data;
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.m b/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.m
deleted file mode 100755
index be65190..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterAccumulator.m
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Copyright (C) 2011 Stig Brautaset. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- * Neither the name of the author nor the names of its contributors may be used
- to endorse or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamWriterAccumulator.h"
-
-
-@implementation SBJsonStreamWriterAccumulator
-
-@synthesize data;
-
-- (id)init {
- self = [super init];
- if (self) {
- data = [[NSMutableData alloc] initWithCapacity:8096u];
- }
- return self;
-}
-
-
-#pragma mark SBJsonStreamWriterDelegate
-
-- (void)writer:(SBJsonStreamWriter *)writer appendBytes:(const void *)bytes length:(NSUInteger)length {
- [data appendBytes:bytes length:length];
-}
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.h b/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.h
deleted file mode 100755
index 90d442a..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-@class SBJsonStreamWriter;
-
-@interface SBJsonStreamWriterState : NSObject
-+ (id)sharedInstance;
-- (BOOL)isInvalidState:(SBJsonStreamWriter*)writer;
-- (void)appendSeparator:(SBJsonStreamWriter*)writer;
-- (BOOL)expectingKey:(SBJsonStreamWriter*)writer;
-- (void)transitionState:(SBJsonStreamWriter*)writer;
-- (void)appendWhitespace:(SBJsonStreamWriter*)writer;
-@end
-
-@interface SBJsonStreamWriterStateObjectStart : SBJsonStreamWriterState
-@end
-
-@interface SBJsonStreamWriterStateObjectKey : SBJsonStreamWriterStateObjectStart
-@end
-
-@interface SBJsonStreamWriterStateObjectValue : SBJsonStreamWriterState
-@end
-
-@interface SBJsonStreamWriterStateArrayStart : SBJsonStreamWriterState
-@end
-
-@interface SBJsonStreamWriterStateArrayValue : SBJsonStreamWriterState
-@end
-
-@interface SBJsonStreamWriterStateStart : SBJsonStreamWriterState
-@end
-
-@interface SBJsonStreamWriterStateComplete : SBJsonStreamWriterState
-@end
-
-@interface SBJsonStreamWriterStateError : SBJsonStreamWriterState
-@end
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.m b/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.m
deleted file mode 100755
index 9f04cac..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonStreamWriterState.m
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonStreamWriterState.h"
-#import "SBJsonStreamWriter.h"
-
-#define SINGLETON \
-+ (id)sharedInstance { \
- static id state; \
- if (!state) state = [[self alloc] init]; \
- return state; \
-}
-
-
-@implementation SBJsonStreamWriterState
-+ (id)sharedInstance { return nil; }
-- (BOOL)isInvalidState:(SBJsonStreamWriter*)writer { return NO; }
-- (void)appendSeparator:(SBJsonStreamWriter*)writer {}
-- (BOOL)expectingKey:(SBJsonStreamWriter*)writer { return NO; }
-- (void)transitionState:(SBJsonStreamWriter *)writer {}
-- (void)appendWhitespace:(SBJsonStreamWriter*)writer {
- [writer appendBytes:"\n" length:1];
- for (NSUInteger i = 0; i < writer.stateStack.count; i++)
- [writer appendBytes:" " length:2];
-}
-@end
-
-@implementation SBJsonStreamWriterStateObjectStart
-
-SINGLETON
-
-- (void)transitionState:(SBJsonStreamWriter *)writer {
- writer.state = [SBJsonStreamWriterStateObjectValue sharedInstance];
-}
-- (BOOL)expectingKey:(SBJsonStreamWriter *)writer {
- writer.error = @"JSON object key must be string";
- return YES;
-}
-@end
-
-@implementation SBJsonStreamWriterStateObjectKey
-
-SINGLETON
-
-- (void)appendSeparator:(SBJsonStreamWriter *)writer {
- [writer appendBytes:"," length:1];
-}
-@end
-
-@implementation SBJsonStreamWriterStateObjectValue
-
-SINGLETON
-
-- (void)appendSeparator:(SBJsonStreamWriter *)writer {
- [writer appendBytes:":" length:1];
-}
-- (void)transitionState:(SBJsonStreamWriter *)writer {
- writer.state = [SBJsonStreamWriterStateObjectKey sharedInstance];
-}
-- (void)appendWhitespace:(SBJsonStreamWriter *)writer {
- [writer appendBytes:" " length:1];
-}
-@end
-
-@implementation SBJsonStreamWriterStateArrayStart
-
-SINGLETON
-
-- (void)transitionState:(SBJsonStreamWriter *)writer {
- writer.state = [SBJsonStreamWriterStateArrayValue sharedInstance];
-}
-@end
-
-@implementation SBJsonStreamWriterStateArrayValue
-
-SINGLETON
-
-- (void)appendSeparator:(SBJsonStreamWriter *)writer {
- [writer appendBytes:"," length:1];
-}
-@end
-
-@implementation SBJsonStreamWriterStateStart
-
-SINGLETON
-
-
-- (void)transitionState:(SBJsonStreamWriter *)writer {
- writer.state = [SBJsonStreamWriterStateComplete sharedInstance];
-}
-- (void)appendSeparator:(SBJsonStreamWriter *)writer {
-}
-@end
-
-@implementation SBJsonStreamWriterStateComplete
-
-SINGLETON
-
-- (BOOL)isInvalidState:(SBJsonStreamWriter*)writer {
- writer.error = @"Stream is closed";
- return YES;
-}
-@end
-
-@implementation SBJsonStreamWriterStateError
-
-SINGLETON
-
-@end
-
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.h b/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.h
deleted file mode 100755
index e484a94..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- Copyright (c) 2010, Stig Brautaset.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-typedef enum {
- sbjson_token_error = -1,
- sbjson_token_eof,
-
- sbjson_token_array_start,
- sbjson_token_array_end,
-
- sbjson_token_object_start,
- sbjson_token_object_end,
-
- sbjson_token_separator,
- sbjson_token_keyval_separator,
-
- sbjson_token_number,
- sbjson_token_string,
- sbjson_token_true,
- sbjson_token_false,
- sbjson_token_null,
-
-} sbjson_token_t;
-
-@class SBJsonUTF8Stream;
-
-@interface SBJsonTokeniser : NSObject
-
-@property (strong) SBJsonUTF8Stream *stream;
-@property (copy) NSString *error;
-
-- (void)appendData:(NSData*)data_;
-
-- (sbjson_token_t)getToken:(NSObject**)token;
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.m
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.m b/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.m
deleted file mode 100755
index 75d3268..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonTokeniser.m
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- Copyright (c) 2010-2011, Stig Brautaset. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "SBJsonTokeniser.h"
-#import "SBJsonUTF8Stream.h"
-
-#define SBStringIsIllegalSurrogateHighCharacter(character) (((character) >= 0xD800UL) && ((character) <= 0xDFFFUL))
-#define SBStringIsSurrogateLowCharacter(character) ((character >= 0xDC00UL) && (character <= 0xDFFFUL))
-#define SBStringIsSurrogateHighCharacter(character) ((character >= 0xD800UL) && (character <= 0xDBFFUL))
-
-@implementation SBJsonTokeniser
-
-@synthesize error = _error;
-@synthesize stream = _stream;
-
-- (id)init {
- self = [super init];
- if (self) {
- _stream = [[SBJsonUTF8Stream alloc] init];
-
- }
-
- return self;
-}
-
-
-- (void)appendData:(NSData *)data_ {
- [_stream appendData:data_];
-}
-
-
-- (sbjson_token_t)match:(const char *)pattern length:(NSUInteger)len retval:(sbjson_token_t)token {
- if (![_stream haveRemainingCharacters:len])
- return sbjson_token_eof;
-
- if ([_stream skipCharacters:pattern length:len])
- return token;
-
- self.error = [NSString stringWithFormat:@"Expected '%s' after initial '%.1s'", pattern, pattern];
- return sbjson_token_error;
-}
-
-- (BOOL)decodeEscape:(unichar)ch into:(unichar*)decoded {
- switch (ch) {
- case '\\':
- case '/':
- case '"':
- *decoded = ch;
- break;
-
- case 'b':
- *decoded = '\b';
- break;
-
- case 'n':
- *decoded = '\n';
- break;
-
- case 'r':
- *decoded = '\r';
- break;
-
- case 't':
- *decoded = '\t';
- break;
-
- case 'f':
- *decoded = '\f';
- break;
-
- default:
- self.error = @"Illegal escape character";
- return NO;
- break;
- }
- return YES;
-}
-
-- (BOOL)decodeHexQuad:(unichar*)quad {
- unichar c, tmp = 0;
-
- for (int i = 0; i < 4; i++) {
- (void)[_stream getNextUnichar:&c];
- tmp *= 16;
- switch (c) {
- case '0' ... '9':
- tmp += c - '0';
- break;
-
- case 'a' ... 'f':
- tmp += 10 + c - 'a';
- break;
-
- case 'A' ... 'F':
- tmp += 10 + c - 'A';
- break;
-
- default:
- return NO;
- }
- }
- *quad = tmp;
- return YES;
-}
-
-- (sbjson_token_t)getStringToken:(NSObject**)token {
- NSMutableString *acc = nil;
-
- for (;;) {
- [_stream skip];
-
- unichar ch;
- {
- NSMutableString *string = nil;
-
- if (![_stream getStringFragment:&string])
- return sbjson_token_eof;
-
- if (!string) {
- self.error = @"Broken Unicode encoding";
- return sbjson_token_error;
- }
-
- if (![_stream getUnichar:&ch])
- return sbjson_token_eof;
-
- if (acc) {
- [acc appendString:string];
-
- } else if (ch == '"') {
- *token = [string copy];
- [_stream skip];
- return sbjson_token_string;
-
- } else {
- acc = [string mutableCopy];
- }
- }
-
-
- switch (ch) {
- case 0 ... 0x1F:
- self.error = [NSString stringWithFormat:@"Unescaped control character [0x%0.2X]", (int)ch];
- return sbjson_token_error;
- break;
-
- case '"':
- *token = acc;
- [_stream skip];
- return sbjson_token_string;
- break;
-
- case '\\':
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
-
- if (ch == 'u') {
- if (![_stream haveRemainingCharacters:5])
- return sbjson_token_eof;
-
- unichar hi;
- if (![self decodeHexQuad:&hi]) {
- self.error = @"Invalid hex quad";
- return sbjson_token_error;
- }
-
- if (SBStringIsSurrogateHighCharacter(hi)) {
- unichar lo;
-
- if (![_stream haveRemainingCharacters:6])
- return sbjson_token_eof;
-
- (void)[_stream getNextUnichar:&ch];
- (void)[_stream getNextUnichar:&lo];
- if (ch != '\\' || lo != 'u' || ![self decodeHexQuad:&lo]) {
- self.error = @"Missing low character in surrogate pair";
- return sbjson_token_error;
- }
-
- if (!SBStringIsSurrogateLowCharacter(lo)) {
- self.error = @"Invalid low character in surrogate pair";
- return sbjson_token_error;
- }
-
- [acc appendFormat:@"%C%C", hi, lo];
- } else if (SBStringIsIllegalSurrogateHighCharacter(hi)) {
- self.error = @"Invalid high character in surrogate pair";
- return sbjson_token_error;
- } else {
- [acc appendFormat:@"%C", hi];
- }
-
-
- } else {
- unichar decoded;
- if (![self decodeEscape:ch into:&decoded])
- return sbjson_token_error;
- [acc appendFormat:@"%C", decoded];
- }
-
- break;
-
- default: {
- self.error = [NSString stringWithFormat:@"Invalid UTF-8: '%x'", (int)ch];
- return sbjson_token_error;
- break;
- }
- }
- }
- return sbjson_token_eof;
-}
-
-- (sbjson_token_t)getNumberToken:(NSObject**)token {
-
- NSUInteger numberStart = _stream.index;
- NSCharacterSet *digits = [NSCharacterSet decimalDigitCharacterSet];
-
- unichar ch;
- if (![_stream getUnichar:&ch])
- return sbjson_token_eof;
-
- BOOL isNegative = NO;
- if (ch == '-') {
- isNegative = YES;
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
- }
-
- unsigned long long mantissa = 0;
- int mantissa_length = 0;
-
- if (ch == '0') {
- mantissa_length++;
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
-
- if ([digits characterIsMember:ch]) {
- self.error = @"Leading zero is illegal in number";
- return sbjson_token_error;
- }
- }
-
- while ([digits characterIsMember:ch]) {
- mantissa *= 10;
- mantissa += (ch - '0');
- mantissa_length++;
-
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
- }
-
- short exponent = 0;
- BOOL isFloat = NO;
-
- if (ch == '.') {
- isFloat = YES;
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
-
- while ([digits characterIsMember:ch]) {
- mantissa *= 10;
- mantissa += (ch - '0');
- mantissa_length++;
- exponent--;
-
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
- }
-
- if (!exponent) {
- self.error = @"No digits after decimal point";
- return sbjson_token_error;
- }
- }
-
- BOOL hasExponent = NO;
- if (ch == 'e' || ch == 'E') {
- hasExponent = YES;
-
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
-
- BOOL expIsNegative = NO;
- if (ch == '-') {
- expIsNegative = YES;
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
-
- } else if (ch == '+') {
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
- }
-
- short explicit_exponent = 0;
- short explicit_exponent_length = 0;
- while ([digits characterIsMember:ch]) {
- explicit_exponent *= 10;
- explicit_exponent += (ch - '0');
- explicit_exponent_length++;
-
- if (![_stream getNextUnichar:&ch])
- return sbjson_token_eof;
- }
-
- if (explicit_exponent_length == 0) {
- self.error = @"No digits in exponent";
- return sbjson_token_error;
- }
-
- if (expIsNegative)
- exponent -= explicit_exponent;
- else
- exponent += explicit_exponent;
- }
-
- if (!mantissa_length && isNegative) {
- self.error = @"No digits after initial minus";
- return sbjson_token_error;
-
- } else if (mantissa_length >= 19) {
-
- NSString *number = [_stream stringWithRange:NSMakeRange(numberStart, _stream.index - numberStart)];
- *token = [NSDecimalNumber decimalNumberWithString:number];
-
- } else if (!isFloat && !hasExponent) {
- if (!isNegative)
- *token = [NSNumber numberWithUnsignedLongLong:mantissa];
- else
- *token = [NSNumber numberWithLongLong:-mantissa];
- } else {
- *token = [NSDecimalNumber decimalNumberWithMantissa:mantissa
- exponent:exponent
- isNegative:isNegative];
- }
-
- return sbjson_token_number;
-}
-
-- (sbjson_token_t)getToken:(NSObject **)token {
-
- [_stream skipWhitespace];
-
- unichar ch;
- if (![_stream getUnichar:&ch])
- return sbjson_token_eof;
-
- NSUInteger oldIndexLocation = _stream.index;
- sbjson_token_t tok;
-
- switch (ch) {
- case '[':
- tok = sbjson_token_array_start;
- [_stream skip];
- break;
-
- case ']':
- tok = sbjson_token_array_end;
- [_stream skip];
- break;
-
- case '{':
- tok = sbjson_token_object_start;
- [_stream skip];
- break;
-
- case ':':
- tok = sbjson_token_keyval_separator;
- [_stream skip];
- break;
-
- case '}':
- tok = sbjson_token_object_end;
- [_stream skip];
- break;
-
- case ',':
- tok = sbjson_token_separator;
- [_stream skip];
- break;
-
- case 'n':
- tok = [self match:"null" length:4 retval:sbjson_token_null];
- break;
-
- case 't':
- tok = [self match:"true" length:4 retval:sbjson_token_true];
- break;
-
- case 'f':
- tok = [self match:"false" length:5 retval:sbjson_token_false];
- break;
-
- case '"':
- tok = [self getStringToken:token];
- break;
-
- case '0' ... '9':
- case '-':
- tok = [self getNumberToken:token];
- break;
-
- case '+':
- self.error = @"Leading + is illegal in number";
- tok = sbjson_token_error;
- break;
-
- default:
- self.error = [NSString stringWithFormat:@"Illegal start of token [%c]", ch];
- tok = sbjson_token_error;
- break;
- }
-
- if (tok == sbjson_token_eof) {
- // We ran out of bytes in the middle of a token.
- // We don't know how to restart in mid-flight, so
- // rewind to the start of the token for next attempt.
- // Hopefully we'll have more data then.
- _stream.index = oldIndexLocation;
- }
-
- return tok;
-}
-
-
-@end
http://git-wip-us.apache.org/repos/asf/usergrid/blob/867060fa/sdks/ios/UGAPI/SBJson/SBJsonUTF8Stream.h
----------------------------------------------------------------------
diff --git a/sdks/ios/UGAPI/SBJson/SBJsonUTF8Stream.h b/sdks/ios/UGAPI/SBJson/SBJsonUTF8Stream.h
deleted file mode 100755
index a26f032..0000000
--- a/sdks/ios/UGAPI/SBJson/SBJsonUTF8Stream.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright (c) 2011, Stig Brautaset. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are
- met:
-
- Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- Neither the name of the the author nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Foundation/Foundation.h>
-
-
-@interface SBJsonUTF8Stream : NSObject {
-@private
- const char *_bytes;
- NSMutableData *_data;
- NSUInteger _length;
-}
-
-@property (assign) NSUInteger index;
-
-- (void)appendData:(NSData*)data_;
-
-- (BOOL)haveRemainingCharacters:(NSUInteger)chars;
-
-- (void)skip;
-- (void)skipWhitespace;
-- (BOOL)skipCharacters:(const char *)chars length:(NSUInteger)len;
-
-- (BOOL)getUnichar:(unichar*)ch;
-- (BOOL)getNextUnichar:(unichar*)ch;
-- (BOOL)getStringFragment:(NSString**)string;
-
-- (NSString*)stringWithRange:(NSRange)range;
-
-@end