diff options
Diffstat (limited to 'libs/TouchJSON/JSON/CJSONScanner.h')
| -rwxr-xr-x | libs/TouchJSON/JSON/CJSONScanner.h | 95 |
1 files changed, 95 insertions, 0 deletions
| diff --git a/libs/TouchJSON/JSON/CJSONScanner.h b/libs/TouchJSON/JSON/CJSONScanner.h new file mode 100755 index 0000000..d410893 --- /dev/null +++ b/libs/TouchJSON/JSON/CJSONScanner.h | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | // | ||
| 2 | // CJSONScanner.h | ||
| 3 | // TouchCode | ||
| 4 | // | ||
| 5 | // Created by Jonathan Wight on 12/07/2005. | ||
| 6 | // Copyright 2005 toxicsoftware.com. All rights reserved. | ||
| 7 | // | ||
| 8 | // Permission is hereby granted, free of charge, to any person | ||
| 9 | // obtaining a copy of this software and associated documentation | ||
| 10 | // files (the "Software"), to deal in the Software without | ||
| 11 | // restriction, including without limitation the rights to use, | ||
| 12 | // copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 13 | // copies of the Software, and to permit persons to whom the | ||
| 14 | // Software is furnished to do so, subject to the following | ||
| 15 | // conditions: | ||
| 16 | // | ||
| 17 | // The above copyright notice and this permission notice shall be | ||
| 18 | // included in all copies or substantial portions of the Software. | ||
| 19 | // | ||
| 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
| 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
| 24 | // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
| 25 | // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 26 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
| 27 | // OTHER DEALINGS IN THE SOFTWARE. | ||
| 28 | // | ||
| 29 | |||
| 30 | #import "CDataScanner.h" | ||
| 31 | |||
| 32 | enum { | ||
| 33 | kJSONScannerOptions_MutableContainers = 0x1, | ||
| 34 | kJSONScannerOptions_MutableLeaves = 0x2, | ||
| 35 | }; | ||
| 36 | typedef NSUInteger EJSONScannerOptions; | ||
| 37 | |||
| 38 | /// CDataScanner subclass that understands JSON syntax natively. You should generally use CJSONDeserializer instead of this class. (TODO - this could have been a category?) | ||
| 39 | @interface CJSONScanner : CDataScanner { | ||
| 40 | BOOL strictEscapeCodes; | ||
| 41 | id nullObject; | ||
| 42 | NSStringEncoding allowedEncoding; | ||
| 43 | EJSONScannerOptions options; | ||
| 44 | } | ||
| 45 | |||
| 46 | @property (readwrite, nonatomic, assign) BOOL strictEscapeCodes; | ||
| 47 | @property (readwrite, nonatomic, retain) id nullObject; | ||
| 48 | @property (readwrite, nonatomic, assign) NSStringEncoding allowedEncoding; | ||
| 49 | @property (readwrite, nonatomic, assign) EJSONScannerOptions options; | ||
| 50 | |||
| 51 | - (BOOL)setData:(NSData *)inData error:(NSError **)outError; | ||
| 52 | |||
| 53 | - (BOOL)scanJSONObject:(id *)outObject error:(NSError **)outError; | ||
| 54 | - (BOOL)scanJSONDictionary:(NSDictionary **)outDictionary error:(NSError **)outError; | ||
| 55 | - (BOOL)scanJSONArray:(NSArray **)outArray error:(NSError **)outError; | ||
| 56 | - (BOOL)scanJSONStringConstant:(NSString **)outStringConstant error:(NSError **)outError; | ||
| 57 | - (BOOL)scanJSONNumberConstant:(NSNumber **)outNumberConstant error:(NSError **)outError; | ||
| 58 | |||
| 59 | @end | ||
| 60 | |||
| 61 | extern NSString *const kJSONScannerErrorDomain /* = @"kJSONScannerErrorDomain" */; | ||
| 62 | |||
| 63 | typedef enum { | ||
| 64 | |||
| 65 | // Fundamental scanning errors | ||
| 66 | kJSONScannerErrorCode_NothingToScan = -11, | ||
| 67 | kJSONScannerErrorCode_CouldNotDecodeData = -12, | ||
| 68 | kJSONScannerErrorCode_CouldNotSerializeData = -13, | ||
| 69 | kJSONScannerErrorCode_CouldNotSerializeObject = -14, | ||
| 70 | kJSONScannerErrorCode_CouldNotScanObject = -15, | ||
| 71 | |||
| 72 | // Dictionary scanning | ||
| 73 | kJSONScannerErrorCode_DictionaryStartCharacterMissing = -101, | ||
| 74 | kJSONScannerErrorCode_DictionaryKeyScanFailed = -102, | ||
| 75 | kJSONScannerErrorCode_DictionaryKeyNotTerminated = -103, | ||
| 76 | kJSONScannerErrorCode_DictionaryValueScanFailed = -104, | ||
| 77 | kJSONScannerErrorCode_DictionaryKeyValuePairNoDelimiter = -105, | ||
| 78 | kJSONScannerErrorCode_DictionaryNotTerminated = -106, | ||
| 79 | |||
| 80 | // Array scanning | ||
| 81 | kJSONScannerErrorCode_ArrayStartCharacterMissing = -201, | ||
| 82 | kJSONScannerErrorCode_ArrayValueScanFailed = -202, | ||
| 83 | kJSONScannerErrorCode_ArrayValueIsNull = -203, | ||
| 84 | kJSONScannerErrorCode_ArrayNotTerminated = -204, | ||
| 85 | |||
| 86 | // String scanning | ||
| 87 | kJSONScannerErrorCode_StringNotStartedWithBackslash = -301, | ||
| 88 | kJSONScannerErrorCode_StringUnicodeNotDecoded = -302, | ||
| 89 | kJSONScannerErrorCode_StringUnknownEscapeCode = -303, | ||
| 90 | kJSONScannerErrorCode_StringNotTerminated = -304, | ||
| 91 | |||
| 92 | // Number scanning | ||
| 93 | kJSONScannerErrorCode_NumberNotScannable = -401 | ||
| 94 | |||
| 95 | } EJSONScannerErrorCode; | ||
