-
Notifications
You must be signed in to change notification settings - Fork 8
/
BFUtilityParser.m
89 lines (61 loc) · 2.26 KB
/
BFUtilityParser.m
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
//
// BFUtilityParser.m
// Briefs
//
// Created by Rob Rhyne on 8/22/09.
// Copyright Digital Arch Design, 2009. See LICENSE file for details.
//
#import "BFUtilityParser.h"
#import "BFConstants.h"
@implementation BFUtilityParser
///////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark Action Parse Methods
+ (NSString *)parseActionCommand:(NSString *)action
{
NSString *lowered = [action lowercaseString];
if ([lowered hasPrefix:kBFActorActionGoto]) {
return kBFActorActionGoto;
} else if ([lowered hasPrefix:kBFActorActionToggle]) {
return kBFActorActionToggle;
} else if ([lowered hasPrefix:kBFActorActionResize]) {
return kBFActorActionResize;
} else if ([lowered hasPrefix:kBFActorActionMove]) {
return kBFActorActionMove;
} else if ([lowered hasPrefix:kBFActorActionHide]) {
return kBFActorActionHide;
} else if ([lowered hasPrefix:kBFActorActionShow]) {
return kBFActorActionShow;
}
// TODO: throw exception?
return nil;
}
+ (NSArray *)parseActionArgsIntoArray:(NSString *)action withPrefix:(NSString *)prefix
{
// check for the a nil action
if (action != nil && ![action isEqual:@""]) {
// normalize the action string
NSString *lowered = [[action lowercaseString] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSRange start = [lowered rangeOfString:@"("];
NSRange end = [lowered rangeOfString:@")"];
NSString *argumentsAsString = [[lowered substringToIndex:end.location] substringFromIndex:start.location+1];
NSArray *argumentsAsArray = [argumentsAsString componentsSeparatedByString:@","];
return argumentsAsArray;
}
else return nil;
}
///////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark Scene Transition Parse Methods
+ (NSString *)parseSceneTransitionCommand:(NSString *)transition
{
// TODO: Do something here.
return nil;
}
+ (NSArray *)parseSceneTransitionOptionsIntoArray:(NSString *)transition withPrefix:(NSString *)prefix
{
// TODO: Do something here.
return nil;
}
///////////////////////////////////////////////////////////////////////////////
@end