changed git call from https to git readonly
[atutor.git] / mods / atsocial_iphone_app / TouchJSON / Extensions / CDataScanner_Extensions.m
1 //
2 //  NSScanner_Extensions.m
3 //  TouchJSON
4 //
5 //  Created by Jonathan Wight on 12/08/2005.
6 //  Copyright 2005 Toxic Software. All rights reserved.
7 //
8
9 #import "CDataScanner_Extensions.h"
10
11 #import "NSCharacterSet_Extensions.h"
12
13 @implementation CDataScanner (CDataScanner_Extensions)
14
15 - (BOOL)scanCStyleComment:(NSString **)outComment
16 {
17 if ([self scanString:@"/*" intoString:NULL] == YES)
18         {
19         NSString *theComment = NULL;
20         if ([self scanUpToString:@"*/" intoString:&theComment] == NO)
21                 [NSException raise:NSGenericException format:@"Started to scan a C style comment but it wasn't terminated."];
22                 
23         if ([theComment rangeOfString:@"/*"].location != NSNotFound)
24                 [NSException raise:NSGenericException format:@"C style comments should not be nested."];
25         
26         if ([self scanString:@"*/" intoString:NULL] == NO)
27                 [NSException raise:NSGenericException format:@"C style comment did not end correctly."];
28                 
29         if (outComment != NULL)
30                 *outComment = theComment;
31
32         return(YES);
33         }
34 else
35         {
36         return(NO);
37         }
38 }
39
40 - (BOOL)scanCPlusPlusStyleComment:(NSString **)outComment
41 {
42 if ([self scanString:@"//" intoString:NULL] == YES)
43         {
44         NSString *theComment = NULL;
45         [self scanUpToCharactersFromSet:[NSCharacterSet linebreaksCharacterSet] intoString:&theComment];
46         [self scanCharactersFromSet:[NSCharacterSet linebreaksCharacterSet] intoString:NULL];
47
48         if (outComment != NULL)
49                 *outComment = theComment;
50
51         return(YES);
52         }
53 else
54         {
55         return(NO);
56         }
57 }
58
59 @end