-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFAFStringScanner.h
More file actions
109 lines (81 loc) · 2.74 KB
/
FAFStringScanner.h
File metadata and controls
109 lines (81 loc) · 2.74 KB
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
//
// FAFStringScanner.h
// oas-compile
//
// Created by Manoah F Adams on 2013-06-28.
// Copyright 2013 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface FAFStringScanner : NSObject
{
NSString* _string;
int _scanLoc;
int _maxLoc;
NSRange _lastFind;
BOOL shouldTokenizeQuotedStrings;
NSArray* alphaNums; // also contains @ and _
NSArray* whiteSpaces;
}
- (id) initWithString:(NSString*)input;
- (int) scanLocation;
- (void) setScanLocation:(int)loc;
/*!
\brief advances the location cursor by the amount specified. Negative values indicate retreat.
*/
- (void) advance:(int) count;
/*!
\brief Returns YES if the cursor is past the last character.
*/
- (BOOL) isAtEnd;
- (NSString*) readUntilString:(NSString*)findString;
- (NSString*) readUntilStringAdvancingTo:(NSString*)findString;
- (NSString*) readUntilStringAdvancingPast:(NSString*)findString;
- (NSRange) _findString:(NSString*)aString;
- (NSString*) readUntilStrings:(NSArray*)findStrings matchString:(NSString* *)string;
- (NSString*) readUntilStringsAdvancingTo:(NSArray*)findStrings matchString:(NSString* *)string;
- (NSString*) readUntilStringsAdvancingPast:(NSArray*)findStrings matchString:(NSString* *)string;
- (NSString*) readForLengthAdvancing: (NSUInteger) length;
/*!
\brief Returns a string equal to the span from the current posisiton to the end of the input string.
*/
- (NSString*) readRemainder;
- (NSArray*) readRemainingTokens;
/*!
\brief returns the previous character, without moving.
*/
- (NSString*) prevCharacter;
/*!
\brief returns the current character, without advancing.
*/
- (NSString*) nextCharacter;
/*!
\brief returns the current character, and advances by 1.
*/
- (NSString*) readCharacter;
/*!
\brief Checks the next character for a parenthesis, brace, bracket, or quote, and reads until the corresponding closure.
This method will not be confused by intervening balanced segments.
If the next character is not a parenthesis, brace, bracket or quote, behaviour is undefined.
Any brace, bracket, or parenthesis inside a quote will be ignored, whether or not it is balanced.
Nested quotes are not supported.
*/
- (NSString*) readBalanced;
/*!
\brief if YES when reading tokens, then if next token is a quote, will read balanced instead. Defaults to YES.
*/
- (void) setShouldTokenizeQuotedStrings: (BOOL) flag;
/*!
\brief returns the next token, without advancing the cursor.
*/
- (NSString*) nextToken;
/*!
\brief returns the next token, and advances the cursor to after the token.
*/
- (NSString*) readToken;
- (NSArray*) readTokensBalanced;
- (unsigned) lineCount;
/*!
\brief replaces all occurrances of excaped characters with actual characters.
*/
+ (NSString*) unescapeString:(NSString*) string;
@end