forked from pmougin/F-Script
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFSCNBase.m
56 lines (45 loc) · 1.26 KB
/
FSCNBase.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
/* FSCNBase.m Copyright (c) 2007-2009 Philippe Mougin. */
/* This software is open source. See the license. */
#import "FSCNBase.h"
@implementation FSCNBase
- (void)encodeWithCoder:(NSCoder *)coder
{
if ( [coder allowsKeyedCoding] )
{
[coder encodeInt32:firstCharIndex forKey:@"firstCharIndex"];
[coder encodeInt32:lastCharIndex forKey:@"lastCharIndex"];
}
else [NSException raise:NSInvalidArchiveOperationException format:@"FSCNBase only supports keyed coding"];
}
- (id)initWithCoder:(NSCoder *)coder
{
self = [super init];
if ( [coder allowsKeyedCoding] )
{
firstCharIndex = [coder decodeInt32ForKey:@"firstCharIndex"];
lastCharIndex = [coder decodeInt32ForKey:@"lastCharIndex"];
}
else [NSException raise:NSInvalidArchiveOperationException format:@"FSCNBase only supports keyed coding"];
return self;
}
- (id)init
{
if ((self = [super init]))
{
firstCharIndex = -1;
lastCharIndex = -1;
return self;
}
return nil;
}
- (void)setFirstCharIndex:(int32_t)first lastCharIndex:(int32_t)last
{
firstCharIndex = first;
lastCharIndex = last;
}
-(void)translateCharRange:(int32_t)translation
{
firstCharIndex += translation;
lastCharIndex += translation;
}
@end