-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRegExRoot.h
154 lines (105 loc) · 3.42 KB
/
RegExRoot.h
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//
// RegExRoot.h
// RegExhibit
//
// Copyright 2007 Roger Jolly. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import "RegExMatch.h"
typedef enum regEx_modifiers {
regExFindAll = 0,
regExCaseInsensitive = 1,
regExWhiteSpace = 2,
regExDotMatchNEwline = 3,
regExMultiline = 4,
regExUnicode = 5
} regExModifierLabel;
typedef enum regEx_uses {
regExMatch = 0,
regExReplace = 1,
regExSplit = 2
} regExUseLabel;
@interface RegExRoot : NSObject
{
BOOL matchSucceeded, matchFinished, doSplit;
// instance variables that save information about the current match
int encodingToUse;
BOOL allowCode;
BOOL matchAll;
NSString *textToMatch;
NSString *matchRegEx;
NSSet *regExModifiers;
NSString *replacementText;
// Arrays to store results
NSMutableArray *matches; // array with RexExMatch-objects
NSMutableArray *splits; // array with NSString-objects
// Task of seperate Perl thread.
NSTask *regExTask;
BOOL dummyText; // mark if RegExhibit uses a dummytext to validate a regex without a user given text.
}
#pragma mark-
#pragma mark Initialisation
- (id) init;
#pragma mark-
#pragma mark Accessors
- (void) setEncodingToUse: (int) anEncoding;
- (int) encodingToUse;
- (void) setMatchAll: (BOOL) aBOOL;
- (BOOL) matchAll;
- (void) setTextToMatch: (NSString *) aString;
- (NSString *) textToMatch;
- (void) setMatchRegEx: (NSString *) aString;
- (NSString *) matchRegEx;
- (void) setRegExModifiers: (NSSet *) modifiers;
- (NSSet *) regExModifiers;
- (void) setReplacementText: (NSString *) aString;
- (NSString *) replacementText;
- (void) setRegExTask: (NSTask *) aTask;
- (NSTask *) regExTask;
- (void) addMatchWithBeginPosition: (int) beginPosition endPosition: (int) endPosition;
- (RegExMatch *) matchNumber: (int) matchNumber;
- (NSString *) splitNumber: (int) splitNumber;
- (void) setMatchSucceeded: (BOOL) anError;
- (BOOL) matchSucceeded;
- (BOOL) matchError;
- (void) setMatchFinished: (BOOL) aBOOL;
- (BOOL) matchFinished;
- (void) setDoSplit: (BOOL) aBOOL;
- (BOOL) doSplit;
#pragma mark-
#pragma mark Regular expression methods
- (void) matchText: (NSString *) matchText
toRegEx: (NSString *) regEx
modifiers: (NSSet *) modifiers
replacement: (NSString *) replaceString
allowCode: (BOOL) codeAllowed;
- (void) replaceInText: (NSString *) textToReplace
regEx: (NSString *) regEx
modifiers: (NSSet *) modifiers
replacement: (NSString *) replaceString
allowCode: (BOOL) codeAllowed;
- (void) splitText: (NSString *) textToSplit
onRegEx: (NSString *) regEx
modifiers: (NSSet *) modifiers
allowCode: (BOOL) codeAllowed;
- (void) modifiersToString: (NSMutableString *) modifiersString;
- (void) buildPerlProgram: (NSMutableString *) programString
version: (int) goal
modifiers: (NSMutableString *) modifiersString;
- (void) runPerlProgram: (NSString *) programString withInput: (NSString *) programInput;
- (void) abortMatching;
- (void) regExError: (NSNotification *) note;
- (void) regExFinished: (NSNotification *) note;
- (void) buildResultsWith: (NSString *) matchResults;
#pragma mark-
#pragma mark Other methods
- (int) numberOfMatches;
- (int) numberOfSplits;
- (void) clearSelf;
- (NSString *) displayInOutlineWithSource: (NSString *) sourceText;
- (int) numberOfChildrenShowingReplacements: (BOOL) showReplacements;
- (id) child: (int) index;
#pragma mark-
#pragma mark Cleaning up
- (void) dealloc;
@end